예제 #1
0
def handle_reboot(bot, ievent):

    """ reboot .. reboot the bot. """

    ievent.reply('rebooting')
    global backupstop
    stateful = True

    if ievent.rest == 'cold':
        stateful = False

    time.sleep(2)

    try: 
        backupstop = 1
        if not stateful:
            fleet.exit()
        else:
            fleet.exit(jabber=True)
        plugins.exit()
    finally:
        if stateful:
            mainhandler.put(0, reboot_stateful, bot, ievent, fleet, partyline)
        else:
            mainhandler.put(0, reboot)
예제 #2
0
def reboot_stateful(bot, ievent, fleet, partyline):
    """ reboot the bot, but keep the connections """
    config.reload()
    session = {'bots': {}, 'name': bot.name, 'channel': ievent.channel, \
'partyline': []}
    for i in fleet.bots:
        session['bots'].update(i._resumedata())
    session['partyline'] = partyline._resumedata()
    sessionfile = tempfile.mkstemp('-session', 'gozerbot-')[1]
    dump(session, open(sessionfile, 'w'))
    fleet.save()
    fleet.exit(jabber=True)
    os.execl(sys.argv[0], sys.argv[0], '-r', sessionfile)
예제 #3
0
def fleet_disable(bot, ievent):
    """ disable a fleet bot. """

    if not ievent.rest:
        ievent.missing("list of fleet bots")
        return

    bots = ievent.rest.split()

    for name in bots:
        bot = fleet.byname(name)
        if bot:
            bot.cfg['enable'] = 0
            bot.cfg.save()
            ievent.reply('disabled %s' % name)
            fleet.exit(name)
        else:
            ievent.reply("can't find %s bot in fleet" % name)
예제 #4
0
def fleet_disable(bot, ievent):

    """ disable a fleet bot. """

    if not ievent.rest:
        ievent.missing("list of fleet bots")
        return

    bots = ievent.rest.split()

    for name in bots:
        bot = fleet.byname(name)
        if bot:
            bot.cfg['enable'] = 0
            bot.cfg.save()
            ievent.reply('disabled %s' % name)
            fleet.exit(name)
        else:
            ievent.reply("can't find %s bot in fleet" % name)
예제 #5
0
def handle_reboot(bot, ievent):
    """ reboot .. reboot the bot. """

    ievent.reply('rebooting')
    global backupstop
    stateful = True

    if ievent.rest == 'cold':
        stateful = False

    time.sleep(2)

    try:
        backupstop = 1
        if not stateful:
            fleet.exit()
        else:
            fleet.exit(jabber=True)
        plugins.exit()
    finally:
        if stateful:
            mainhandler.put(0, reboot_stateful, bot, ievent, fleet, partyline)
        else:
            mainhandler.put(0, reboot)
예제 #6
0
def handle_fleetdisconnect(bot, ievent):
    """ fleet-disconnect <botname> .. disconnect a fleet bot from server. """

    try:
        botname = ievent.args[0]
    except IndexError:
        ievent.missing('<botname>')
        return

    ievent.reply('exiting %s' % botname)

    try:
        if fleet.exit(botname):
            ievent.reply("%s bot stopped" % botname)
        else:
            ievent.reply("can't stop %s bot" % botname)
    except Exception, ex:
        ievent.reply(str(ex))
예제 #7
0
def handle_fleetdisconnect(bot, ievent):

    """ fleet-disconnect <botname> .. disconnect a fleet bot from server. """

    try:
        botname = ievent.args[0]
    except IndexError:
        ievent.missing('<botname>')
        return

    ievent.reply('exiting %s' % botname)

    try:
        if fleet.exit(botname):
            ievent.reply("%s bot stopped" % botname)
        else:
            ievent.reply("can't stop %s bot" % botname)
    except Exception, ex:
        ievent.reply(str(ex))
예제 #8
0
def reboot():
    fleet.exit()
    os.execl(sys.argv[0], *sys.argv)