def handle_plot(tweet): """ Gets name of user who tweeted the COMMAND - Generates word cloud - Sends out tweet @param tweet - The tweet object that tweeted the COMMAND """ twitter = Twitter(tweet['user']['screen_name']) tweets = twitter.get_last_month_tweets_for_user() # Make sure the user tweeted the previous month if len(tweets) == 0: return words = twitter.get_words(tweets) generate_word_cloud(words) user = tweets[0]['user'] month = tweets[0]['created_at'].strftime('%B') tweet_text = f""" @{user} here are the most common words you tweeted for the month of {month}. #visualization #wordcloud #automation #AWS #Lambda #{month} """ twitter.send_tweet(tweet_text, IMG_PATH) os.remove(IMG_PATH)