So I'm writing a bit of code for use in an IRC bot. I tried to use scheduler to get around the barbaric-ness of calling time.sleep() every time I want the bot to delay for a few seconds. In scheduler you can choose the delay function "for example time.sleep()"-- but I haven't found any mention of other delay functions anywhere on the net.
Being an IRC bot it's important that it can receive pings and distribute pongs when necessary. time.sleep(), however, pauses the entire .py, rendering the ping/pong lines irrelevant and ultimately leading to a ping timeout.
import time
import sched
snip
c=sched.scheduler(time.time, time.sleep)
snip
x=msg
if(int(x)>=30):
def xsc(x):
swrite("JOIN "+chan)
privmsg(chan, "I'm back after a "+x+" second sleave!")
swrite("PART "+chan)
c.enter(float(x), 1, xsc, (x,))
c.run()
else:
privmsg(chan, "At least a 30 second kick, please ;).")