Beispiel #1
0
def handle_fleetaddjabber(bot, ievent):
    """ fleed-addjabber <name> <host> <user> <password> [port] .. add jabber 
        bot to fleet.
    """
    try:
        import xmpp
    except ImportError:
        ievent.reply('xmpp is not enabled .. install the xmpppy package')
        return

    from gozerbot.jabber.jabberbot import Jabberbot

    if not bot.type == 'jabber':
        ievent.reply('use this command on a jabber bot (and change \
password if you used it)')
        return

    if ievent.groupchat:
        ievent.reply('use this command in a private message (and change \
password if you used it)')
        return

    length = len(ievent.args)

    if length == 5:
        (name, host, user, password, port) = ievent.args
    elif length == 4:
        (name, host, user, password) = ievent.args
        port = 5222
    else:
        ievent.missing('<name> <host> <user> <password> [<port>]')
        return

    if fleet.byname(name):
        ievent.reply('we already have a bot with %s name in fleet' % \
name)
        return

    if '--port' in ievent.optionset:
        port = ievent.options['--port']

    cfg = Config(datadir + os.sep + 'fleet' + os.sep + name, 'config')
    cfg['name'] = name
    cfg['type'] = 'jabber'
    cfg['host'] = host
    cfg['user'] = user
    cfg['password'] = password
    cfg['port'] = port
    cfg.save()
    b = fleet.makebot(name, cfg)

    try:
        ievent.reply('added %s bot' % name)
        fleet.addbot(b)
        ievent.reply('connecting to %s' % server)
        fleet.connect(name)
        ievent.reply('%s started' % name)
    except Exception, ex:
        ievent.reply(str(ex))
        fleet.delete(b)
    def __init__(self):
        self.hide = []
        self.plugname = calledfrom(sys._getframe())
        Config.__init__(self, datadir + os.sep + 'plugs' + os.sep + self.plugname, "config")

        if self.plugname not in config['loadlist']:
             return

        cmndname = "%s-cfg" % self.plugname
        rlog(-3, 'persistconfig', 'added command %s (%s)' % (cmndname, \
self.plugname))
        cmnds[cmndname] = Command(self.cmnd_cfg, 'OPER', self.plugname, \
threaded=True)	
        examples.add(cmndname, "plugin configuration", cmndname)
        cmndnamesave = cmndname + "save"
        cmnds[cmndnamesave] = Command(self.cmnd_cfgsave, 'OPER', \
self.plugname, threaded=True)	
        examples.add(cmndnamesave, "save plugin configuration", cmndnamesave)
Beispiel #3
0
    def __init__(self):
        self.hide = []
        self.plugname = calledfrom(sys._getframe())
        Config.__init__(self,
                        datadir + os.sep + 'plugs' + os.sep + self.plugname,
                        "config")

        if self.plugname not in config['loadlist']:
            return

        cmndname = "%s-cfg" % self.plugname
        rlog(-3, 'persistconfig', 'added command %s (%s)' % (cmndname, \
self.plugname))
        cmnds[cmndname] = Command(self.cmnd_cfg, 'OPER', self.plugname, \
threaded=True)
        examples.add(cmndname, "plugin configuration", cmndname)
        cmndnamesave = cmndname + "save"
        cmnds[cmndnamesave] = Command(self.cmnd_cfgsave, 'OPER', \
self.plugname, threaded=True)
        examples.add(cmndnamesave, "save plugin configuration", cmndnamesave)
Beispiel #4
0
from gozerbot.fleet import fleet
from gozerbot.redispatcher import rebefore, reafter
from gozerbot.database.alchemy import startmaindb
import os
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
import re
import time
donot = ['quit', 'reboot', 'jump']
config.load()
oldlevel = config['loglevel']
config['loglevel'] = 1000
enable_logging()
startmaindb()
cfg = Config()
bot = Bot(cfg)
bot.channels.setdefault('#test', {})
bot.channels.setdefault('#dunkbots', {})
bot.userhosts['dunker'] = '*****@*****.**'
bot.userhosts['test'] = 'test@test'
bot.server = 'localhost'
bot.port = 6667
fleet.addbot(bot)
plugins.regplugins()
time.sleep(5)

try:
    users.add('test', [
        'test@test',
    ], ['OPER', 'USER', 'QUOTE', 'MAIL'])
Beispiel #5
0
def handle_fleetaddirc(bot, ievent):
    """ fleed-addirc <name> <nick> <server> [port] [passwd] [ipv6] .. add irc \
        bot to fleet.
    """

    from gozerbot.irc.bot import Bot
    length = len(ievent.args)

    if length == 7:
        (name, nick, server, ipv6, ssl, port, password) = ievent.args
    elif length == 6:
        (name, nick, server, ipv6, ssl, port) = ievent.args
        password = ""
    elif length == 5:
        (name, nick, server, ipv6, ssl) = ievent.args
        password = ""
        if ssl:
            port = 6697
        else:
            port = 6667
    elif length == 4:
        (name, nick, server, ipv6) = ievent.args
        password = ""
        ssl = 0
        port = 6667
    elif length == 3:
        (name, nick, server) = ievent.args
        port = 6667
        password = ""
        ssl = 0
        ipv6 = 0
    else:
        ievent.missing('<name> <nick> <server> [<ipv6>] [<ssl>] [<port>] \
[<password>]')
        return

    if fleet.byname(name):
        ievent.reply('we already have a bot with %s name in fleet' % \
name)
        return

    if '--port' in ievent.optionset:
        port = ievent.options['--port']

    cfg = Config(datadir + os.sep + 'fleet' + os.sep + name, 'config', \
fleetbotconfigtxt)
    cfg['name'] = name
    cfg['nick'] = nick
    cfg['server'] = server
    cfg['port'] = port
    cfg['password'] = password
    cfg['ipv6'] = ipv6
    cfg['ssl'] = ssl
    cfg.save()
    b = fleet.makebot(name, cfg)

    try:
        ievent.reply('adding bot: %s' % str(b))
        fleet.addbot(b)
        ievent.reply('connecting to %s' % server)
        fleet.connect(name)
        ievent.reply('%s started' % name)
    except Exception, ex:
        ievent.reply(str(ex))
        fleet.delete(b)
Beispiel #6
0
def handle_fleetaddirc(bot, ievent):

    """ fleed-addirc <name> <nick> <server> [port] [passwd] [ipv6] .. add irc \
        bot to fleet.
    """

    from gozerbot.irc.bot import Bot
    length  = len(ievent.args)

    if length == 7:
        (name, nick, server, ipv6, ssl, port, password) = ievent.args
    elif length == 6:
        (name, nick, server, ipv6, ssl, port) = ievent.args
        password = ""
    elif length == 5:
        (name, nick, server, ipv6, ssl) = ievent.args
        password = ""
        if ssl:
           port = 6697
        else:
           port = 6667
    elif length == 4:
        (name, nick, server, ipv6) = ievent.args
        password = ""
        ssl = 0
        port = 6667
    elif length == 3:
        (name, nick, server) = ievent.args
        port = 6667
        password = ""
        ssl = 0
        ipv6 = 0
    else:
        ievent.missing('<name> <nick> <server> [<ipv6>] [<ssl>] [<port>] \
[<password>]')
        return

    if fleet.byname(name):
        ievent.reply('we already have a bot with %s name in fleet' % \
name)
        return

    if '--port' in ievent.optionset:
        port = ievent.options['--port']

    cfg = Config(datadir + os.sep + 'fleet' + os.sep + name, 'config', \
fleetbotconfigtxt)
    cfg['name'] = name
    cfg['nick'] = nick
    cfg['server'] = server
    cfg['port'] = port
    cfg['password'] = password
    cfg['ipv6'] = ipv6
    cfg['ssl'] = ssl
    cfg.save()
    b = fleet.makebot(name, cfg)

    try:
        ievent.reply('adding bot: %s' % str(b))
        fleet.addbot(b)
        ievent.reply('connecting to %s' % server)
        fleet.connect(name)
        ievent.reply('%s started' % name)
    except Exception, ex:
        ievent.reply(str(ex))
        fleet.delete(b)
Beispiel #7
0
def handle_fleetaddjabber(bot, ievent):

    """ fleed-addjabber <name> <host> <user> <password> [port] .. add jabber 
        bot to fleet.
    """
    try:
        import xmpp
    except ImportError:
        ievent.reply('xmpp is not enabled .. install the xmpppy package')
        return

    from gozerbot.jabber.jabberbot import Jabberbot

    if not bot.type == 'jabber':
        ievent.reply('use this command on a jabber bot (and change \
password if you used it)')
        return

    if ievent.groupchat:
        ievent.reply('use this command in a private message (and change \
password if you used it)')
        return

    length  = len(ievent.args)

    if length == 5:
        (name, host, user, password, port) = ievent.args
    elif length == 4:
        (name, host, user, password) = ievent.args
        port = 5222
    else:
        ievent.missing('<name> <host> <user> <password> [<port>]')
        return

    if fleet.byname(name):
        ievent.reply('we already have a bot with %s name in fleet' % \
name)
        return

    if '--port' in ievent.optionset:
        port = ievent.options['--port']

    cfg = Config(datadir + os.sep + 'fleet' + os.sep + name, 'config')
    cfg['name'] = name
    cfg['type'] = 'jabber'
    cfg['host'] = host
    cfg['user'] = user
    cfg['password'] = password
    cfg['port'] = port
    cfg.save()
    b = fleet.makebot(name, cfg)

    try:
        ievent.reply('added %s bot' % name)
        fleet.addbot(b)
        ievent.reply('connecting to %s' % server)
        fleet.connect(name)
        ievent.reply('%s started' % name)
    except Exception, ex:
        ievent.reply(str(ex))
        fleet.delete(b)