parent
250d05e2f7
commit
ce26eda989
@ -0,0 +1,32 @@
|
||||
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 = -9
|
||||
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"]):
|
||||
return self.misc_plugin.on_pubmsg(event)
|
||||
else:
|
||||
self.bot.say(event.target, "?" * random.randint(1, 3))
|
||||
return True
|
Loading…
Reference in new issue