| View previous topic :: View next topic |
| Author |
Message |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Aug 22, 2005 4:19 am Post subject: |
|
|
| 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? |
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Mon Aug 22, 2005 4:31 am Post subject: |
|
|
aaaaaaaaaaahhhhh
Sorry about that, I didnt realize no....
One final thing:
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 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Mon Aug 22, 2005 12:00 pm Post subject: |
|
|
| Code: |
bind pub - !game foo
proc foo {n u h c t} {
dnslookup [lindex [split $u @] 1] bar $n $c $t
}
proc bar {ip host stat nick chan game} {
if {$stat} {
if {$game != ""} {
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"
}
}
|
|
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Tue Aug 23, 2005 6:34 am Post subject: |
|
|
Thanks again demond for helping me!!!
The last script however gives:
[12:33] Tcl error [bar]: no value given for parameter "game" to "bar"
when I try to type only !game (with no parameters)  |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Aug 23, 2005 12:24 pm Post subject: |
|
|
| Code: |
bind pub - !game foo
proc foo {n u h c t} {
dnslookup [lindex [split $u @] 1] bar $n $c [expr {$t != ""? $t : "none"}]
}
proc bar {ip host stat nick chan game} {
if {$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"
}
}
|
|
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Tue Aug 23, 2005 1:09 pm Post subject: |
|
|
Thanks yet again demond, but...hmm...when I using nick
ghe[lix]
type
!game
I get:
[19:07] Tcl error [bar]: invalid command name "lix"
 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Aug 23, 2005 2:35 pm Post subject: |
|
|
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)
| Code: |
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"
}
}
|
|
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Tue Aug 23, 2005 4:46 pm Post subject: |
|
|
Again...and again thanks demond seems to work perfectly now !!!
(I try to forget the fact that this script now is totally jibberish to me - or what you call it)
 |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Tue Aug 23, 2005 4:56 pm Post subject: |
|
|
well perhaps it would be a good excercise for you to try understand how the thing works all you need is Tcl's manual page and tcl-commands.doc |
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Tue Aug 23, 2005 4:59 pm Post subject: |
|
|
additional note:
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... ?? |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Wed Aug 24, 2005 2:37 am Post subject: |
|
|
use this, let me know about any problems:
| Code: |
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" |
|
| Back to top |
|
 |
h3ctic Voice
Joined: 18 Aug 2005 Posts: 15
|
Posted: Sun Aug 28, 2005 5:30 pm Post subject: |
|
|
demond, I've used your script now since right after you posted that last fix, and so far no errors, works very nice
thanks!!!!
 |
|
| Back to top |
|
 |
|