]> git.aero2k.de Git - urlbot-v3.git/commitdiff
coin
authorThorsten <mail@aero2k.de>
Tue, 21 Jan 2020 17:53:51 +0000 (18:53 +0100)
committerThorsten S <mail@aero2k.de>
Tue, 21 Jan 2020 17:54:41 +0000 (18:54 +0100)
distbot/plugins/basic.py

index 6af2892fbf6510ce60403acc380722138c1a0ee6..17603afc1910b9382bf9f532e5c4374770a2bbc2 100644 (file)
@@ -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",