From 9c53022a6acf487c55aa53dd572b64d98dac8f5e Mon Sep 17 00:00:00 2001 From: athphane Date: Thu, 3 Oct 2024 10:55:27 +0500 Subject: [PATCH] feat: add Instagram d.ddinstagram.com regex replacement --- userbot/plugins/text_replacement.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/userbot/plugins/text_replacement.py b/userbot/plugins/text_replacement.py index 62cc3bb..6191cc0 100644 --- a/userbot/plugins/text_replacement.py +++ b/userbot/plugins/text_replacement.py @@ -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",