Refactor Code

Remove newline characters for logging
main
Hammy 4 years ago
parent 1a055bcaac
commit b5e2a9f93c

@ -54,13 +54,10 @@ class Winston:
result = random.choice([True, False]) result = random.choice([True, False])
if result: if result:
random_tweet = random.choice(self.potential_tweets) random_tweet = random.choice(self.potential_tweets)
self.bot.update_status(status=random_tweet) self.send_tweet(random_tweet)
logger.info(f"Random Tweet Sent: '{random_tweet}'")
else: else:
random_tweet_with_image = random.choice(self.potential_tweets_with_images) random_tweet_with_image = random.choice(self.potential_tweets_with_images)
self.tweet_with_media(random_tweet_with_image) self.tweet_with_media(random_tweet_with_image)
logger.info(
f"Random Tweet With Image Sent:\nTweet: '{random_tweet_with_image[0]}'\nImage Filename: '{random_tweet_with_image[1]}'")
def tweet_with_media(self, text_and_media): def tweet_with_media(self, text_and_media):
"""Tweet with media + optional text""" """Tweet with media + optional text"""
@ -74,7 +71,7 @@ class Winston:
try: try:
response = self.bot.upload_media(media=media) response = self.bot.upload_media(media=media)
self.bot.update_status(status=text, media_ids=[response['media_id']]) self.bot.update_status(status=text, media_ids=[response['media_id']])
logger.info(f"Tweet Sent With Image:\nTweet: {text}\nImage Name: {filename}") logger.info(f"Tweet Sent With Image: || Tweet: {text} || Image Name: {filename}")
except TwythonError as error: except TwythonError as error:
print(error.msg) print(error.msg)

Loading…
Cancel
Save