Exemple #1
0
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
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
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
Exemple #6
0
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
Exemple #7
0
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
Exemple #8
0
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
Exemple #9
0
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
Exemple #10
0
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
Exemple #11
0
def is_resurring_running(name):
    if not settings.exists(name, recurring_domain):
        return None

    return _get_recurring(name).running
Exemple #12
0
def is_resurring_running(name):
    if not settings.exists(name, recurring_domain):
        return None

    return _get_recurring(name).running