|
|
|
@ -235,7 +235,7 @@ def post_tweet(author, content, media_ids=None, reply_to_id=None, tweet_type="rs |
|
|
|
author_info = rate_limit_info[username] |
|
|
|
author_info = rate_limit_info[username] |
|
|
|
|
|
|
|
|
|
|
|
if response.status_code == 201: |
|
|
|
if response.status_code == 201: |
|
|
|
# Successful post - update remaining tweets |
|
|
|
# Successful post - update remaining tweets and increment posted count |
|
|
|
author_info['tweets_posted_in_run'] = author_info.get('tweets_posted_in_run', 0) + 1 |
|
|
|
author_info['tweets_posted_in_run'] = author_info.get('tweets_posted_in_run', 0) + 1 |
|
|
|
author_info['tweet_remaining'] = remaining - 1 # Decrement remaining tweets |
|
|
|
author_info['tweet_remaining'] = remaining - 1 # Decrement remaining tweets |
|
|
|
rate_limit_info[username] = author_info |
|
|
|
rate_limit_info[username] = author_info |
|
|
|
@ -251,6 +251,7 @@ def post_tweet(author, content, media_ids=None, reply_to_id=None, tweet_type="rs |
|
|
|
reset = int(reset_str) |
|
|
|
reset = int(reset_str) |
|
|
|
author_info['tweet_remaining'] = remaining |
|
|
|
author_info['tweet_remaining'] = remaining |
|
|
|
author_info['tweet_reset'] = reset |
|
|
|
author_info['tweet_reset'] = reset |
|
|
|
|
|
|
|
# Don't reset tweets_posted_in_run here |
|
|
|
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) |
|
|
|
logger.info(f"Updated rate limit info from API for {username}: {remaining}/17 tweets remaining") |
|
|
|
logger.info(f"Updated rate limit info from API for {username}: {remaining}/17 tweets remaining") |
|
|
|
@ -1798,10 +1799,10 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400): |
|
|
|
remaining = min(remaining, max_tweets) # Ensure within Free tier limit |
|
|
|
remaining = min(remaining, max_tweets) # Ensure within Free tier limit |
|
|
|
reset = api_reset |
|
|
|
reset = api_reset |
|
|
|
|
|
|
|
|
|
|
|
# Update author info |
|
|
|
# Update author info but preserve tweets_posted_in_run |
|
|
|
author_info['tweet_remaining'] = remaining |
|
|
|
author_info['tweet_remaining'] = remaining |
|
|
|
author_info['tweet_reset'] = reset |
|
|
|
author_info['tweet_reset'] = reset |
|
|
|
author_info['tweets_posted_in_run'] = 0 |
|
|
|
# Don't reset tweets_posted_in_run here |
|
|
|
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) |
|
|
|
|
|
|
|
|
|
|
|
|