Esempio n. 1
0
    def handle_message(self, message: Dict[str, str],
                       bot_handler: BotHandler) -> None:
        content = message["content"]

        response = parse.execute(content, self.api_key)

        bot_handler.send_reply(message, response)
Esempio n. 2
0
    def handle_message(self, message: Dict[str, str],
                       bot_handler: Any) -> None:
        content = message['content']

        response = parse.execute(content, self.api_key)

        bot_handler.send_reply(message, response)
Esempio n. 3
0
    def initialize(self, bot_handler: BotHandler) -> None:
        try:
            self.config = bot_handler.get_config_info("monkeytestit")
        except NoBotConfigException:
            bot_handler.quit("Quitting because there's no config file "
                             "supplied. See doc.md for a guide on setting up "
                             "one. If you already know the drill, just create "
                             'a .conf file with "monkeytestit" as the '
                             "section header and api_key = <your key> for "
                             "the api key.")

        self.api_key = self.config.get("api_key")

        if not self.api_key:
            bot_handler.quit("Config file exists, but can't find api_key key "
                             "or value. Perhaps it is misconfigured. Check "
                             "doc.md for details on how to setup the config.")

        logging.info("Checking validity of API key. This will take a while.")

        if "wrong secret" in parse.execute("check https://website",
                                           self.api_key).lower():
            bot_handler.quit("API key exists, but it is not valid. Reconfigure"
                             " your api_key value and try again.")
Esempio n. 4
0
    def initialize(self, bot_handler: Any) -> None:
        try:
            self.config = bot_handler.get_config_info('monkeytestit')
        except NoBotConfigException:
            bot_handler.quit("Quitting because there's no config file "
                             "supplied. See doc.md for a guide on setting up "
                             "one. If you already know the drill, just create "
                             "a .conf file with \"monkeytestit\" as the "
                             "section header and api_key = <your key> for "
                             "the api key.")

        self.api_key = self.config.get('api_key')

        if not self.api_key:
            bot_handler.quit("Config file exists, but can't find api_key key "
                             "or value. Perhaps it is misconfigured. Check "
                             "doc.md for details on how to setup the config.")

        logging.info("Checking validity of API key. This will take a while.")

        if "wrong secret" in parse.execute("check https://website",
                                           self.api_key).lower():
            bot_handler.quit("API key exists, but it is not valid. Reconfigure"
                             " your api_key value and try again.")