add enguagement tweet & fix filtered words

This commit is contained in:
2025-04-30 08:51:38 +10:00
parent 5963712139
commit 15186846be
5 changed files with 245 additions and 41 deletions
+23 -13
View File
@@ -28,17 +28,27 @@ def get_dynamic_hook(article_title):
logging.error(f"Dynamic hook generation failed: {e}")
return "This food scoop will blow your mind!"
def select_best_cta(article_title, article_summary, post_url):
# Use the provided post_url if available, otherwise a placeholder to be updated later
share_url_base = post_url if post_url else "https://insiderfoodie.com/placeholder"
share_url = f"https://x.com/intent/tweet?url={quote(share_url_base)}&text={quote(get_dynamic_hook(article_title))}"
cta_options = [
f"Cant Get Enough? Share This Now On <a href='{share_url}'><i class='tsi tsi-twitter'></i></a>!",
f"Obsessed Yet? Spread the Word On <a href='{share_url}'><i class='tsi tsi-twitter'></i></a>!",
f"This Blew Your Mind, Right? Tweet It On <a href='{share_url}'><i class='tsi tsi-twitter'></i></a>!",
f"Ready to Spill the Tea? Share On <a href='{share_url}'><i class='tsi tsi-twitter'></i></a>!",
f"Too Wild to Keep Quiet? Post It On <a href='{share_url}'><i class='tsi tsi-twitter'></i></a>!"
def select_best_cta(title, content, post_url=None):
cta_templates = [
# Share-focused CTAs
"Cant Get Enough Share This Now On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
"This Blew Your Mind Right Tweet It On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
"Ready to Spill the Tea Share On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
"Too Wild to Keep Quiet Post It On <a href='https://x.com/intent/tweet?url={url}&text={text}'><i class='tsi tsi-twitter'></i></a>",
# Like-focused CTAs
"Love This Foodie Find Hit That Like Button",
"Think This Dish Is a Game Changer Show Some Love With a Like",
# Follow-focused CTAs
"Hungry for More Foodie Insights Follow Us for the Latest Trends",
"Dont Miss Out on Foodie Updates Follow Us Today"
]
selected_cta = random.choice(cta_options)
logging.info(f"Selected random CTA: {selected_cta}")
return selected_cta
hook = get_dynamic_hook(title).strip()
hook = urllib.parse.quote(hook)
url = post_url if post_url else "https://insiderfoodie.com/placeholder"
url = urllib.parse.quote(url)
cta = random.choice(cta_templates)
if "https://x.com/intent/tweet" in cta:
cta = cta.format(url=url, text=hook)
return cta