Skip to content

Commit

Permalink
Fix post.caption
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanLua authored Aug 20, 2024
1 parent 31ed2a0 commit 3ce0e1d
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions src/instawebhooks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,17 @@ async def create_embed(post: Post):
profile_pic_file = File(io.BytesIO(profile_pic_bytes), "profile_pic.webp")

# Format the post caption with clickable links for mentions and hashtags
post_caption = post.caption
if post_caption is str:
post_caption = re.sub(
r"#([a-zA-Z0-9]+\b)",
r"[#\1](https://www.instagram.com/explore/tags/\1)",
post_caption,
)
post_caption = re.sub(
r"@([a-zA-Z0-9_]+\b)",
r"[@\1](https://www.instagram.com/\1)",
post_caption,
)
post_caption = post.caption or ""
post_caption = re.sub(
r"#([a-zA-Z0-9]+\b)",
r"[#\1](https://www.instagram.com/explore/tags/\1)",
post_caption,
)
post_caption = re.sub(
r"@([a-zA-Z0-9_]+\b)",
r"[@\1](https://www.instagram.com/\1)",
post_caption,
)

embed = Embed(
color=13500529,
Expand Down

0 comments on commit 3ce0e1d

Please sign in to comment.