So i this following code is what i did, but it only replies to existing tweets, i tried to run it in a loop, but it hit api limits very very quick, i could delay the time but i want something more efficient and quick, i've hear about working with stream of tweets, i don't understand how that works i am new to coding, anyawy here is the code that hits api limit very quick
import tweepy
from random import randint
from time import sleep
CONSUMER_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'
CONSUMER_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
ACCESS_TOKEN = 'xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
ACCESS_TOKEN_SECRET = 'xxxxxxxxxxxxxxxxxxxxxxxxxx'
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
num=0
count=0
temp=0
while (count < 100):
firstTweet = api.search("dogs")[0]
if firstTweet.id==temp:
sleep(randint(10,20))
continue
rid=firstTweet.id
rsn=firstTweet.user.screen_name
m="@%s If you love dogs, follow us" % (rsn)
api.update_status(status=m, in_reply_to_status_id=rid)
count=count+1
print(count)
temp = firstTweet.id
basically it searches for tweet about dogs, takes the top most tweet, replies to it, and saved the tweet id in temp so the loop keeps running and if the top tweet is still the same it won't reply once it changes (that is there is a new tweet) it will reply, but this code only runs for 5 mins and then hits limit is there any other way to do it?