dictionary structure of X_API_CREDENTIALS

main
Shane 7 months ago
parent 8825d7a9f8
commit 2041084962
  1. 2
      foodie_engagement_tweet.py
  2. 2
      foodie_utils.py
  3. 2
      foodie_weekly_thread.py

@ -126,7 +126,7 @@ def get_reference_date():
def generate_engagement_tweet(author): def generate_engagement_tweet(author):
"""Generate an engagement tweet using author background themes.""" """Generate an engagement tweet using author background themes."""
credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) credentials = X_API_CREDENTIALS.get(author["username"])
if not credentials: if not credentials:
logging.error(f"No X credentials found for {author['username']}") logging.error(f"No X credentials found for {author['username']}")
return None return None

@ -216,7 +216,7 @@ def post_tweet(author, tweet, reply_to_id=None):
import tweepy import tweepy
from datetime import datetime, timezone from datetime import datetime, timezone
credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) credentials = X_API_CREDENTIALS.get(author["username"])
if not credentials: if not credentials:
logging.error(f"No X credentials found for {author['username']}") logging.error(f"No X credentials found for {author['username']}")
return False return False

@ -100,7 +100,7 @@ def validate_twitter_credentials():
logging.info("Validating Twitter API credentials for all authors") logging.info("Validating Twitter API credentials for all authors")
valid_credentials = [] valid_credentials = []
for author in AUTHORS: for author in AUTHORS:
credentials = next((cred for cred in X_API_CREDENTIALS if cred["username"] == author["username"]), None) credentials = X_API_CREDENTIALS.get(author["username"])
if not credentials: if not credentials:
logging.error(f"No X credentials found for {author['username']} in X_API_CREDENTIALS") logging.error(f"No X credentials found for {author['username']} in X_API_CREDENTIALS")
continue continue

Loading…
Cancel
Save