Posted by electronerd Fri 23rd Mar 2007 23:56 - Syntax is Python - 85 views
Download | New Post | Modify | Hide line numbers
  1. import time
  2.  
  3.  
  4. def ping(irccontext, source, dest, text):
  5.     if dest == irccontext.me():
  6.         #the message was sent to me in a pm
  7.         target = source
  8.     else:
  9.         #the message was sent to a channel
  10.         target = dest
  11.    
  12.     starttime = time.time()
  13.     irccontext.sendCtcp("PING", dest=source, value="I do not need the value of this anymore", priority="immediate")
  14.     try:
  15.         response = irccontext.waitFor("ctcp-response", "ping", source=source, dest=irccontext.me(), timeout=60)
  16.         endtime = time.time()
  17.         irccontext.sendMsg("Lag time to %s: %.3f" % (source, endtime-starttime),
  18.     except TimeoutException e:
  19.         irccontext.sendMsg("No response from %s in 60 seconds" % dest)
  20.        
  21. #bind() is like waitFor() except it is asynchronous (like eggdrop's bind)1
  22. 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

 

Comments: 0