try
This commit is contained in:
+11
-3
@@ -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:
|
||||||
|
|||||||
+1955
-417
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user