fix author X post to use persona
This commit is contained in:
+14
-5
@@ -832,13 +832,22 @@ def post_to_wp(post_data, category, link, author, image_url, original_source, im
|
|||||||
timestamp = datetime.now(timezone.utc).isoformat()
|
timestamp = datetime.now(timezone.utc).isoformat()
|
||||||
save_post_to_recent(post_data["title"], post_url, wp_username, timestamp)
|
save_post_to_recent(post_data["title"], post_url, wp_username, timestamp)
|
||||||
|
|
||||||
# Post tweet if enabled
|
# Post tweet if enabled
|
||||||
if should_post_tweet:
|
if should_post_tweet:
|
||||||
credentials = X_API_CREDENTIALS.get(post_data["author"])
|
credentials = X_API_CREDENTIALS.get(post_data["author"])
|
||||||
if credentials:
|
if credentials:
|
||||||
tweet_text = f"{post_data['title']}\n{post_url}"
|
# Select persona for the tweet (same logic as used in summarize_with_gpt4o)
|
||||||
if post_tweet(author, tweet_text):
|
persona = select_best_persona(interest_score, post_data["content"])
|
||||||
logger.info(f"Successfully tweeted for post: {post_data['title']}")
|
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:
|
else:
|
||||||
logger.warning(f"Failed to tweet for post: {post_data['title']}")
|
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']
|
resource_owner_secret=credentials['access_token_secret']
|
||||||
)
|
)
|
||||||
url = 'https://api.x.com/2/tweets'
|
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:
|
try:
|
||||||
response = requests.post(url, json=payload, auth=oauth)
|
response = requests.post(url, json=payload, auth=oauth)
|
||||||
|
|||||||
Reference in New Issue
Block a user