rendered paste bodyimport xchatimport randomclass UtilHelper(object): """ This handles some of the various misc utilities required for battle. At this point, only timers are in here. Ways to also shut off the timers prematurely are also available. """ def __init__(self): pass def time60Delay(self, userdata): """ Sixty seconds til something... """ if self.timerOn: context = userdata context.command("say 60 seconds!") return 0 def time50Delay(self, userdata): """ Fifty seconds til something... """ if self.timerOn: context = userdata context.command("say 50 seconds!") return 0 def time40Delay(self, userdata): """ Fourty seconds til something... """ if self.timerOn: context = userdata context.command("say 40 seconds!") return 0 def time30Delay(self, userdata): """ Thirty seconds til something... """ if self.timerOn: context = userdata context.command("say 30 seconds...") return 0 def time20Delay(self, userdata): """ Twenty seconds til something... """ if self.timerOn: context = userdata context.command("say 20 seconds...!") return 0 def time10Delay(self, userdata): """ Ten seconds til something... """ if self.timerOn: context = userdata context.command("say 10 seconds!!") return 0 def timeUpDelay(self, userdata): """ Time is up... """ if self.timerOn: context = userdata context.command("say BUZZ! Time is up!") print "You can use the timers again." return 0 def start60(self, con): """ This handles the basic 60 second timer. """ self.timerOn = True # Allow this timer to run. delay60 = xchat.hook_timer(100, self.time60Delay, con) delay50 = xchat.hook_timer(10100, self.time50Delay, con) delay40 = xchat.hook_timer(20100, self.time40Delay, con) delay30 = xchat.hook_timer(30100, self.time30Delay, con) delay20 = xchat.hook_timer(40100, self.time20Delay, con) delay10 = xchat.hook_timer(50100, self.time10Delay, con) delayUp = xchat.hook_timer(60100, self.timeUpDelay, con) pass def start30(self, con): """ This handles the basic 30 second timer. """ self.timerOn = True # Allow this timer to run. delay30 = xchat.hook_timer(100, self.time30Delay, con) delay20 = xchat.hook_timer(10100, self.time20Delay, con) delay10 = xchat.hook_timer(20100, self.time10Delay, con) delayUp = xchat.hook_timer(30100, self.timeUpDelay, con) def start20(self, con): """ This handles the basic 20 second timer. """ self.timerOn = True # Allow this timer to run. delay20 = xchat.hook_timer(100, self.time20Delay, con) delay10 = xchat.hook_timer(10100, self.time10Delay, con) delayUp = xchat.hook_timer(20100, self.timeUpDelay, con) def timerToggle(self, toBeOn="off"): """ This messes with the state of the timers. This can only "turn off" timers: the timers themselves will still run. """ word = "" if toBeOn.lower() == "True".lower() or toBeOn.lower() == "On".lower(): word = "on" self.timerOn = True else: word = "off" self.timerOn = False print "say \x02The timer is now %s!\x02" % word return xchat.EAT_ALL def UtilRoll(self, word, word_eol, userdata): """ The rolls needed are used here. """ # /util timer [<seconds>] context = xchat.get_context() if word[1].lower() == "timer".lower(): if len(word) == 2: self.start60(context) elif len(word) == 3: if int(word[2]) == 60: self.start60(context) elif int(word[2]) == 30: self.start30(context) elif int(word[2]) == 20: self.start20(context) else: pass # /util togger <feature> elif word[1].lower() == "toggle".lower(): if word[2] == "timer".lower(): if len(word) == 4: self.timerToggle(word[3]) else: self.timerToggle() else: pass return xchat.EAT_ALL