ignore retweet and retrieve entire tweet
This commit is contained in:
parent
e9937d1bb3
commit
79caf5b097
1 changed files with 25 additions and 20 deletions
7
main.py
7
main.py
|
@ -33,9 +33,14 @@ class Listener(StreamListener):
|
||||||
"""Answer to tweets."""
|
"""Answer to tweets."""
|
||||||
if status._json["user"]["id"] in self.listOfFriendsID: # verification of the author of the tweet
|
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 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
|
# recovery of the last "usable" word of the tweet
|
||||||
regex = r"https?:\/\/\S+| +?\?|\?| +?\!| ?\!|-|~|(?<=ui)i+|@\S+|\.+|(?<=na)a+(?<!n)|(?<=quoi)i+|(?<=no)o+(?<!n)|…"
|
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]
|
lastWord = tweetText.split()[-1:][0]
|
||||||
print(f"Tweet trouvé de {status._json['user']['screen_name']} (dernier mot : \"{lastWord}\")...", end = " ")
|
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
|
if lastWord in universalBase: # check if the last word found is a supported word
|
||||||
|
|
Reference in a new issue