mIRC Homepage
Posted By: sCHuTt bot doing a search - 20/09/04 12:13 PM
Elllo mighty scripters, for my bot i'd like the feature to type !regged and have a bot displaying the word between a string have xxx registered. on webpage http://server/page.html

<+bot> we have xxx regged ppl according to ]http://server/page.html

Is that even possible? Look up a webpage, parse for a similar string an take the middle word out to display in a channel?

I've tried to dismantle the many google scripts but my midget brain gets confused after the second minute looking at it grin

TIA guys
Posted By: FiberOPtics Re: bot doing a search - 20/09/04 04:17 PM
Hi,

it's very much possible, but not until we know what site it is :tongue:

Greets
Posted By: sCHuTt Re: bot doing a search - 20/09/04 04:36 PM
tbh i don't see why. Say i'd like the first word on http://www.mirc.com/index.html confused
Posted By: FiberOPtics Re: bot doing a search - 20/09/04 05:05 PM
As an example, I've made you a very stupid little socket script that will display the amount of registered users on the mIRC Msgboard.

Note that I'm absolutely unexperienced with sockets, so there might be tweaks, and extra additions necessary. Nevertheless, it's a working example of how to achieve what you want.

Note that the parsing is very dependent on the way that the webpage is created, so for another webpage, the parsing will be different.

Note that right now I'm only using a regular variable (%data) and not a binvar to store the incoming data from the socket. In many occasions on different pages, the *string too long issue can arise when the read-in data exceeds the max string length possible. For our example, %data is fine though.

Usage: /showregistered

Code:
alias showregistered sockopen mirc mirc.com 80
 [color:red]  [/color] 
on *:SOCKOPEN:mirc:{
  var %sn = $sockname
  if $sockerr { echo -a Error opening socket %sn | halt }
  sockwrite -n %sn GET https://forums.mirc.com/ubbthreads.php HTTP/1.1 
  sockwrite -n %sn Host: mirc.com $+ $crlf $+ $crlf
  echo -a Opened socket %sn
}
 [color:red]  [/color] 
on *:SOCKREAD:mirc:{
  var %sn = $sockname 
  if $sockerr { echo -s Error reading from socket %sn | halt }
  var %data
  sockread %data
  if * Registered User(s). iswm %data { 
    echo -ac info * Found $gettok(%data,1,32) registered users on the mIRC Msgboard 
    sockclose %sn
    halt
  }
}
 [color:red]  [/color] 
on *:SOCKCLOSE:mirc: echo -a Closed socket $sockname

Again, it's just an example.

Btw, the on sockclose event does not get triggered when you (or your script) tells the socket to close. So normally you won't see the "Closed socket mIRC". You will however see it if it closed out of its own.

Greets
© mIRC Discussion Forums