This commit is contained in:
2025-05-08 17:31:29 +10:00
parent ae194b502f
commit 82f4a1d8b1
7 changed files with 294 additions and 175 deletions
+4 -8
View File
@@ -8,7 +8,7 @@ import fcntl
import os
from datetime import datetime, timedelta, timezone
from openai import OpenAI
from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, check_author_rate_limit
from foodie_utils import post_tweet, AUTHORS, SUMMARY_MODEL, check_author_rate_limit, load_json_file
from foodie_config import X_API_CREDENTIALS, AUTHOR_BACKGROUNDS_FILE
from dotenv import load_dotenv
@@ -162,13 +162,9 @@ def post_engagement_tweet():
for author in AUTHORS:
# Check if the author can post before generating the tweet
if check_author_rate_limit(author):
reset_time = datetime.fromtimestamp(
load_json_file('/home/shane/foodie_automator/rate_limit_info.json', default={})
.get(author['username'], {})
.get('tweet_reset', time.time()),
tz=timezone.utc
).strftime('%Y-%m-%d %H:%M:%S')
can_post, remaining, reset = check_author_rate_limit(author)
if not can_post:
reset_time = datetime.fromtimestamp(reset, tz=timezone.utc).strftime('%Y-%m-%d %H:%M:%S') if reset else "Unknown"
logging.info(f"Skipping engagement tweet for {author['username']} due to rate limit. Reset at: {reset_time}")
continue