check
This commit is contained in:
+16
-3
@@ -22,16 +22,23 @@ def display_author_status(author):
|
|||||||
can_post, remaining, reset = check_author_rate_limit(author)
|
can_post, remaining, reset = check_author_rate_limit(author)
|
||||||
reset_time = datetime.fromtimestamp(reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
reset_time = datetime.fromtimestamp(reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
|
||||||
|
# Get detailed API status first
|
||||||
|
api_remaining, api_reset = get_x_rate_limit_status(author)
|
||||||
|
if api_remaining is not None:
|
||||||
|
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
|
# Use API values as primary display
|
||||||
|
remaining = api_remaining
|
||||||
|
reset_time = api_reset_time
|
||||||
|
can_post = remaining > 0
|
||||||
|
|
||||||
status = "✅" if can_post else "❌"
|
status = "✅" if can_post else "❌"
|
||||||
print(f"\n{status} {username}:")
|
print(f"\n{status} {username}:")
|
||||||
print(f" • Remaining tweets: {remaining}/17")
|
print(f" • Remaining tweets: {remaining}/17")
|
||||||
print(f" • Reset time: {reset_time}")
|
print(f" • Reset time: {reset_time}")
|
||||||
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
||||||
|
|
||||||
# Get detailed API status
|
# Show API status for verification
|
||||||
api_remaining, api_reset = get_x_rate_limit_status(author)
|
|
||||||
if api_remaining is not None:
|
if api_remaining is not None:
|
||||||
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
|
||||||
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
||||||
|
|
||||||
def display_total_capacity():
|
def display_total_capacity():
|
||||||
@@ -46,6 +53,12 @@ def display_total_capacity():
|
|||||||
|
|
||||||
for author in AUTHORS:
|
for author in AUTHORS:
|
||||||
can_post, remaining, _ = check_author_rate_limit(author)
|
can_post, remaining, _ = check_author_rate_limit(author)
|
||||||
|
# Get API status for accurate count
|
||||||
|
api_remaining, _ = get_x_rate_limit_status(author)
|
||||||
|
if api_remaining is not None:
|
||||||
|
remaining = api_remaining
|
||||||
|
can_post = remaining > 0
|
||||||
|
|
||||||
used = 17 - remaining
|
used = 17 - remaining
|
||||||
total_used += used
|
total_used += used
|
||||||
if can_post:
|
if can_post:
|
||||||
|
|||||||
@@ -1667,6 +1667,7 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400):
|
|||||||
logger.info(f"At least one script is running, using stored rate limit info for {username}")
|
logger.info(f"At least one script is running, using stored rate limit info for {username}")
|
||||||
remaining = author_info.get('tweet_remaining', max_tweets)
|
remaining = author_info.get('tweet_remaining', max_tweets)
|
||||||
reset = author_info.get('tweet_reset', current_time + tweet_window_seconds)
|
reset = author_info.get('tweet_reset', current_time + tweet_window_seconds)
|
||||||
|
|
||||||
# Check if reset time has passed
|
# Check if reset time has passed
|
||||||
if current_time >= reset:
|
if current_time >= reset:
|
||||||
logger.info(f"Reset time passed for {username}, resetting quota")
|
logger.info(f"Reset time passed for {username}, resetting quota")
|
||||||
@@ -1677,6 +1678,7 @@ 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)
|
||||||
|
|
||||||
# Adjust for tweets posted in this run
|
# Adjust for tweets posted in this run
|
||||||
remaining = remaining - author_info.get('tweets_posted_in_run', 0)
|
remaining = remaining - author_info.get('tweets_posted_in_run', 0)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user