def stop_recurring(name): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) recurring.stop() print '[Recurring] Stopping %s for %s' % (name, the_channel) return True
def skip_recurring(name): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) recurring.reset() print '[Recurring] Skipping %s for %s' % (name, the_channel) return True
def start_recurring(name): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) recurring.start(settings.getdata(name + '_data', recurring_domain)[0], True) print '[Recurring] Starting %s for %s' % (name, the_channel) return True
def start_recurring(name): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) recurring.start( settings.getdata(name + '_data', recurring_domain)[0], True) print '[Recurring] Starting %s for %s' % (name, the_channel) return True
def set_timeout(name, newtimeout, imediatestart=True): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) oldtimeout, message, createdat = settings.getdata(name + '_data', recurring_domain) recurring.stop() recurring.start(newtimeout, imediatestart) settings.setdata(name + '_data', (newtimeout, message, createdat), recurring_domain) print '[Recurring] Changed %s timeout: %s -> %s, %simediate' % (name, oldtimeout, newtimeout, '' if imediatestart else 'not ') return True
def delete_recurring(name): if not settings.exists(name, recurring_domain): return False print '[Recurring] Deleting %s for %s' % (name, the_channel) # WHAT A F*****G WEIRD WAY TO DO THIS try: rtask = _get_recurring(name) rtask.stop() del rtask except: pass settings.deldata(name, recurring_domain) settings.deldata(name + '_data', recurring_domain) return True
def set_timeout(name, newtimeout, imediatestart=True): if not settings.exists(name, recurring_domain): return False recurring = _get_recurring(name) oldtimeout, message, createdat = settings.getdata(name + '_data', recurring_domain) recurring.stop() recurring.start(newtimeout, imediatestart) settings.setdata(name + '_data', (newtimeout, message, createdat), recurring_domain) print '[Recurring] Changed %s timeout: %s -> %s, %simediate' % ( name, oldtimeout, newtimeout, '' if imediatestart else 'not ') return True
def register_new_recurring(bot, name, message, timeout, duration=None, autostart=True): if settings.exists(name, recurring_domain): return False timeout = int(timeout) message = str(message) recurtask = task.LoopingCall(_online_check_wrapper, the_channel, message, bot) recurringid = id(recurtask) settings.setdata(name, recurringid, recurring_domain) settings.setdata(name + '_data', (timeout, message, time.time()), recurring_domain) print '[Recurring] Creating recurring %s for %s' % (name, the_channel) if autostart: recurtask.start(timeout, False) return True
def register_new_recurring(bot, name, message, timeout, autostart=True): if settings.exists(name, recurring_domain): return False timeout = int(timeout) message = str(message) recurtask = task.LoopingCall(_online_check_wrapper, the_channel, message, bot) recurringid = id(recurtask) settings.setdata(name, recurringid, recurring_domain) settings.setdata(name + '_data', (timeout, message, time.time()), recurring_domain) print '[Recurring] Creating recurring %s for %s' % (name, the_channel) if autostart: recurtask.start(timeout, False) return True
def is_resurring_running(name): if not settings.exists(name, recurring_domain): return None return _get_recurring(name).running