don't you realize that if you type !game FOO it will reply with goober is hosting FOO on 1.2.3.4 and if you type !game BAR it will reply with goober is hosting BAR on 1.2.3.4?
is it possible to edit that last code you wrote to have it also respond only with the users ip adress to the trigger !game when theres no second parameter ?
like:
<user>!game FOO
<bot>user is hosting FOO on 1.2.3.4
<user>!game
<bot>user your ip is: 1.2.3.4
nice observation h3ctic, and a good occasion to show how to avoid a security pitfall of [dnslookup] (see my article "Script security" in the FAQ section)
bind pub - !game foo
proc foo {n u h c t} {
if {$t == ""} {set t none}
dnslookup [lindex [split $u @] 1] bar n c t
}
proc bar {ip host stat n c t} {
upvar $n nick; upvar $c chan; upvar $t game
regsub -all {\.} $host {} host
if {[string is digit $host] || $stat} {
if {$game != "none"} {
puthelp "privmsg $chan :$nick is hosting $game on $ip"
} {
puthelp "privmsg $chan :$nick's ip address is $ip"
}
} {
puthelp "privmsg $chan :error resolving $nick's ip"
}
}
hmm...this is weird..but it seems every now and then I get this in my log:
[22:53] Tcl error [bar]: can't read "game": no such variable
from channel:
[23.08 - 22:53] <+me> can u type "!game" then "!game test"
[23.08 - 22:53] <user-1> !game
[23.08 - 22:54] <user-1> !game test
[23.08 - 22:54] <@bot> user1 is hosting test game on 1.2.3.4
[23.08 - 22:54] <me> hmm...type !game again plz
[23.08 - 22:55] <user-1> !game
[23.08 - 22:55] <@bot> user1's ip address is 1.2.3.4
[23.08 - 22:55] <me> hmm
note that i've renamed stuff above, the user "user-1"'s nick included a - (minus sign)
the weird thing is that its not consistant...meaning the script will not give the error in log (mentioned above) every time... ??
bind pub - !game foo
proc foo {n u h c t} {
if {$t == ""} {set t none}
dnslookup [lindex [split $u @] 1] [list bar $n $c $t]
}
proc bar {nick chan game ip host stat} {
regsub -all {\.} $host {} host
if {[string is digit $host] || $stat} {
if {$game != "none"} {
puthelp "privmsg $chan :$nick is hosting $game on $ip"
} {
puthelp "privmsg $chan :$nick's ip address is $ip"
}
} {
puthelp "privmsg $chan :error resolving $nick's ip"
}
}
can anyone take an educated guess why the previous version sometimes worked and sometimes didn't? [dnslookup] is trickier than [utimer], maybe I should comment on it in "Script security"