ignore retweet and retrieve entire tweet

This commit is contained in:
Mylloon 2021-08-04 20:24:22 +02:00
parent e9937d1bb3
commit 79caf5b097

View file

@ -33,9 +33,14 @@ class Listener(StreamListener):
"""Answer to tweets."""
if status._json["user"]["id"] in self.listOfFriendsID: # verification of the author of the tweet
if seniority(status._json["created_at"]): # verification of the age of the tweet
if not hasattr(status, "retweeted_status"): # ignore Retweet
try: # retrieve the entire tweet
tweet = status.extended_tweet["full_text"]
except AttributeError:
tweet = status.text
# recovery of the last "usable" word of the tweet
regex = r"https?:\/\/\S+| +?\?|\?| +?\!| ?\!|-|~|(?<=ui)i+|@\S+|\.+|(?<=na)a+(?<!n)|(?<=quoi)i+|(?<=no)o+(?<!n)|…"
tweetText = sub(regex, "", status._json["text"].lower())
tweetText = sub(regex, "", tweet.lower())
lastWord = tweetText.split()[-1:][0]
print(f"Tweet trouvé de {status._json['user']['screen_name']} (dernier mot : \"{lastWord}\")...", end = " ")
if lastWord in universalBase: # check if the last word found is a supported word