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 

PING script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
chadchoud
Voice


Joined: 20 Sep 2006
Posts: 2

PostPosted: Wed Sep 20, 2006 2:16 pm    Post subject: PING script Reply with quote

I wrote a tcl ping script. I'm still a newbie in tcl. I hope somebody can help.
Here's the script:
Code:

bind PUB - !ping CheckPing

proc CheckPing {nick uhost hand chan text} {
  putserv "privmsg $chan : [lindex [split $text] 0]"
  if { [lindex [split $text] 0] != "" } {
    set ::moo(arg) [lindex [split $text] 0]
  } else {
      set ::moo(arg) $nick
  }
  set ::moo(ticks) [clock clicks -milliseconds]
  set ::moo(chan) $chan
  putserv "privmsg $chan : $moo(arg) "
  putserv "privmsg [lindex $moo(arg) :\001PING [clock clicks -milliseconds]\001"
  putserv "privmsg $chan :ping sent!"
  putserv "privmsg $chan :I'm sending the ping request to $moo(arg) now."
}

bind CTCR - PING* Reply

proc Reply {nick uhost hand dest keyword text} {
  global server moo
  putserv "privmsg $moo(chan) :$moo(arg)'s ping reply from $server is : [expr [expr [clock clicks] - $moo(ticks)] / 1000]"
}


As you see, I added some debuging, and found that $moo(arg) isn't filled.

I didn't check the ctcp reply yet..
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Sep 20, 2006 2:47 pm    Post subject: Reply with quote

Code:

set pingchans "#mychan #chan2 #etc"

bind pub - .ping pub:ping
bind ctcr - PING ctcr:ping

proc pub:ping {nick uhost hand chan arg} {
global pingreq pingp pingchans
        if {[lsearch -exact $pingchans $chan] == -1} {
                puthelp "PRIVMSG $nick :ping disabled on $chan"
                return
        }
        set arg [string trim $arg]
        if {![info exists pingp($chan)]} {
                set pingp($chan) 0
        }
        utimer 2 [list incr pingp($chan) -1]
        if {[incr pingp($chan)] < 3} {
                if {[set targ [lindex [split $arg] 0]] == ""} {
                        putserv "PRIVMSG $chan :Use: .ping <nick> or .ping me"
                        return
                }
                if {([string equal -nocase "me" $targ] == 1)} {
                        putserv "PRIVMSG $nick :\001PING [clock clicks -milliseconds]\001"
                        set pingreq([string tolower $nick]) "$chan"
                        return
                }
                if {[onchan $targ $chan]} {
                        putserv "PRIVMSG $targ :\001PING [clock clicks -milliseconds]\001"
                        set pingreq([string tolower $targ]) "$chan"
                } else {
                        puthelp "PRIVMSG $chan :$targ is not in $chan."
                }
        }
}

proc ctcr:ping {nick uhost hand dest keyword arg} {
        global pingreq
        if {![info exists pingreq([set nnick [string tolower $nick]])]} {return}
        if {[string is integer [set reply [lindex [split $arg] 0]]]} {
                putserv "PRIVMSG $pingreq($nnick) :\[\002$nick\002 PING reply\]: [expr {abs([clock clicks -milliseconds] - $reply) / 1000.0}] seconds."
        }
        unset pingreq($nnick)
}

putlog "Ping.tcl v1.3 by Opposing Loaded..."
Back to top
View user's profile Send private message
chadchoud
Voice


Joined: 20 Sep 2006
Posts: 2

PostPosted: Wed Sep 20, 2006 4:42 pm    Post subject: sorry Reply with quote

sorry but I didn't ask for a pre-made script. I just asked where's the problem in my own. and the "rules" on this section of the forum are "do no request scripts".
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Wed Sep 20, 2006 5:17 pm    Post subject: Reply with quote

And it would be polite for you to enclose your code within code tags.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Sep 20, 2006 7:56 pm    Post subject: Re: sorry Reply with quote

chadchoud wrote:
sorry but I didn't ask for a pre-made script. I just asked where's the problem in my own. and the "rules" on this section of the forum are "do no request scripts".


I posted it as an example of a working script. Take it as such, or read it and learn from it.
Back to top
View user's profile Send private message
stdragon
Owner


Joined: 23 Sep 2001
Posts: 959

PostPosted: Fri Sep 22, 2006 10:06 pm    Post subject: Reply with quote

Code:

 putserv "privmsg [lindex $moo(arg) :\001PING [clock clicks -milliseconds]\001"


That's the only obvious error I see so far. When you tested $moo(arg) did you get an error (undeclared) or was it just the wrong value (e.g. empty)?
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
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