fix author X post to use persona
This commit is contained in:
+13
-4
@@ -836,9 +836,18 @@ def post_to_wp(post_data, category, link, author, image_url, original_source, im
|
||||
if should_post_tweet:
|
||||
credentials = X_API_CREDENTIALS.get(post_data["author"])
|
||||
if credentials:
|
||||
tweet_text = f"{post_data['title']}\n{post_url}"
|
||||
if post_tweet(author, tweet_text):
|
||||
logger.info(f"Successfully tweeted for post: {post_data['title']}")
|
||||
# Select persona for the tweet (same logic as used in summarize_with_gpt4o)
|
||||
persona = select_best_persona(interest_score, post_data["content"])
|
||||
logger.info(f"Selected persona for tweet: {persona}")
|
||||
# Generate GPT-based tweet
|
||||
tweet_post = {
|
||||
"title": post_data["title"],
|
||||
"url": post_url
|
||||
}
|
||||
tweet_text = generate_article_tweet(author, tweet_post, persona)
|
||||
tweet_id, tweet_data = post_tweet(author, tweet_text)
|
||||
if tweet_id:
|
||||
logger.info(f"Successfully tweeted for post: {post_data['title']} (Tweet ID: {tweet_id})")
|
||||
else:
|
||||
logger.warning(f"Failed to tweet for post: {post_data['title']}")
|
||||
|
||||
@@ -1255,7 +1264,7 @@ def get_x_rate_limit_status(author):
|
||||
resource_owner_secret=credentials['access_token_secret']
|
||||
)
|
||||
url = 'https://api.x.com/2/tweets'
|
||||
payload = {'text': f'Test tweet to check rate limits for {username} - please ignore'}
|
||||
payload = {'text': f'Test tweet to check rate limits for {username} - please ignore {int(time.time())}'}
|
||||
|
||||
try:
|
||||
response = requests.post(url, json=payload, auth=oauth)
|
||||
|
||||
Reference in New Issue
Block a user