Ejemplo n.º 1
0
def handle_reload(bot, ievent):
    """ reload <plugin> .. reload a plugin """
    try:
        plugs = ievent.args
    except IndexError:
        ievent.missing('<list plugins>')
        return
    reloaded = []
    errors = []
    for plug in plugs:
        plug = plug.lower()
        if plug == 'config':
            config.reload()
            ievent.reply('config reloaded')
            continue
        p = gozer_import('gozerbot.plugs.__init__')
        if plug in p.__plugs__:
            reloaded.extend(plugins.reload('gozerbot.plugs', plug))
            continue
        try:
            reloaded.extend(plugins.reload('myplugs', plug))
        except ImportError, ex:
            try:
                reloaded.extend(plugins.reload('gozerplugs', plug))
            except ImportError, ex:
                errors.append(str(ex))
Ejemplo n.º 2
0
def handle_reload(bot, ievent):
    """ reload <plugin> .. reload a plugin """
    try:
        plugs = ievent.args
    except IndexError:
        ievent.missing("<list plugins>")
        return
    reloaded = []
    errors = []
    for plug in plugs:
        plug = plug.lower()
        if plug == "config":
            config.reload()
            ievent.reply("config reloaded")
            continue
        p = gozer_import("gozerbot.plugs.__init__")
        if plug in p.__plugs__:
            reloaded.extend(plugins.reload("gozerbot.plugs", plug))
            continue
        try:
            reloaded.extend(plugins.reload("myplugs", plug))
        except ImportError, ex:
            try:
                reloaded.extend(plugins.reload("gozerplugs", plug))
            except ImportError, ex:
                errors.append(str(ex))
Ejemplo n.º 3
0
def handle_cloudenable(bot, ievent):
    """ cloud-enable .. enable the cloud """
    ievent.reply('enabling the cloud')
    cfg.set('enable', 1)
    cfg.save()
    plugins.reload('gozerplugs', 'cloud')
    ievent.reply('done')
Ejemplo n.º 4
0
def handle_plugupgrade(bot, ievent):
    alreadygot = []
    upgraded = []
    plugs = []
    if ievent.rest:
        plugs.extend(ievent.rest.split())
    else:
        for name, plug in plugins.plugs.iteritems():
            if hasattr(plug, 'upgrade'):
                plugs.append(name)
    ievent.reply('starting plugin upgrade for plugins: ', plugs, dot=True)
    errors = []
    for plug in plugs:
        try:
            s = plugins.plugs[plug].size()
        except AttributeError:
            s = 0
        if s and not '-f' in ievent.optionset:
            alreadygot.append(plug)
            continue
        try:
            plugins.plugs[plug].upgrade()
            plugins.reload('gozerplugs', plug)
            ievent.reply('upgraded %s' % plug)
            upgraded.append(plug)
        except AttributeError:
            continue
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
Ejemplo n.º 5
0
def handle_cloudenable(bot, ievent):
    """ cloud-enable .. enable the cloud """
    ievent.reply('enabling the cloud')
    cfg.set('enable', 1)
    cfg.save()
    plugins.reload('gozerplugs', 'cloud')
    ievent.reply('done')
Ejemplo n.º 6
0
def handle_plugupgrade(bot, ievent):
    alreadygot = []
    upgraded = []
    plugs = []
    if ievent.rest:
        plugs.extend(ievent.rest.split())
    else:
        for name, plug in plugins.plugs.iteritems():
            if hasattr(plug, 'upgrade'):
                plugs.append(name)    
    ievent.reply('starting plugin upgrade for plugins: ', plugs, dot=True)
    errors = []
    for plug in plugs:
        try:
            s = plugins.plugs[plug].size()
        except AttributeError:
            s = 0
        if s and not '-f' in ievent.optionset:
            alreadygot.append(plug)
            continue
        try:
            plugins.plugs[plug].upgrade()
            plugins.reload('gozerplugs', plug)
            ievent.reply('upgraded %s' % plug)
            upgraded.append(plug)
        except AttributeError:
            continue
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
Ejemplo n.º 7
0
def handle_markovenable(bot, ievent):
    """ enable markov in a channel .. learn the log of that channel """
    try:
        channel = ievent.args[0]
    except IndexError:
        channel = ievent.channel
    if not enabled(bot.name, channel):
        cfg.get('enable').append(jsonstring([bot.name, channel]))
    else:
        ievent.reply('%s is already enabled' % channel)
        return
    cfg.save()
    markovlearn.data.append(channel)
    markovlearn.save()
    plugins.reload('gozerplugs', 'markov')
    ievent.reply('%s enabled' % channel)
Ejemplo n.º 8
0
def handle_plugenable(bot, ievent):
    doall = False
    if '-a' in ievent.optionset:
        doall = True
    if not ievent.rest and not doall:
        ievent.missing('<plugname>')
        return
    try:
        plugs = gozer_import('gozerplugs').__plugs__
    except ImportError:
        ievent.reply("no gozerplugs package detected")
        return
    if not doall:
        plugs = ievent.rest.split()
    ievent.reply("trying to reload: ", plugs, dot=True)
    errors = []
    reloaded = []
    failed = []
    for plug in plugs:
        try:
            reloaded.extend(plugins.reload('gozerplugs', plug))
        except ImportError, ex:
            errors.append(str(ex))
            failed.append(plug)
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
            failed.append(plug)
Ejemplo n.º 9
0
def handle_markovenable(bot, ievent):
    """ enable markov in a channel .. learn the log of that channel """
    try:
        channel = ievent.args[0]
    except IndexError:
        channel = ievent.channel
    if not enabled(bot.name, channel):
        cfg.get('enable').append(jsonstring([bot.name, channel]))
    else:
        ievent.reply('%s is already enabled' % channel)
        return
    cfg.save()
    markovlearn.data.append(channel)
    markovlearn.save()
    plugins.reload('gozerplugs', 'markov')
    ievent.reply('%s enabled' % channel)
Ejemplo n.º 10
0
def handle_plugenable(bot, ievent):
    doall = False
    if '-a' in ievent.optionset:
        doall = True
    if not ievent.rest and not doall:
        ievent.missing('<plugname>')
        return
    try:
        plugs = gozer_import('gozerplugs').__plugs__
    except ImportError:
        ievent.reply("no gozerplugs package detected")
        return
    if not doall:
        plugs = ievent.rest.split()
    ievent.reply("trying to reload: ", plugs, dot=True)
    errors = []
    reloaded = []
    failed = []
    for plug in plugs:
        try:
            reloaded.extend(plugins.reload('gozerplugs', plug))
        except ImportError, ex:
            errors.append(str(ex))
            failed.append(plug)
        except Exception, ex:
            handle_exception()
            errors.append(exceptionmsg())
            failed.append(plug)
Ejemplo n.º 11
0
def handle_webdisable(bot, ievent):
    """ web-disable .. disable webserver"""
    cfg.set('webenable', 0)
    cfg.save()
    if plugins.reload('gozerplugs', 'webserver'):
        ievent.reply('done')
    else:
        ievent.reply('error reloading webserver plugin')
Ejemplo n.º 12
0
def handle_webdisable(bot, ievent):
    """ web-disable .. disable webserver"""
    cfg.set('webenable', 0)
    cfg.save()
    if plugins.reload('gozerplugs', 'webserver'):
        ievent.reply('done')
    else:
        ievent.reply('error reloading webserver plugin')
Ejemplo n.º 13
0
def handle_markovdisable(bot, ievent):
    """ disable markov in a channel """
    try:
        channel = ievent.args[0]
    except IndexError:
        channel = ievent.channel
    if enabled(bot.name, channel):
        cfg.get('enable').remove(jsonstring([bot.name, channel]))
    else:
        ievent.reply('%s is not enabled' % channel)
        return
    cfg.save()
    try:
        markovlearn.data.remove(channel)
        markovlearn.save()
    except ValueError:
        pass
    plugins.reload('gozerplugs', 'markov')
    ievent.reply('%s disabled' % channel)
Ejemplo n.º 14
0
def handle_markovdisable(bot, ievent):
    """ disable markov in a channel """
    try:
        channel = ievent.args[0]
    except IndexError:
        channel = ievent.channel
    if enabled(bot.name, channel):
        cfg.get('enable').remove(jsonstring([bot.name, channel]))
    else:
        ievent.reply('%s is not enabled' % channel)
        return
    cfg.save()
    try:
        markovlearn.data.remove(channel)
        markovlearn.save()
    except ValueError:
        pass
    plugins.reload('gozerplugs', 'markov')
    ievent.reply('%s disabled' % channel)
Ejemplo n.º 15
0
def handle_webenable(bot, ievent):
    """ web-enable <host> <port> """
    try:
        (host, port) = ievent.args
        port = int(port)
    except ValueError:
        ievent.missing('<host> <port>')
        return
    cfg.set('webenable', 1)
    cfg.set('webhost', host)
    cfg.set('webport', port)
    cfg.save()
    if plugins.reload('gozerplugs', 'webserver'):
        ievent.reply('done')
    else:
        ievent.reply('error reloading webserver plugin')
Ejemplo n.º 16
0
def handle_webenable(bot, ievent):
    """ web-enable <host> <port> """
    try:
        (host, port) = ievent.args
        port = int(port)
    except ValueError:
        ievent.missing('<host> <port>')
        return
    cfg.set('webenable', 1)
    cfg.set('webhost', host)
    cfg.set('webport', port)
    cfg.save()
    if plugins.reload('gozerplugs', 'webserver'):
        ievent.reply('done')
    else:
        ievent.reply('error reloading webserver plugin')
Ejemplo n.º 17
0
            if not response or response.txt != 'yes':
                ievent.reply('not installing %s' % plug)
                return
    except:
        pass
    installer = Installer()
    try:
        installer.install(plug, 'http://%s/%s' % (server, dirr))
    except InstallerException, e:
        ievent.reply('error installing %s: ' % plug, result=[str(x) for x \
in list(e)], dot=True)
        return
    except Exception, ex:
        ievent.reply(str(ex))
        return
    reloaded = plugins.reload('myplugs', plug)
    if reloaded:
        ievent.reply("%s reloaded" % ' .. '.join(reloaded))
    else:
        ievent.reply('reload of %s failed' % plug)


cmnds.add('install', handle_install, 'OPER')
examples.add(
    'install', 'install <server> <dir> <plug>: install \
http://<plugserver>/<dir>/<plugin>.py from server (maybe try install-plug \
?)', 'install gozerbot.org plugs autovoice')


def handle_installplug(bot, ievent):
    """ remotely install a plugin """
Ejemplo n.º 18
0
def handle_clouddisable(bot, ievent):
    """cloud-disable .. disable the gozerbot cloud """
    cfg.set('enable', 0)
    cfg.save()
    plugins.reload('gozerplugs', 'cloud')
    ievent.reply('cloud disabled')
Ejemplo n.º 19
0
def handle_awaydisable(bot, ievent):
    """ away-disable .. disable away """
    awaydict.data['enable'] = 0
    awaydict.save()
    plugins.reload('gozerplugs', 'away')
    ievent.reply('away disabled')
Ejemplo n.º 20
0
def handle_clouddisable(bot, ievent):
    """cloud-disable .. disable the gozerbot cloud """
    cfg.set('enable', 0)
    cfg.save()
    plugins.reload('gozerplugs', 'cloud')
    ievent.reply('cloud disabled')