Update handler to receive manual json data

main
Hammy 4 years ago
parent 02fecd5488
commit 404bd95fc2

@ -1,7 +1,6 @@
import logging import logging
import random import random
from bot.commands import send_tweet
from bot.winston import Winston from bot.winston import Winston
logger = logging.getLogger() logger = logging.getLogger()
@ -10,9 +9,17 @@ logger.setLevel(logging.INFO)
def event_handler(event, context): def event_handler(event, context):
"""Sends random tweet from list of potential tweets""" """Sends random tweet from list of potential tweets"""
winston = Winston() winston = Winston()
random_tweet = random.choice(winston.potential_tweets) Actions = {
send_tweet(winston.bot, random_tweet) "tweet": lambda text: winston.send_tweet(text),
"tweet_media": lambda text_and_media: winston.tweet_with_media(text_and_media),
"like": lambda tweet_id: winston.like_tweet(tweet_id),
"follow": lambda username: winston.follow_someone(username)
}
for key, values in event.items():
Actions[key](values)
logger.info(f"Random Tweet Sent: {random_tweet}") winston.send_tweet(random.choice(winston.potential_tweets))

Loading…
Cancel
Save