Posted by electronerd Fri 23rd Mar 2007 23:56 - Syntax is Python - 85 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
-
import time
-
-
-
def ping(irccontext, source, dest, text):
-
if dest == irccontext.me():
-
#the message was sent to me in a pm
-
target = source
-
else:
-
#the message was sent to a channel
-
target = dest
-
-
starttime = time.time()
-
irccontext.sendCtcp("PING", dest=source, value="I do not need the value of this anymore", priority="immediate")
-
try:
-
response = irccontext.waitFor("ctcp-response", "ping", source=source, dest=irccontext.me(), timeout=60)
-
endtime = time.time()
-
irccontext.sendMsg("Lag time to %s: %.3f" % (source, endtime-starttime),
-
except TimeoutException e:
-
irccontext.sendMsg("No response from %s in 60 seconds" % dest)
-
-
#bind() is like waitFor() except it is asynchronous (like eggdrop's bind)1
-
irccontext.bind(keyword="PRIVMSG", match="!ping", script=ping)
PermaLink to this entry https://pastebin.co.uk/12157
Posted by electronerd Fri 23rd Mar 2007 23:56 - Syntax is Python - 85 views
Download | New Post | Modify | Hide line numbers
Download | New Post | Modify | Hide line numbers
Comments: 0