import random from edmond.plugin import Plugin from edmond.utils import proc class UnknownQuestionPlugin(Plugin): """Handle unknown questions. Reply with some question marks, but there is a configurable rate to pass processing of the message to the misc_reactions if available. """ REQUIRED_CONFIGS = ["pass_to_misc_rate"] def __init__(self, bot): super().__init__(bot) self.priority = -7 self.misc_plugin = None def on_welcome(self, event): self.misc_plugin = self.bot.get_plugin("miscreactions") def on_pubmsg(self, event): message = self.should_read_message(event.arguments[0]) if message is None: return False if self.misc_plugin and proc(self.config["pass_to_misc_rate"]): self.misc_plugin.react(event) else: self.bot.say(event.target, "?" * random.randint(1, 3)) return True