| View previous topic :: View next topic |
| Author |
Message |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Thu Aug 18, 2005 4:45 pm Post subject: pm user if raw 307 is null |
|
|
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: |
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. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Thu Aug 18, 2005 5:42 pm Post subject: |
|
|
| 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) |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Thu Aug 18, 2005 7:40 pm Post subject: |
|
|
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? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Thu Aug 18, 2005 11:51 pm Post subject: |
|
|
actually, you only need to track 3 WHOIS replies:
| Code: |
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) |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 12:27 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 19, 2005 12:35 am Post subject: |
|
|
| hmm you must have messed up something, my code sends one message only, "please identify or register your nick" |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 1:01 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 1:09 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 19, 2005 1:18 am Post subject: |
|
|
| what's the server IP? |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 1:36 am Post subject: |
|
|
| dunno...the add'y is irc.gigairc.net |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 19, 2005 1:50 am Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 2:16 am Post subject: |
|
|
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 } } |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 19, 2005 2:26 am Post subject: |
|
|
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) |
|
| Back to top |
|
 |
mikey2 Voice
Joined: 18 Aug 2005 Posts: 19
|
Posted: Fri Aug 19, 2005 2:44 am Post subject: |
|
|
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? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Aug 19, 2005 3:00 am Post subject: |
|
|
you usually add colors by using mIRC's color escape code, ASCII 3:
| Code: |
puthelp "privmsg $n :\0034,8 this will show up in red on yellow background"
|
refer to mIRC's online help for color codes designations |
|
| Back to top |
|
 |
|