from edmond.plugin import Plugin from edmond.plugins.kagi_fastgpt import KagiFastgptPlugin class UnknownCommandPlugin(Plugin): def __init__(self, bot): super().__init__(bot) self.priority: int = -6 self.gpt_plugin: KagiFastgptPlugin def on_welcome(self, _): self.gpt_plugin = self.bot.get_plugin("kagifastgpt") if self.gpt_plugin is None or not self.gpt_plugin: self.bot.log_w("GPT plugin is not available.") self.is_ready = False def on_pubmsg(self, event): message = self.should_read_message(event.arguments[0]) if not message: return False words = message.split() if len(words) == 0 or words[-1] != self.config["command_suffix"]: return False query = " ".join(words[:-1]) if not query.endswith("."): query += "." self.gpt_plugin.reply(query, event.target) return True