use file instead of API checks for rate limit X
This commit is contained in:
+21
-16
@@ -3,7 +3,7 @@ import logging
|
||||
from datetime import datetime, timezone
|
||||
from foodie_utils import (
|
||||
AUTHORS, check_author_rate_limit, load_json_file,
|
||||
get_x_rate_limit_status, update_system_activity
|
||||
get_x_rate_limit_status, update_system_activity, is_any_script_running
|
||||
)
|
||||
import time
|
||||
import sys
|
||||
@@ -22,14 +22,15 @@ def display_author_status(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')
|
||||
|
||||
# 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
|
||||
# Only check API if no scripts are running
|
||||
if not is_any_script_running():
|
||||
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 "❌"
|
||||
print(f"\n{status} {username}:")
|
||||
@@ -38,8 +39,11 @@ def display_author_status(author):
|
||||
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
||||
|
||||
# Show API status for verification
|
||||
if api_remaining is not None:
|
||||
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
||||
if not is_any_script_running():
|
||||
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')
|
||||
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
||||
|
||||
def display_total_capacity():
|
||||
"""Display total capacity across all authors."""
|
||||
@@ -53,11 +57,12 @@ def display_total_capacity():
|
||||
|
||||
for author in AUTHORS:
|
||||
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
|
||||
# Only check API if no scripts are running
|
||||
if not is_any_script_running():
|
||||
api_remaining, _ = get_x_rate_limit_status(author)
|
||||
if api_remaining is not None:
|
||||
remaining = api_remaining
|
||||
can_post = remaining > 0
|
||||
|
||||
used = 17 - remaining
|
||||
total_used += used
|
||||
|
||||
Reference in New Issue
Block a user