Skip to content

Commit

Permalink
feat: add Instagram d.ddinstagram.com regex replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
athphane committed Oct 3, 2024
1 parent d7a7f74 commit 9c53022
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions userbot/plugins/text_replacement.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ async def twitter_url_fixer(bot: UserBot, message: Message):
)


# Assuming UserBot is your Client instance
instagram_regex = r'https?://(www\.)?instagram\.com/[^\s]+'

@UserBot.on_message(filters.regex(instagram_regex) & filters.me)
async def instagram_url_fixer(bot: UserBot, message: Message):
# Extract the text from the message
message_text = message.text

# Check and replace instagram.com with d.ddinstagram.com
modified_text = re.sub(r'(https?://)(instagram\.com)', r'\1d.ddinstagram.com', message_text)

# Edit the message with the modified link
await message.edit(
modified_text,
disable_web_page_preview=False # Webpage preview enabled
)


# Command help section
add_command_help(
"reddit",
Expand Down

0 comments on commit 9c53022

Please sign in to comment.