### eggping.tcl v1.0.1, 1 April 2002
### by Graeme Donaldson
###  - !ping or !pingme on a channel, or
###  - /msg bot ping or /msg bot pingme

# Public triggers, seperated by spaces.
set pingpubwords "!ping !pingme"

# /msg triggers, seperated by spaces.
set pingmsgwords "ping pingme"

# If there are channels where you don't want the bot to listen for !ping
# requests, set them here, seperated by spaces, e.g. "#lame #lamer #lamest"
set pingdisabled ""


### YOU SHOULDN'T NEED TO EDIT ANYTHING BEYOND THIS POINT! ###
set pingver "1.0.1"
set pingnver "100001"
putlog "Loading eggping.tcl $pingver by Souperman..."
if {[info tclversion]<8.3} {
	set pingmethod 0
	putlog " eggping.tcl: Tcl [info patchlevel] detected; using normal ping."
} else {
	set pingmethod 1
	putlog " eggping.tcl: Tcl [info patchlevel] detected; using millisecond ping."
}
foreach trigger [split $pingpubwords] { bind pub - $trigger pingnick }
foreach trigger [split $pingmsgwords] { bind msg - $trigger pingnick }
bind ctcr - PING pingreply
proc pingnick {nick host hand chan {arg ""}} {
	global pingmethod pingdisabled
	foreach channel [split $pingdisabled] {
		if {[string tolower $channel] == [string tolower $chan]} {
			return
		}
	}
	if {$pingmethod==0} {
		putquick "PRIVMSG $nick :\001PING [unixtime]\001"
	} else {
		putquick "PRIVMSG $nick :\001PING [clock clicks]\001"
	}
	return 1
}
proc pingreply {nick host hand dest key args} {
	global pingmethod server
	set pingnum [lindex $args 0]
	set pingserver [lindex [split $server :] 0]
	if {![regexp -- {[^0-9]} $pingnum]} {
		if {$pingmethod==0} {
			puthelp "NOTICE $nick :Ping reply from $pingserver: [duration [expr [unixtime] - $pingnum]]"
		} else {
			puthelp "NOTICE $nick :Ping reply from $pingserver: [expr [expr [clock clicks] - $pingnum] / 1000.000] seconds"
		}
		return 0
	}
}
putlog " Visit http://www.eggdrop.za.net/ for updates and other Tcl scripts."
putlog "Successfully loaded eggping.tcl $pingver by Souperman!"
Published in: TCL
Download

Related snippets