Refactor Code
parent
3cd17f516c
commit
d47a90b338
@ -1,19 +1,16 @@
|
|||||||
from bot.winston import Winston
|
def send_tweet(bot, tweet_text):
|
||||||
|
|
||||||
|
|
||||||
def send_tweet(tweet_text):
|
|
||||||
"""Sends a tweet to Twitter"""
|
"""Sends a tweet to Twitter"""
|
||||||
|
|
||||||
Winston.bot.update_status(status=tweet_text)
|
bot.update_status(status=tweet_text)
|
||||||
|
|
||||||
|
|
||||||
def follow_someone(username):
|
def follow_someone(bot, username):
|
||||||
"""Follows someone based on given username"""
|
"""Follows someone based on given username"""
|
||||||
|
|
||||||
Winston.bot.create_friendship(username=username)
|
bot.create_friendship(username=username)
|
||||||
|
|
||||||
|
|
||||||
def like_tweet(tweet_id):
|
def like_tweet(bot, tweet_id):
|
||||||
"""Likes a tweet based on it's ID"""
|
"""Likes a tweet based on it's ID"""
|
||||||
|
|
||||||
Winston.bot.create_favorite(id=tweet_id)
|
bot.create_favorite(id=tweet_id)
|
||||||
|
@ -1,6 +1,18 @@
|
|||||||
|
import logging
|
||||||
|
import random
|
||||||
|
|
||||||
|
from bot.commands import send_tweet
|
||||||
from bot.winston import Winston
|
from bot.winston import Winston
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
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.request_handler()
|
winston = Winston()
|
||||||
|
|
||||||
|
random_tweet = random.choice(winston.potential_tweets)
|
||||||
|
send_tweet(winston.bot, random_tweet)
|
||||||
|
|
||||||
|
logger.info(f"Random Tweet Sent: {random_tweet}")
|
||||||
|
Loading…
Reference in New Issue