Skip to content

Commit 3ce0e1d

Browse files
authored
Fix post.caption
1 parent 31ed2a0 commit 3ce0e1d

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

src/instawebhooks/__main__.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,18 +145,17 @@ async def create_embed(post: Post):
145145
profile_pic_file = File(io.BytesIO(profile_pic_bytes), "profile_pic.webp")
146146

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

161160
embed = Embed(
162161
color=13500529,

0 commit comments

Comments
 (0)