From 985ac401b46908b4b949b035304201bd0a4bce2b Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 9 Oct 2020 18:57:08 +0200 Subject: [PATCH] beers: add plugin --- README.md | 2 +- config.json.example | 5 +++++ edmond/plugins/beers.py | 22 ++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 edmond/plugins/beers.py diff --git a/README.md b/README.md index ffcf71c..8864907 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Missing features ---------------- - [x] Actions (/me) -- [ ] Beers +- [x] Beers - [x] Mood - [ ] Random: dice, choice, etc - [ ] Notes diff --git a/config.json.example b/config.json.example index a8bd9e7..d7385c0 100644 --- a/config.json.example +++ b/config.json.example @@ -7,6 +7,11 @@ "speak_delay": 0.5, "resources_dir": "resources", "plugins": { + "beers": { + "commands": ["beer"], + "beers": ["Paix-Dieu"], + "opening_text": "/me cracks open a {beer} for {target}" + }, "common": { "command_suffix": "please" }, diff --git a/edmond/plugins/beers.py b/edmond/plugins/beers.py new file mode 100644 index 0000000..0a8ddaf --- /dev/null +++ b/edmond/plugins/beers.py @@ -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