<commit_before>import tweepy
import time
from credentials import *
import urllib

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
print("Bot started.")


for tweet in tweepy.Cursor(api.search, q='@ratemyplate_').items():
    try:
        username = tweet.user.screen_name
        text = tweet.text

        location = tweet.user.location
        api.update_status('@' + username + ' here is your meal: ' + urllib.parse.quote_plus(str(tweet.id)), in_reply_to_status_id=tweet.id)
        print("Tweet received from ", username, text )
    except tweepy.TweepError as e:
        print(e.reason)

    except StopIteration:
        break


print("Bot finished.")<commit_msg>twitter bot url<commit_after>import tweepy
import time
from credentials import *
import urllib
from pyshorteners import Shortener

auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
print("Bot started.")

shortener = Shortener("Tinyurl")
recent_id = 0
image = False
url = 'http://172.16.58.3:3000/meals?{}={}'
reply = '@{} here is the environmental impact of your meal: '

while True:
	for tweet in tweepy.Cursor(api.search, q='@ratemyplate_', include_entities=True).items():
		
		if(tweet.id>recent_id):

			try:

				username = tweet.user.screen_name
				formatted_reply = reply.format(username)
				if 'media' in tweet.entities:
					image = True
					image = tweet.entities['media'][0]
					media = image['media_url']
					formatted_reply += shortener.short(url.format('image', media))

				else:
				
					text = tweet.text[14:].replace(" ", "+")
					location = tweet.user.location
					formatted_reply += shortener.short(url.format('recipe', text))

					
				print(formatted_reply)

					# urllib.request.urlopen('http://172.16.58.3:3000/meals?recipe=' + text).read()
					# api.update_status('@' + username + ' here is your meal: ' + urllib.parse.quote_plus(str(tweet.id)), in_reply_to_status_id=tweet.id)
				api.update_status(formatted_reply, in_reply_to_status_id=tweet.id)
				print("Tweet received from ", username)

			except tweepy.TweepError as e:
				print(e.reason)

			except StopIteration:
				break

		recent_id = tweet.id
		print("Bot finished.")

	time.sleep(30)
{'fraction_non_alphanumeric': 0.1269296740994854, 'fraction_numerical': 0.012864493996569469, 'mean_word_length': 3.974413646055437, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3546041', 'n_tokens_mistral': 906, 'n_tokens_neox': 780, 'n_words': 158}