unknown_question: add plugin

master
dece 4 years ago
parent 250d05e2f7
commit ce26eda989

@ -50,9 +50,9 @@ Missing features
- [x] appreciation
- [x] detector
- [x] "???"
- [ ] Simple word mappings for fun
- ~~[ ] Simple word mappings for fun~~
- ~~[ ] Lyrics~~
- [ ] Phonétique
- [x] Greet other people joining
- [x] Mourn other people parting
- [ ] unknown questions
- [x] unknown questions

@ -119,6 +119,9 @@
"param_source": "from",
"param_dest": "to"
},
"unknownquestion": {
"pass_to_misc_rate": 50
},
"wikipedia": {
"commands": ["science", "define"],
"lang": "en",

@ -32,6 +32,8 @@ class Plugin:
For now these levels are used:
- 0: default
- -3: low, misc parsing of messages, answer to various messages
- -8: handling of unknown commands
- -9: handling of unknown questions
- -10: lowest, e.g. for random reactions usually with a very low rate
"""

@ -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…
Cancel
Save