From 773ce9b7b35ebea06eea069130137cdb7d4924b7 Mon Sep 17 00:00:00 2001 From: Thorsten Date: Tue, 21 Jan 2020 18:53:51 +0100 Subject: [PATCH] coin --- distbot/plugins/basic.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/distbot/plugins/basic.py b/distbot/plugins/basic.py index 6af2892..17603af 100644 --- a/distbot/plugins/basic.py +++ b/distbot/plugins/basic.py @@ -183,6 +183,24 @@ class XChoose(Worker): return Action(msg='%s: %s' % (sender, str(e))) +class Coin(Worker): + binding_keys = [ + "nick.#.coin.#", + "nick.#.münze.#" + ] + description = "flip a coin" + usage = "bot: [...] (coin|münze) [...]" + + def parse_body(self, msg): + sender = get_nick_from_message(msg) + if "coin" in msg: + localized_responses = ["head", "tails"] + else: + localized_responses = ["kopf", "zahl"] + result = random.choice(localized_responses) + return Action(msg="{}: {}".format(sender, result)) + + class Choose(Worker): binding_keys = [ "nick.choose.#", "nick.choose", -- 2.39.2