Exemple #1
0
def main():
    if not botconfig.DEBUG_MODE:
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)
        fh = logging.FileHandler("errors.log")
        fh.setLevel(logging.WARNING)
        logger.addHandler(fh)
        if botconfig.VERBOSE_MODE:
            hdlr = logging.StreamHandler(sys.stdout)
            hdlr.setLevel(logging.DEBUG)
            logger.addHandler(hdlr)
        formatter = UTCFormatter('[%(asctime)s] %(message)s', '%d/%b/%Y %H:%M:%S')
        for handler in logger.handlers:
            handler.setFormatter(formatter)
    else:
        logging.basicConfig(level=logging.DEBUG)
        formatter = UTCFormatter('[%(asctime)s] %(message)s', '%H:%M:%S')
        for handler in logging.getLogger().handlers:
            handler.setFormatter(formatter)
    
    cli = IRCClient(
                      {"privmsg":modules.common.on_privmsg,
                       "notice":lambda a, b, c, d: modules.common.on_privmsg(a, b, c, d, True),
                       "":modules.common.__unhandled__},
                     host=botconfig.HOST, 
                     port=botconfig.PORT,
                     authname=botconfig.USERNAME,
                     password=botconfig.PASS,
                     nickname=botconfig.NICK,
                     sasl_auth=botconfig.SASL_AUTHENTICATION,
                     use_ssl=botconfig.USE_SSL,
                     connect_cb=modules.common.connect_callback
                    )
    cli.mainLoop()
Exemple #2
0
def main():
    evt = Event("init", {})
    evt.dispatch()
    src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
    cli = IRCClient(
                      {"privmsg": lambda *s: None,
                       "notice": lambda *s: None,
                       "": handler.unhandled},
                     host=botconfig.HOST,
                     port=botconfig.PORT,
                     authname=botconfig.USERNAME,
                     password=botconfig.PASS,
                     nickname=botconfig.NICK,
                     ident=botconfig.IDENT,
                     real_name=botconfig.REALNAME,
                     sasl_auth=botconfig.SASL_AUTHENTICATION,
                     server_pass=botconfig.SERVER_PASS,
                     use_ssl=botconfig.USE_SSL,
                     cert_verify=var.SSL_VERIFY,
                     cert_fp=var.SSL_CERTFP,
                     client_certfile=var.SSL_CERTFILE,
                     client_keyfile=var.SSL_KEYFILE,
                     cipher_list=var.SSL_CIPHERS,
                     tokenbucket=TokenBucket(var.IRC_TB_BURST, var.IRC_TB_DELAY, init=var.IRC_TB_INIT),
                     connect_cb=handler.connect_callback,
                     stream_handler=src.stream,
    )
    cli.mainLoop()
Exemple #3
0
def main():
    evt = Event("init", {})
    evt.dispatch()
    src.plog("Connecting to {0}:{1}{2}".format(
        botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
    cli = IRCClient(
        {
            "privmsg": lambda *s: None,
            "notice": lambda *s: None,
            "": handler.unhandled
        },
        host=botconfig.HOST,
        port=botconfig.PORT,
        authname=botconfig.USERNAME,
        password=botconfig.PASS,
        nickname=botconfig.NICK,
        ident=botconfig.IDENT,
        real_name=botconfig.REALNAME,
        sasl_auth=botconfig.SASL_AUTHENTICATION,
        server_pass=botconfig.SERVER_PASS,
        use_ssl=botconfig.USE_SSL,
        cert_verify=var.SSL_VERIFY,
        cert_fp=var.SSL_CERTFP,
        client_certfile=var.SSL_CERTFILE,
        client_keyfile=var.SSL_KEYFILE,
        cipher_list=var.SSL_CIPHERS,
        tokenbucket=TokenBucket(var.IRC_TB_BURST,
                                var.IRC_TB_DELAY,
                                init=var.IRC_TB_INIT),
        connect_cb=handler.connect_callback,
        stream_handler=src.stream,
    )
    cli.mainLoop()
Exemple #4
0
def main():
    evt = Event("init", {})
    evt.dispatch()
    src.plog("Connecting to {0}:{1}{2}".format(
        botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
    cli = IRCClient(
        {
            "privmsg": lambda *s: None,
            "notice": lambda *s: None,
            "": handler.unhandled
        },
        host=botconfig.HOST,
        port=botconfig.PORT,
        authname=botconfig.USERNAME,
        password=botconfig.PASS,
        nickname=botconfig.NICK,
        ident=botconfig.IDENT,
        real_name=botconfig.REALNAME,
        sasl_auth=botconfig.SASL_AUTHENTICATION,
        server_pass=botconfig.SERVER_PASS,
        use_ssl=botconfig.USE_SSL,
        connect_cb=handler.connect_callback,
        stream_handler=src.stream,
    )
    cli.mainLoop()
Exemple #5
0
def main():
    cli = IRCClient(
                      {"privmsg": handler.on_privmsg,
                       "notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
                       "": handler.unhandled},
                     host=botconfig.HOST,
                     port=botconfig.PORT,
                     authname=botconfig.USERNAME,
                     password=botconfig.PASS,
                     nickname=botconfig.NICK,
                     ident=botconfig.IDENT,
                     real_name=botconfig.REALNAME,
                     sasl_auth=botconfig.SASL_AUTHENTICATION,
                     use_ssl=botconfig.USE_SSL,
                     connect_cb=handler.connect_callback,
                     stream_handler=src.stream,
    )
    cli.mainLoop()
Exemple #6
0
def main():
    src.plog("Connecting to {0}:{1}{2}".format(botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
    cli = IRCClient(
                      {"privmsg": handler.on_privmsg,
                       "notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
                       "": handler.unhandled},
                     host=botconfig.HOST,
                     port=botconfig.PORT,
                     authname=botconfig.USERNAME,
                     password=botconfig.PASS,
                     nickname=botconfig.NICK,
                     ident=botconfig.IDENT,
                     real_name=botconfig.REALNAME,
                     sasl_auth=botconfig.SASL_AUTHENTICATION,
                     server_pass=botconfig.SERVER_PASS,
                     use_ssl=botconfig.USE_SSL,
                     connect_cb=handler.connect_callback,
                     stream_handler=src.stream,
    )
    cli.mainLoop()
Exemple #7
0
def main():
    if not botconfig.DEBUG_MODE:
        logger = logging.getLogger()
        logger.setLevel(logging.DEBUG)
        fh = logging.FileHandler("errors.log")
        fh.setLevel(logging.WARNING)
        logger.addHandler(fh)
        if botconfig.VERBOSE_MODE:
            hdlr = logging.StreamHandler(sys.stdout)
            hdlr.setLevel(logging.DEBUG)
            logger.addHandler(hdlr)
        formatter = UTCFormatter('[%(asctime)s] %(message)s',
                                 '%d/%b/%Y %H:%M:%S')
        for handler in logger.handlers:
            handler.setFormatter(formatter)
    else:
        logging.basicConfig(level=logging.DEBUG)
        formatter = UTCFormatter('[%(asctime)s] %(message)s', '%H:%M:%S')
        for handler in logging.getLogger().handlers:
            handler.setFormatter(formatter)

    cli = IRCClient(
        {
            "privmsg":
            modules.common.on_privmsg,
            "notice":
            lambda a, b, c, d: modules.common.on_privmsg(a, b, c, d, True),
            "":
            modules.common.__unhandled__
        },
        host=botconfig.HOST,
        port=botconfig.PORT,
        authname=botconfig.USERNAME,
        password=botconfig.PASS,
        nickname=botconfig.NICK,
        sasl_auth=botconfig.SASL_AUTHENTICATION,
        use_ssl=botconfig.USE_SSL,
        connect_cb=modules.common.connect_callback)
    cli.mainLoop()
Exemple #8
0
def main():
    src.logger(None)("Connecting to {0}:{1}{2}".format(
        botconfig.HOST, "+" if botconfig.USE_SSL else "", botconfig.PORT))
    cli = IRCClient(
        {
            "privmsg": handler.on_privmsg,
            "notice": lambda a, b, c, d: handler.on_privmsg(a, b, c, d, True),
            "": handler.unhandled
        },
        host=botconfig.HOST,
        port=botconfig.PORT,
        authname=botconfig.USERNAME,
        password=botconfig.PASS,
        nickname=botconfig.NICK,
        ident=botconfig.IDENT,
        real_name=botconfig.REALNAME,
        sasl_auth=botconfig.SASL_AUTHENTICATION,
        server_pass=botconfig.SERVER_PASS,
        use_ssl=botconfig.USE_SSL,
        connect_cb=handler.connect_callback,
        stream_handler=src.stream,
    )
    cli.mainLoop()