From a40866e7366c779315a99f8cb56aa81c0dc1bcab Mon Sep 17 00:00:00 2001 From: Mylloon Date: Sun, 7 Aug 2022 22:06:41 +0200 Subject: [PATCH] don't check the tweet date and doublecheck for retweets --- main.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 8f77773..cedfae1 100644 --- a/main.py +++ b/main.py @@ -5,7 +5,6 @@ from random import choice from re import findall, sub from dotenv import load_dotenv -from pytz import timezone from tweepy import Client, StreamingClient, StreamRule, Tweet @@ -95,8 +94,8 @@ class Listener(StreamingClient): print(f"Raison : {notice['reason']}") def on_tweet(self, tweet: Tweet): - # Verify the age of the tweet - if seniority(tweet.created_at): + # Check if the tweet is not a retweet + if not tweet.text.startswith("RT @"): # Fetch the last word of the tweet tweet.username: str = self.client.get_user( id=tweet.author_id, user_auth=True).data.username @@ -194,18 +193,6 @@ def getFriends(client: Client, users: list[str]) -> list: return friends_list[0] -def seniority(date: datetime) -> bool: - """Return True only if the given string date is less than one day old""" - # Convert string format to datetime format - datetimeObject = datetime.strptime(date, "%a %b %d %H:%M:%S +0000 %Y") - # Twitter give us an UTC time - datetimeObject = datetimeObject.replace(tzinfo=timezone("UTC")) - # time now in UTC minus the time we got to get the age of the date - age = datetime.now(timezone("UTC")) - datetimeObject - # False if older than a day, else True - return False if age.days >= 1 else True - - def createBaseTrigger(lists: list[list]) -> list: """Merges all given lists into one""" listing = []