I'm currently trying to make a twitter bot that is supposed to reply to one tweet, which it filters using regex, and reply to it. The relevant code looks as follows:
questionRegex = re.compile(regex here)
def searchWeatherRequest(weatherReport) :
for tweet in tweepy.Cursor(api.search,
q=questionRegex,
lang="en",
since=today).items(1):
try:
tweetId = tweet.user.id
username = tweet.user.screen_name
print ('\Tweet by: @' + username)
tweet.retweet()
api.update_status("@" + username + "Today's weather" + weatherReport)
print (tweet.text)
except tweepy.TweepError as e:
print (e.reason)
except StopIteration:
break
time.sleep(3600)
But whenever I run the code, I receive the message "no tweets found" (even after posting a tweet that would match the regex, so I know that it's not just because there are simply no tweets that would match it). I also tried filtering the tweets in steps (first, I filter tweets using just one word, and then I filter those tweets using regex) but this did not work either. Does anyone know what I'm doing wrong. I read multiple articles and questions about this but none of the solutions seemed to work. I read one question you couldn't filter tweets using regex but other answers suggested otherwise. Is it true that you simply can't use regex, or am I encountering a simple coding error?