egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Making my windrop-bot respond with the users IP adress
Goto page Previous  1, 2
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive
View previous topic :: View next topic  
Author Message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Aug 22, 2005 4:19 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Mon Aug 22, 2005 4:31 am    Post subject: Reply with quote

aaaaaaaaaaahhhhh Embarassed

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Aug 22, 2005 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Tue Aug 23, 2005 6:34 am    Post subject: Reply with quote

Thanks again demond for helping me!!! Smile

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) Question
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Aug 23, 2005 12:24 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Tue Aug 23, 2005 1:09 pm    Post subject: Reply with quote

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"

Question
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Aug 23, 2005 2:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Tue Aug 23, 2005 4:46 pm    Post subject: Reply with quote

Again...and again thanks demond seems to work perfectly now !!! Smile

(I try to forget the fact that this script now is totally jibberish to me - or what you call it)

Very Happy
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Aug 23, 2005 4:56 pm    Post subject: Reply with quote

well perhaps it would be a good excercise for you to try understand how the thing works Smile all you need is Tcl's manual page and tcl-commands.doc
Back to top
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Tue Aug 23, 2005 4:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Wed Aug 24, 2005 2:37 am    Post subject: Reply with quote

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? Smile [dnslookup] is trickier than [utimer], maybe I should comment on it in "Script security"
Back to top
View user's profile Send private message Visit poster's website
h3ctic
Voice


Joined: 18 Aug 2005
Posts: 15

PostPosted: Sun Aug 28, 2005 5:30 pm    Post subject: Reply with quote

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

thanks!!!!

Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    egghelp.org community Forum Index -> Archive All times are GMT - 4 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber