From: Thorsten Date: Tue, 21 Jan 2020 17:53:51 +0000 (+0100) Subject: coin X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=773ce9b7b35ebea06eea069130137cdb7d4924b7;p=urlbot-v3.git coin --- 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",