Exemple #1
0
def launch(channel,
           credentials="./credentials.json",
           persistence="./persistence.pickle",
           *modules):
    """Starts a TwitchTV irc moderator bot in channel

    channel: the channel to join

    credentials: where to look for a ["login", "password"] file

    persistence: where to keep persistent data

    modules: hooks to load"""
    import sys
    from twisted.python import log
    log.startLogging(sys.stdout)
    from twisted.internet import reactor
    from pyhqbot.irc import BotFactory
    from pyhqbot.loader import load
    for module in modules:
        try:
            load(module)
        except ImportError as e:
            print "Error loading \"{0}\": {1}".format(module, e)
        except Exception as e:
            import sys
            sys.excepthook(*sys.exc_info())
            print "Error in module \"{0}\"".format(module)
        else:
            continue
        return
    user, password = get_credentials(credentials)
    storage = get_storage(persistence)
    factory = BotFactory(channel, user, password, storage)
    reactor.connectTCP(factory.host, factory.port, factory)
    reactor.run()
Exemple #2
0
def launch(channel, credentials="./credentials.json", persistence="./persistence.pickle", *modules):
    """Starts a TwitchTV irc moderator bot in channel

    channel: the channel to join

    credentials: where to look for a ["login", "password"] file

    persistence: where to keep persistent data

    modules: hooks to load"""
    import sys
    from twisted.python import log

    log.startLogging(sys.stdout)
    from twisted.internet import reactor
    from pyhqbot.irc import BotFactory
    from pyhqbot.loader import load

    for module in modules:
        try:
            load(module)
        except ImportError as e:
            print 'Error loading "{0}": {1}'.format(module, e)
        except Exception as e:
            import sys

            sys.excepthook(*sys.exc_info())
            print 'Error in module "{0}"'.format(module)
        else:
            continue
        return
    user, password = get_credentials(credentials)
    storage = get_storage(persistence)
    factory = BotFactory(channel, user, password, storage)
    reactor.connectTCP(factory.host, factory.port, factory)
    reactor.run()
Exemple #3
0
def get_credentials(file):
    from json import load
    return load(open(file))
Exemple #4
0
def get_credentials(file):
    from json import load

    return load(open(file))