Skip to content

Commit 8cb8932

Browse files
authored
Add hyperlinks for mentions
1 parent 1d19a95 commit 8cb8932

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

src/instawebhooks/__main__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,17 @@ async def create_embed(post: Post):
144144
post_image_file = File(io.BytesIO(post_image_bytes), "post_image.webp")
145145
profile_pic_file = File(io.BytesIO(profile_pic_bytes), "profile_pic.webp")
146146

147-
# Replace hashtags with clickable links
148-
if post.caption is None:
149-
post_caption = ""
150-
else:
151-
post_caption = re.sub(
152-
r"#([a-zA-Z0-9]+\b)",
153-
r"[#\1](https://www.instagram.com/explore/tags/\1)",
154-
post.caption,
155-
)
147+
# Format the post caption with clickable links for mentions and hashtags
148+
post_caption = re.sub(
149+
r"#([a-zA-Z0-9]+\b)",
150+
r"[#\1](https://www.instagram.com/explore/tags/\1)",
151+
post.caption,
152+
)
153+
post_caption = re.sub(
154+
r"@([a-zA-Z0-9_]+\b)",
155+
r"[@\1](https://www.instagram.com/\1)",
156+
post_caption,
157+
)
156158

157159
embed = Embed(
158160
color=13500529,

0 commit comments

Comments
 (0)