Shane 7 months ago
parent 110346064f
commit 9ad9228e51
  1. 6
      foodie_engagement_tweet.py
  2. 8
      foodie_utils.py

@ -410,6 +410,12 @@ def post_engagement_tweet():
logging.warning(f"Daily post limit (20) reached for {username}, skipping") logging.warning(f"Daily post limit (20) reached for {username}, skipping")
continue continue
# Check user activity before posting
credentials = X_API_CREDENTIALS.get(username)
if credentials:
from foodie_utils import check_user_activity
check_user_activity(username, credentials)
tweet = generate_engagement_tweet(author) tweet = generate_engagement_tweet(author)
if not tweet: if not tweet:
logging.error(f"Failed to generate engagement tweet for {username}, skipping") logging.error(f"Failed to generate engagement tweet for {username}, skipping")

@ -281,11 +281,11 @@ def post_tweet(author, tweet, reply_to_id=None):
in_reply_to_tweet_id=reply_to_id in_reply_to_tweet_id=reply_to_id
) )
# Log rate limit headers on success # Log rate limit headers on success
if hasattr(client, 'session') and client.session.last_response: if hasattr(response, '_response') and response._response: # Access the underlying response
rate_limit_headers = { rate_limit_headers = {
"x-rate-limit-limit": client.session.last_response.headers.get("x-rate-limit-limit"), "x-rate-limit-limit": response._response.headers.get("x-rate-limit-limit"),
"x-rate-limit-remaining": client.session.last_response.headers.get("x-rate-limit-remaining"), "x-rate-limit-remaining": response._response.headers.get("x-rate-limit-remaining"),
"x-rate-limit-reset": client.session.last_response.headers.get("x-rate-limit-reset"), "x-rate-limit-reset": response._response.headers.get("x-rate-limit-reset"),
} }
logging.debug(f"Rate limit headers after posting for {username}: {rate_limit_headers}") logging.debug(f"Rate limit headers after posting for {username}: {rate_limit_headers}")
else: else:

Loading…
Cancel
Save