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 datetime import datetime, timezone
|
||||||
from foodie_utils import (
|
from foodie_utils import (
|
||||||
AUTHORS, check_author_rate_limit, load_json_file,
|
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 time
|
||||||
import sys
|
import sys
|
||||||
@@ -22,14 +22,15 @@ 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
|
# Only check API if no scripts are running
|
||||||
api_remaining, api_reset = get_x_rate_limit_status(author)
|
if not is_any_script_running():
|
||||||
if api_remaining is not None:
|
api_remaining, api_reset = get_x_rate_limit_status(author)
|
||||||
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
if api_remaining is not None:
|
||||||
# Use API values as primary display
|
api_reset_time = datetime.fromtimestamp(api_reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S')
|
||||||
remaining = api_remaining
|
# Use API values as primary display
|
||||||
reset_time = api_reset_time
|
remaining = api_remaining
|
||||||
can_post = remaining > 0
|
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}:")
|
||||||
@@ -38,8 +39,11 @@ def display_author_status(author):
|
|||||||
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
print(f" • Can post: {'Yes' if can_post else 'No'}")
|
||||||
|
|
||||||
# Show API status for verification
|
# Show API status for verification
|
||||||
if api_remaining is not None:
|
if not is_any_script_running():
|
||||||
print(f" • API Status: {api_remaining} remaining, resets at {api_reset_time}")
|
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():
|
def display_total_capacity():
|
||||||
"""Display total capacity across all authors."""
|
"""Display total capacity across all authors."""
|
||||||
@@ -53,11 +57,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
|
# Only check API if no scripts are running
|
||||||
api_remaining, _ = get_x_rate_limit_status(author)
|
if not is_any_script_running():
|
||||||
if api_remaining is not None:
|
api_remaining, _ = get_x_rate_limit_status(author)
|
||||||
remaining = api_remaining
|
if api_remaining is not None:
|
||||||
can_post = remaining > 0
|
remaining = api_remaining
|
||||||
|
can_post = remaining > 0
|
||||||
|
|
||||||
used = 17 - remaining
|
used = 17 - remaining
|
||||||
total_used += used
|
total_used += used
|
||||||
|
|||||||
Reference in New Issue
Block a user