mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2014
Posts: 1
B
BCodeIt Offline OP
Mostly harmless
OP Offline
Mostly harmless
B
Joined: Sep 2014
Posts: 1
Hello Fellow Mirc users smile

I am currently trying to finish my script, so I can read the 1 line text I have on a webpage.

My Code:

Code:
alias test {
  sockopen test host.com 80
}

on *:sockopen:test: {
  sockwrite -n $sockname GET /index.php?test=1 HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  sockwrite -n $sockname Host: host.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname
}

on *:sockread:test: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temp
    sockread -f %temp
  }
}

on *:text:!test:#: {
    var %temp $test()
    msg $chan %temp
}


I use my own webpage instead of host.com in my script.

The script is not working now, and that's why I kindly ask for your help smile

It's supposed work like this when it's used in twitchs chat:
!test command is used -> It opens the socket, goes to the website and return the text from the webpage.

It shouldn't be a problem since source code at: /index.php?test=1 returns: Hello This is a test.


I hope anyone can help me further with my problem smile


Last edited by BCodeIt; 08/09/14 12:46 PM.
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Try using this code but be careful for excess flood! in order to work this code the bot must be into the channel that the !test command executed.

Code:
on *:sockopen:test: {
  if ($sockerr) {
    var %m = $iif($me ison $sock($sockname).mark,msg $sock($sockname).mark,echo -a)
    %m Error, The was an connection error, try again later!
    sockclose $sockname
    return
  }
  sockwrite -n $sockname GET /index.php HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  sockwrite -n $sockname Host: host.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname
}
on *:sockread:test: {
  if ($sockerr) {
    var %m = $iif($me ison $sock($sockname).mark,msg $sock($sockname).mark,echo -a)
    %m Error, The was an connection reading error, try again later!
    sockclose $sockname
    return
  }
  var %temp
  sockread -f %temp 
  if ($sockbr) {
    if ($me ison $sock($sockname).mark) { $iif($me ison $sock($sockname).mark,msg $sock($sockname).mark,echo -a) READ: %temp }
  }
}

on *:text:!test:#: {
  if ($sock(test)) { .msg $chan Error, Already in use, Please wait to finish! | return }
  sockopen test google.com 80
  sockmark test $chan
}


- Thanks!


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-

Link Copied to Clipboard