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.

Making my windrop-bot respond with the users IP adress

Old posts that have not been replied to for several years.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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?
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

aaaaaaaaaaahhhhh :oops:

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
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

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"
   }
} 
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

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) :?:
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

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"
   }
} 
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

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"

:?:
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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: Select all

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"
   }
}
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

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)

:D
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

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
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

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... ??
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

use this, let me know about any problems:

Code: Select all

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"
h
h3ctic
Voice
Posts: 15
Joined: Thu Aug 18, 2005 8:00 pm

Post by h3ctic »

demond, I've used your script now since right after you posted that last fix, and so far no errors, works very nice

thanks!!!!

:)
Locked