From c16910706e42ad6926a3403599cc887cda257798 Mon Sep 17 00:00:00 2001 From: Hammy Date: Fri, 12 Feb 2021 19:08:12 +0000 Subject: [PATCH] Implement separate function to send random tweet --- bot/handler.py | 3 +-- bot/winston.py | 9 ++++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bot/handler.py b/bot/handler.py index 0e968fd..429b904 100644 --- a/bot/handler.py +++ b/bot/handler.py @@ -1,5 +1,4 @@ import logging -import random from bot.winston import Winston @@ -22,4 +21,4 @@ def event_handler(event, context): for key, values in event.items(): Actions[key](values) - winston.send_tweet(random.choice(winston.potential_tweets)) + winston.send_random_tweet() diff --git a/bot/winston.py b/bot/winston.py index 841eae2..876e459 100644 --- a/bot/winston.py +++ b/bot/winston.py @@ -1,3 +1,5 @@ +import random + import filetype as filetype from twython import Twython @@ -16,7 +18,7 @@ class Winston: "I didn't pay my taxes!", "I'm wanted in over 60 countries! I'm still on the run :D", "Overwatch", - + ] def send_tweet(self, tweet_text): @@ -24,6 +26,11 @@ class Winston: self.bot.update_status(status=tweet_text) + def send_random_tweet(self): + """Tweet something random from potential tweets""" + + self.bot.update_status(status=random.choice(self.potential_tweets)) + def tweet_with_media(self, text_and_media): """Tweet with media + optional text"""