add a check if the conversation_id doesn't exists
This commit is contained in:
parent
61a1d52bf8
commit
35e27c7da1
1 changed files with 25 additions and 19 deletions
44
main.py
44
main.py
|
@ -103,26 +103,32 @@ class Listener(StreamingClient):
|
||||||
# Check if the tweet is not a retweet
|
# Check if the tweet is not a retweet
|
||||||
if not tweet.text.startswith("RT @"):
|
if not tweet.text.startswith("RT @"):
|
||||||
# Cancel if author of the first tweet in the conversation is in private
|
# Cancel if author of the first tweet in the conversation is in private
|
||||||
if tweet.conversation_id and tweet.id != tweet.conversation_id:
|
if tweet.conversation_id:
|
||||||
if keys["VERBOSE"]:
|
if tweet.id != tweet.conversation_id:
|
||||||
print("Thread...", end=" ")
|
|
||||||
base_tweet = self.client.get_tweet(id=tweet.conversation_id, tweet_fields="author_id", user_auth=True).data
|
|
||||||
# Sometimes Twitter don't give what we want
|
|
||||||
if hasattr(base_tweet, 'author_id'):
|
|
||||||
base_author = self._get_user(base_tweet.author_id)
|
|
||||||
# Check if account is in private mode
|
|
||||||
if base_author.protected:
|
|
||||||
if keys["VERBOSE"]:
|
|
||||||
print("Auteur du premier tweet en privé, pas de réponses.")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
if keys["VERBOSE"]:
|
|
||||||
print("Auteur du premier tweet en publique...", end=" ")
|
|
||||||
else:
|
|
||||||
# Can't check the status of the first tweet in the thread, ignoring for safety
|
|
||||||
if keys["VERBOSE"]:
|
if keys["VERBOSE"]:
|
||||||
print("Impossible de vérifier le status de l'auteur du fil.")
|
print("Thread...", end=" ")
|
||||||
return
|
base_tweet = self.client.get_tweet(id=tweet.conversation_id, tweet_fields="author_id", user_auth=True).data
|
||||||
|
# Sometimes Twitter don't give what we want
|
||||||
|
if hasattr(base_tweet, 'author_id'):
|
||||||
|
base_author = self._get_user(base_tweet.author_id)
|
||||||
|
# Check if account is in private mode
|
||||||
|
if base_author.protected:
|
||||||
|
if keys["VERBOSE"]:
|
||||||
|
print("Auteur du premier tweet en privé, pas de réponses.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
if keys["VERBOSE"]:
|
||||||
|
print("Auteur du premier tweet en publique...", end=" ")
|
||||||
|
else:
|
||||||
|
# Can't check the status of the first tweet in the thread, ignoring for safety
|
||||||
|
if keys["VERBOSE"]:
|
||||||
|
print("Impossible de vérifier le status de l'auteur du fil.")
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# Can't check if we're in a thread or not
|
||||||
|
if keys["VERBOSE"]:
|
||||||
|
print("Impossible de vérifier si le tweet est dans un thread.")
|
||||||
|
return
|
||||||
author = self._get_user(tweet.author_id)
|
author = self._get_user(tweet.author_id)
|
||||||
# Clean the tweet
|
# Clean the tweet
|
||||||
lastWord = cleanTweet(tweet.text)
|
lastWord = cleanTweet(tweet.text)
|
||||||
|
|
Reference in a new issue