fix bug: latest tweet time check

master
wlt233 2 weeks ago
parent fd9ed57637
commit 3484454769

@ -14,7 +14,7 @@ from .twi_parser import parse_timeline
LATEST_TWEET_ID_DICT = {}
LATEST_TWEET_TS_DICT = {}
def check_new_tweets(tweets, list_id):
def check_new_tweets(tweets, list_id, check_interval=600):
if not tweets: return []
new_tweets = []
@ -22,7 +22,7 @@ def check_new_tweets(tweets, list_id):
for tweet in tweets:
if tweet["rest_id"] == LATEST_TWEET_ID_DICT[list_id]: break
if tweet["timestamp"] <= LATEST_TWEET_TS_DICT[list_id]: break
# if time.time() - tweet["timestamp"] > 1200: break
if time.time() - tweet["timestamp"] > check_interval * 3: break
new_tweets.append(tweet)
LATEST_TWEET_ID_DICT[list_id] = tweets[0]["rest_id"]
@ -51,7 +51,7 @@ async def task_handler(args):
data = await get_list(list_id)
if data:
tweets = parse_timeline(data)
new_tweets = check_new_tweets(tweets, list_id)
new_tweets = check_new_tweets(tweets, list_id, config.get("check_interval", 600))
new_tweets = filter_tweets(new_tweets, args["filter"])
if new_tweets:
json_data = { args["qq"]: new_tweets }

Loading…
Cancel
Save