mIRC Home    About    Download    Register    News    Help

Print Thread
#133329 19/10/05 09:44 AM
Joined: May 2005
Posts: 79
M
Babel fish
OP Offline
Babel fish
M
Joined: May 2005
Posts: 79
A friend of mine has a socket bot and want's it to count numbers and letters ie;

" !count 1 11 " and it counts 1 2 3 4 5 etc to 11

and also " !count a f " and it goes a b c d etc

does anyone have a way of doing this and would it involve regular expressions? thanks for any help.

#133330 19/10/05 11:58 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
regular expressions make socket scripting much easier to deal with.

umn, just an example:

Code:
if ($regex(%sread,/^:([^!]*)!([^\@]*)@([^\ ]*?) PRIVMSG (#[^\ ]*) :(.+)$/)) {
  var %nick = $regml(1) , %ident = $regml(2) , %host = $regml(3)
  var %chan = $regml(4) , %msg = $regml(5) , %wdaddress = $+(%ident,@,%host)
  var %pmsg = sockwrite -n $sockname privmsg %chan :

  if ($regex(%msg,/^!count ([^\ ]+) (.+)$/)) {
    var %begin = $regml(1) , %end = $regml(2)
    if (%begin isnum && %end isnum) {
      while (%begin <= %end) {
        var %counting = %counting %begin
        inc %begin
      }
    }
    elseif (%begin isletter && %end isletter) {
      var %begin = $asc(%begin) , %end = $asc(%end)
      while (%begin <= %end) {
        var %counting = %counting $chr(%begin)
        inc %begin
      }
    }
    %pmsg $+ Counting: %counting
  }
}


That *should* work.

Probably would have to add a few "checks," especially for the "letters" part.

Edit: Oops.. missed a ).

Last edited by Rand; 19/10/05 12:10 PM.
#133331 21/10/05 07:23 AM
Joined: May 2005
Posts: 106
S
Vogon poet
Offline
Vogon poet
S
Joined: May 2005
Posts: 106
1, 2, 3, 4, 5 oh man counting is hard :P


and thats the way the scout leader burns

Link Copied to Clipboard