check all authors on start rate limit X
This commit is contained in:
+7
-4
@@ -1215,6 +1215,10 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400):
|
|||||||
remaining = max_tweets
|
remaining = max_tweets
|
||||||
reset = current_time + tweet_window_seconds
|
reset = current_time + tweet_window_seconds
|
||||||
logger.warning(f"Test tweet failed for {username}, resetting quota to {max_tweets}")
|
logger.warning(f"Test tweet failed for {username}, resetting quota to {max_tweets}")
|
||||||
|
# Ensure reset is in the future
|
||||||
|
if reset <= current_time:
|
||||||
|
logger.warning(f"Reset time {reset} is in the past for {username}. Setting to 24 hours from now.")
|
||||||
|
reset = current_time + tweet_window_seconds
|
||||||
# Update author info with synced quota
|
# Update author info with synced quota
|
||||||
author_info = {
|
author_info = {
|
||||||
'tweet_remaining': remaining,
|
'tweet_remaining': remaining,
|
||||||
@@ -1225,11 +1229,8 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400):
|
|||||||
rate_limit_info[username] = author_info
|
rate_limit_info[username] = author_info
|
||||||
save_json_file(rate_limit_file, rate_limit_info)
|
save_json_file(rate_limit_file, rate_limit_info)
|
||||||
|
|
||||||
# Calculate remaining tweets based on tweets posted in this run
|
|
||||||
remaining = author_info['tweet_remaining'] - author_info['tweets_posted_in_run']
|
|
||||||
reset = author_info['tweet_reset']
|
|
||||||
|
|
||||||
# Check if quota has reset
|
# Check if quota has reset
|
||||||
|
reset = author_info['tweet_reset']
|
||||||
if current_time >= reset:
|
if current_time >= reset:
|
||||||
logger.info(f"Quota reset for {username}, restoring to {max_tweets} tweets")
|
logger.info(f"Quota reset for {username}, restoring to {max_tweets} tweets")
|
||||||
remaining = max_tweets
|
remaining = max_tweets
|
||||||
@@ -1239,6 +1240,8 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400):
|
|||||||
author_info['tweets_posted_in_run'] = 0
|
author_info['tweets_posted_in_run'] = 0
|
||||||
rate_limit_info[username] = author_info
|
rate_limit_info[username] = author_info
|
||||||
save_json_file(rate_limit_file, rate_limit_info)
|
save_json_file(rate_limit_file, rate_limit_info)
|
||||||
|
else:
|
||||||
|
remaining = author_info['tweet_remaining'] - author_info['tweets_posted_in_run']
|
||||||
|
|
||||||
can_post = remaining > 0
|
can_post = remaining > 0
|
||||||
if not can_post:
|
if not can_post:
|
||||||
|
|||||||
Reference in New Issue
Block a user