beers: add plugin

This commit is contained in:
dece 2020-10-09 18:57:08 +02:00
parent 61703b484a
commit 985ac401b4
3 changed files with 28 additions and 1 deletions

View file

@ -9,7 +9,7 @@ Missing features
---------------- ----------------
- [x] Actions (/me) - [x] Actions (/me)
- [ ] Beers - [x] Beers
- [x] Mood - [x] Mood
- [ ] Random: dice, choice, etc - [ ] Random: dice, choice, etc
- [ ] Notes - [ ] Notes

View file

@ -7,6 +7,11 @@
"speak_delay": 0.5, "speak_delay": 0.5,
"resources_dir": "resources", "resources_dir": "resources",
"plugins": { "plugins": {
"beers": {
"commands": ["beer"],
"beers": ["Paix-Dieu"],
"opening_text": "/me cracks open a {beer} for {target}"
},
"common": { "common": {
"command_suffix": "please" "command_suffix": "please"
}, },

22
edmond/plugins/beers.py Normal file
View file

@ -0,0 +1,22 @@
import random
from edmond.plugin import Plugin
class BeersPlugin(Plugin):
REQUIRED_CONFIGS = ["commands", "beers", "opening_text"]
def __init__(self, bot):
super().__init__(bot)
def on_pubmsg(self, event):
if not self.should_handle_command(event.arguments[0]):
return False
beer = random.choice(self.config["beers"])
opening_text = self.config["opening_text"].format(
beer=beer,
target=event.source.nick
)
self.bot.say(event.target, opening_text)
return True