mIRC Homepage
Posted By: EricDraven help with raws - 04/02/04 03:45 AM
i op on a server that includes regestered users age and sex as part of the /whois
what i need to do is strip this out of /whois into a %var so i can check it or print it out
main reason being to kick anyone who isnt a teen out of teens room and isnt an adult out of adultsonly room
doing
/debug on
/whois targetnick
/debug off
shows the line i need is
:irc.ukchatterbox.com 320 mynick targetnick :is 19/male
so am i right in saying i have to trap the raws from a /whois command?, how do i do this?
Posted By: Online Re: help with raws - 04/02/04 04:35 AM
raw 320:*: echo -s Name: $2 - Age: $gettok($4,1,47) - Sex: $gettok($4,2,47)

Using $gettok($4,2,47) you can even kick females out of males-only room wink
Posted By: EricDraven Re: help with raws - 04/02/04 05:03 AM
thanks, but how do i assign the returned line to a variable so that i can print it to a window, or use it in a warning/kick
and how can i do it to everyone in the room without flooding my status (ie supress /whois from displaying), but still be able to do /whois normaly from command line or popup
Posted By: Online Re: help with raws - 04/02/04 07:44 AM
Here's an example:
Code:
On @*:join:[color:blue]#teenworld[/color],[color:blue]#20+[/color]:{
  if $hget(whois,0).item < 3 {
    ;
    ; The hash table "whois" stores the nicks you are doing a WHOIS on.
    ;
    hadd -mu20 whois $nick #
    whois $nick
  }
}
 
raw *:*:{
  ;
  ; 310-320 is the range of WHOIS replies.
  ;
  if $numeric isnum 310-320 && $hget(whois,$2) {
    if $numeric == 320 {
      [color:green]echo -s Name: $2 - Age: $gettok($4,1,47) - Sex: $gettok($4,2,47)[/color]
    }
    if $numeric == 318 { 
      ; 
      ; 318 = End of WHOIS
      ;
      hdel whois $2
    }
    haltdef
  }
}

To know what a specific command does, type /help /command. See the gree line? This informal /echo can be replaced with anything else. For example -
Code:
    if $numeric == 320 {
      var %nick = $2
      var %chan = $hget(whois,$2)
      var %age = $gettok($4,1,47)
 
      if %chan == #teenworld && %age >= 20 {
        notice %nick Man, you're too old for %chan
      }
      elseif %chan == #20+ && %age < 20 {
        kick %chan %nick See you in #teenworld
      }
    }

I hope it wasn't too complicated...
To keep the current code structure, first paste in Word or Wordpad then copy to the mIRC editor.
Posted By: EricDraven Re: help with raws - 05/02/04 03:22 AM
thanks m8, cant get it to work as typed, but at least it gives me some ideas to work on
(note to self: best readup about hash tables now)
by the way, i use EditPlus for all my scripting,html coding etc but thanks grin
Posted By: Online Re: help with raws - 05/02/04 03:48 AM
I couldn't test this script because the servers I'm on do not send the age/sex reply you mentioned. If you want, tell me the name of your network and we'll do some tests.

You can find a hash tables tutorial here:
http://helpdesk.zaz.net/documents/tutorials.php
Posted By: Cheech Re: help with raws - 05/02/04 04:11 AM
probably i am misunderstanding this but ? if this is the response
:irc.ukchatterbox.com 320 mynick targetnick :is 19/male
wont this
Age: $gettok($4,1,47) - Sex: $gettok($4,2,47)
return the number 1 for age and the number 9 for sex ?
Posted By: Online Re: help with raws - 05/02/04 04:55 AM
Well you can check this yourself smile
Assuming $4 is the word "17/male", type:
  • //echo -a Age: $gettok(17/male,1,47)
    //echo -a Sex: $gettok(17/male,2,47)
Those $gettok's treat the string as if it's separated by / - ASCII number 47 - and return either the first (1) or second (2) part of that string. Read more on tokens at Helpdesk's website.
Posted By: Cheech Re: help with raws - 05/02/04 01:36 PM
ah i see now thats what i was unclear on was the number 47 or 32 etc.. from the help file makes sense now thx for the explanation smile
Posted By: Kaneda Re: help with raws - 05/02/04 11:38 PM
What if you wanted to check for how many channels the joining nick is in, like for porn advertiser kicking purposes?
© mIRC Discussion Forums