Edm0nd/edmond/plugins/unknown_question.py

33 lines
929 B
Python
Raw Normal View History

2020-11-05 23:52:20 +01:00
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)
2021-06-06 18:28:43 +02:00
self.priority = -7
2020-11-05 23:52:20 +01:00
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)
2020-11-05 23:52:20 +01:00
else:
self.bot.say(event.target, "?" * random.randint(1, 3))
return True