Shane 7 months ago
parent eff6f585bb
commit 7c7c9a7b0a
  1. 14
      check_x_capacity.py
  2. 2
      foodie_utils.py
  3. 2372
      temp_log.txt

@ -25,11 +25,19 @@ logger = logging.getLogger(__name__)
NOTIFICATION_FILE = '/home/shane/foodie_automator/notification_tracking.json' NOTIFICATION_FILE = '/home/shane/foodie_automator/notification_tracking.json'
def load_notification_tracking(): def load_notification_tracking():
"""Load notification tracking data.""" """Load notification tracking data as a dict. If not a dict, reset to {}."""
return load_json_file(NOTIFICATION_FILE, default={}) data = load_json_file(NOTIFICATION_FILE, default={})
if not isinstance(data, dict):
logging.warning(f"notification_tracking.json was not a dict, resetting to empty dict.")
data = {}
save_json_file(NOTIFICATION_FILE, data)
return data
def save_notification_tracking(tracking_data): def save_notification_tracking(tracking_data):
"""Save notification tracking data.""" """Save notification tracking data as a dict."""
if not isinstance(tracking_data, dict):
logging.warning(f"Attempted to save non-dict to notification_tracking.json, resetting to empty dict.")
tracking_data = {}
save_json_file(NOTIFICATION_FILE, tracking_data) save_json_file(NOTIFICATION_FILE, tracking_data)
def should_send_notification(username, reset_time): def should_send_notification(username, reset_time):

@ -1810,6 +1810,8 @@ def check_author_rate_limit(author, max_tweets=17, tweet_window_seconds=86400):
if remaining < 0: if remaining < 0:
logger.warning(f"Negative remaining tweets for {username}: {remaining}. Setting to 0.") logger.warning(f"Negative remaining tweets for {username}: {remaining}. Setting to 0.")
remaining = 0 remaining = 0
# Always cap at zero
remaining = max(0, remaining)
can_post = remaining > 0 can_post = remaining > 0
if not can_post: if not can_post:

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save