]> git.aero2k.de Git - urlbot-v3.git/commitdiff
add magic 8ball
authorThorsten <mail@aero2k.de>
Tue, 30 Aug 2022 19:07:02 +0000 (21:07 +0200)
committerThorsten <mail@aero2k.de>
Tue, 30 Aug 2022 19:07:02 +0000 (21:07 +0200)
distbot/plugins/basic.py
distbot/plugins/url.py

index 0c45e6584155c98abea7d608f387f89828d394d0..15a4d00e8cde1dea9f19a899172e43857a4e362a 100644 (file)
@@ -306,6 +306,42 @@ class Choose(Worker):
         return Action(msg='%s: My choices are: %s!' % (sender, ', '.join(choose_between(alternatives))))
 
 
+class Magic8Ball(Worker):
+    binding_keys = ["nick.8ball.#"]
+    description = "answering all your questions"
+    usage = "bot: 8ball <your question>"
+
+    answers = [
+        "A Definite Yes",
+        "I Have My Doubts",
+        "You Will Have To Wait",
+        "Looking Good",
+        "Probably",
+        "Outlook So So",
+        "Don't Bet On It",
+        "Too Early To Predict",
+        "Who Knows",
+        "Absolutely",
+        "Absolutely Not",
+        "Go For It",
+        "You Can Count On It",
+        "Not Now",
+        "Forget About It",
+        "Looks Good To Me",
+        "Have My Doubts",
+        "Are You Kidding",
+        "Yes In Due Time",
+        "My Sources Say No",
+        "Yes",
+    ]
+
+    def parse_body(self, msg):
+        sender = get_nick_from_message(msg)
+
+        choice = random.choice(self.answers)
+        return Action(msg='%s: %s!' % (sender, choice))
+
+
 class TeaTimer(Worker):
     binding_keys = ["nick.teatimer.*", "nick.teatimer"]
     description = 'sets a tea timer to $1 or currently %d seconds' % conf_get('plugins.teatimer.steep_time')
@@ -339,4 +375,4 @@ class TeaTimer(Worker):
         )
 
 
-ALL = [Dice, Dice20, Ping, XChoose, Coin, Choose, TeaTimer]
+ALL = [Dice, Dice20, Ping, XChoose, Coin, Choose, Magic8Ball, TeaTimer]
index 2897ef050b898484ee85d6171081ca7df6ee8999..e421f89da17c6598d2a4f581c6a7b2e9aa87d620 100644 (file)
@@ -105,7 +105,7 @@ class URLResolver(Worker):
             except UnicodeError as e:
                 message = 'Bug triggered (%s), invalid URL/domain part: %s' % (str(e), url)
                 logger.warning(message)
-                return {'msg': message}
+                return Action(msg=message)
 
             if title:
                 title = title.strip()