unknown_question: add plugin
This commit is contained in:
parent
250d05e2f7
commit
ce26eda989
|
@ -50,9 +50,9 @@ Missing features
|
||||||
- [x] appreciation
|
- [x] appreciation
|
||||||
- [x] detector
|
- [x] detector
|
||||||
- [x] "???"
|
- [x] "???"
|
||||||
- [ ] Simple word mappings for fun
|
- ~~[ ] Simple word mappings for fun~~
|
||||||
- ~~[ ] Lyrics~~
|
- ~~[ ] Lyrics~~
|
||||||
- [ ] Phonétique
|
- [ ] Phonétique
|
||||||
- [x] Greet other people joining
|
- [x] Greet other people joining
|
||||||
- [x] Mourn other people parting
|
- [x] Mourn other people parting
|
||||||
- [ ] unknown questions
|
- [x] unknown questions
|
||||||
|
|
|
@ -119,6 +119,9 @@
|
||||||
"param_source": "from",
|
"param_source": "from",
|
||||||
"param_dest": "to"
|
"param_dest": "to"
|
||||||
},
|
},
|
||||||
|
"unknownquestion": {
|
||||||
|
"pass_to_misc_rate": 50
|
||||||
|
},
|
||||||
"wikipedia": {
|
"wikipedia": {
|
||||||
"commands": ["science", "define"],
|
"commands": ["science", "define"],
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
|
|
|
@ -32,6 +32,8 @@ class Plugin:
|
||||||
For now these levels are used:
|
For now these levels are used:
|
||||||
- 0: default
|
- 0: default
|
||||||
- -3: low, misc parsing of messages, answer to various messages
|
- -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
|
- -10: lowest, e.g. for random reactions usually with a very low rate
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
32
edmond/plugins/unknown_question.py
Normal file
32
edmond/plugins/unknown_question.py
Normal file
|
@ -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 a new issue