Ejemplo n.º 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)
Ejemplo n.º 2
0
def handle_fleetdel(bot, ievent):
    """ fleet-del <botname> .. delete bot from fleet. """

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

    try:
        if fleet.delete(name):
            ievent.reply('%s deleted' % name)
        else:
            ievent.reply('%s delete failed' % name)
    except Exception, ex:
        ievent.reply(str(ex))
Ejemplo n.º 3
0
def handle_fleetdel(bot, ievent):

    """ fleet-del <botname> .. delete bot from fleet. """

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

    try:
        if fleet.delete(name):
            ievent.reply('%s deleted' % name)
        else:
            ievent.reply('%s delete failed' % name)
    except Exception, ex:
        ievent.reply(str(ex))
Ejemplo n.º 4
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)
Ejemplo n.º 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)
Ejemplo n.º 6
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)