import random from edmond.plugin import Plugin from edmond.utils import proc class UnknownQuestionPlugin(Plugin): """Handle unknown questions. """ def __init__(self, bot): super().__init__(bot) self.priority = -7 self.misc_plugin = None self.gpt3_plugin = None def on_welcome(self, _): self.misc_plugin = self.bot.get_plugin("miscreactions") self.gpt3_plugin = self.bot.get_plugin("gpt3") def on_pubmsg(self, event): message = self.should_read_message(event.arguments[0]) if message is None: return False if self.gpt3_plugin and message.endswith(self.config["question_mark"]): message += "\n\n" self.gpt3_plugin.reply(message, event.target) else: self.classic_reply(event) return True def classic_reply(self, event): if ( self.misc_plugin and "pass_to_misc_rate" in self.config and proc(self.config["pass_to_misc_rate"]) ): self.misc_plugin.react(event) else: self.bot.say(event.target, "?" * random.randint(1, 3))