This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

pm user if raw 307 is null

Help for those learning Tcl or writing their own scripts.
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

pm user if raw 307 is null

Post by mikey2 »

I'm trying to write a tcl that will whois a user when he/she joins a channel, and send a pm only if the nick is not registered. I have this snippet here, which need to be modified:

Code: Select all

bind join - * whois:onjoin 
bind raw - 307 whois:num 

 
proc whois:onjoin {nick host hand chan} { putserv "WHOIS $nick" } 
 
proc whois:num {from key arg} { 
 set nick [lindex [split $arg] 1] 
 if {![string equal $nick $::botnick]} { 
  puthelp "PRIVMSG $nick :[join [lrange [split $arg] 1 end]]" 
 } 
}
This simply pm's a user with their whois info. I guess I need an if statement that tests whether the value of 307 is null...Sorry if I'm not making sense, I'm a newbie here.

Thanks for your help.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you need to track the whole WHOIS response, from 311 to 318 (End of /WHOIS list), i.e. when you get 318 and you still haven't got 307 for that nick, it means the nick has not identified (or isn't registered)
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

Thanks Demond for your help.

ok, I suppose I what you suggested, like this:

bind raw - 311 whois:num
bind raw - 312 whois:num
bind raw - 313 whois:num
(up to 318)

Then how do I identify the existence (or lack thereof) of 307?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

actually, you only need to track 3 WHOIS replies:

Code: Select all

bind join - * foo
proc foo {n u h c} {
   puthelp "whois $n"
} 
bind raw - 311 got311 ;# first WHOIS reply
bind raw - 307 got307 ;# nick has identified (registered)
bind raw - 318 got318 ;# End of /WHOIS list 
proc got311 {f k t} {
   set n [lindex [split $t] 1]
   set ::whoised($n) 0
}
proc got307 {f k t} {
   set n [lindex [split $t] 1]
   incr ::whoised($n)
}
proc got318 {f k t} {
   set n [lindex [split $t] 1]
   if {$::whoised($n) == 0} {
      puthelp "privmsg $n :please identify or register your nick"
   }
}
using [puthelp] is recommended since it lowers the rate of output to server, thereby decreasing the chance of disconnecting because of "Excess flood" (remember, you send to server on join, and you might be join-flooded); of course, this implementation is not 100% correct and will actually skip some joining users since most IRC servers have the WHOIS command paced, e.g. you are allowed one WHOIS in 2 seconds; if you need absolute precision on that, you have to implement your own WHOIS output queue with appropriate for your server flush-out frequency (which is not hard, search the forum, I've already written about that)
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

Wow....it is so close...It actually does what I need, but is there any way to prevent this info in the pm?

UN-REGISTERED NICKS SEE THIS:

[9:20pm] <hugo> bozo Mikey (host here)* :Mike Smith
[9:20pm] <hugo> bozo (:#channel here)
[9:20pm] <hugo> bozo (server here)
[9:20pm] <hugo> please identify or register your nick

(can I omit the first three lines?)

REGISTERED NICK SEE THIS:

[9:23pm]‹ hugo › mikey mikey cdg.rocks.net * :mikey
[9:23pm]‹ hugo › mikey (:#channel here)
[9:24pm]‹ hugo › mikey (server here)
[9:24pm]‹ hugo › mikey :End of /WHOIS list.

(can I omit the pm all together?)

The whois runs two times also.

I look forward to your response. And thanks in a big way for this :)
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

hmm you must have messed up something, my code sends one message only, "please identify or register your nick"
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

I saved as a new tcl and rehashed the bot. Will copy and paste code again.

I really appreciate your help on this...Will check back if I have probs.
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

still same...

server is gigairc, wonder if this is causing the prob.

an irc peep said perhaps omit the raw 311.

Wonder if this will work.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

what's the server IP?
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

dunno...the add'y is irc.gigairc.net
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

mikey2 wrote:dunno...the add'y is irc.gigairc.net
it supports the standard WHOIS replies so my script should work as intended

remove all other scripts from config file temporarily and restart the bot, see if that helps
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

commented scripts in the .conf file, rehashed and same.
weird
any other ideas?
another person provided this code, which does the same thing:

#bind join - * foo
#proc foo {n u h c} { puthelp "whois $n" }
#bind raw - 307 got307 ;# nick has identified (registered)
#bind raw - 318 got318 ;# End of /WHOIS list
#proc gesc {str} { string tolower [string map {\\ \\\\ \[ \\\[ \] \\\] \{ \\\{ \} \\\}} $str] }
#proc got307 {f k t} { array set ::registered "[gesc [lindex $t 1]] 1" }
#proc got318 {f k t} { set n [gesc [lindex $t 1]]; set nick [lindex $t 1]; if {![info exists ::registered($n)]} { puthelp "PRIVMSG $nick :register ya damn nick" } { array unset ::registered $n } }
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

that [string map] is useless (and their script is incorrect) but anyway

what's your channel? I can't believe my script behaves the way you said it does and want to see that for myself

of course, you need to leave only my script active in your config and restart the bot (re-start, not rehash)
m
mikey2
Voice
Posts: 19
Joined: Thu Aug 18, 2005 4:39 pm

Post by mikey2 »

I've officially changed my nick to bonehead...lol
works FINE when u re-start...re-hash don't do a darn thing.

ur my hero :) Thanks so much for your help. Sorry I took so long to see the light.

Now...I'd like to dress up the pm output a bit. What is an easy way (a.k.a. a way I'll understand) to add colors, or other gaudy things?
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

;)

you usually add colors by using mIRC's color escape code, ASCII 3:

Code: Select all

puthelp "privmsg $n :\0034,8 this will show up in red on yellow background"
refer to mIRC's online help for color codes designations
Post Reply