Exemple #1
0
    def __init__(self, bot_config):
        self.bot_config = bot_config

        setup_logging(loglevel="INFO", console_loglevel="DEBUG",
                      log_path_format="logs/botlogs/%Y/%m/%Y-%m-%d.log")

        self.log = logging.getLogger("bot")

        conninfo = self.bot_config["Connection Info"]
        self.networking = Networking(conninfo["host"], conninfo["port"],
                                     timeout=conninfo["timeout"],
                                     floodcontrol_mode="msg_count",

                                     floodcontrol_config={"burst_count_per_10_seconds": 5,
                                                          "base_delay": 0.5,
                                                          "max_delay": 2})

        msginfo = self.bot_config["Bot Options"]["Message Sending"]
        self.networking.set_wait_coefficient(base_delay=msginfo["minimum delay"],
                                             messages_per_minute=msginfo["messages per minute"],
                                             burst=msginfo["burst"])

        self.message_handler = MessageHandler()

        self.user_messages = UserMessages(self)
        self.server_info = ServerInformation(self)
        self.channel_manager = ChannelManager(self)

        self.tools = Tools()

        self.log.info("All modules configured and set up. Bot is ready to go.")

        self._shutdown = False