def reply_with_image(status_id, program_text, user_name): tagged_user_name = '@' + user_name error_status = tagged_user_name + " Sorry, I could't read that. Try again!" try: image_file = run_turtle_program(program_text) reply_tweet = api.update_with_media(status=tagged_user_name, in_reply_to_status_id=status_id, filename=image_file) except arpeggio.NoMatch: reply_tweet = api.update_status(status=error_status, in_reply_to_status_id=status_id) return reply_tweet
(get_tweets(user_name)) the_tweet_that_I_want = listOfTweets[0]['Tweet'] the_tweet_that_I_want_ID = listOfTweets[0]['Tweet ID'] def manipulate_tweet(tweet_text): result = "" for i in range(len(tweet_text)): if not tweet_text[i].isalpha(): result += tweet_text[i] continue if i % 2 == 0: result += tweet_text[i].lower() else: result += tweet_text[i].upper() return result URL = "https://twitter.com/" + str(user_name) + "/status/" + str(the_tweet_that_I_want_ID) message = str(user_name) + " " + str(manipulate_tweet(the_tweet_that_I_want)) + "\n" + URL if len(message) > 280: message = str(user_name) + " " + str(manipulate_tweet(the_tweet_that_I_want)) print('posting this clever message to twitter:') print(message) api.update_status(message) print('success!')
import datetime from authentication import api import requests #message = "The time is {}. Do you know where your twitter bot is?".format( # datetime.datetime.now().strftime('%-I:%m %p')) #print('posting this clever message to twitter:') #print(message) #api.update_status(message) word = input("What word would you like to rhythm with?") response = requests.get( "https://rhymebrain.com/talk?function=getRhymes&word=" + word) rhymes = response.json() tweet = "" counter = 0 for rhyme in rhymes: if counter <= 5: tweet += rhyme["word"] + " " counter += 1 print(tweet) api.update_status(tweet) print('success!')
from authentication import api import requests string = input("Insert the sentence to rhyme: ") sentence = string.split() new_sentence_tweet = '' for word in sentence: response = requests.get("https://rhymebrain.com/talk?function=getRhymes&word="+word) new_word = response.json() counter = 0 for w in new_word: if counter < 1: new_sentence_tweet += w["word"]+ " " counter += 1 print(new_sentence_tweet) api.update_status(new_sentence_tweet) print('success!')