From: Thorsten Date: Tue, 30 Aug 2022 19:07:02 +0000 (+0200) Subject: add magic 8ball X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=0678c6752595f691b042f5dd5a0314689d0dc283;p=urlbot-v3.git add magic 8ball --- diff --git a/distbot/plugins/basic.py b/distbot/plugins/basic.py index 0c45e65..15a4d00 100644 --- a/distbot/plugins/basic.py +++ b/distbot/plugins/basic.py @@ -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 " + + 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] diff --git a/distbot/plugins/url.py b/distbot/plugins/url.py index 2897ef0..e421f89 100644 --- a/distbot/plugins/url.py +++ b/distbot/plugins/url.py @@ -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()