diff --git a/userbot/plugins/video_dl.py b/userbot/plugins/video_dl.py index e38de8a9..b76cb302 100644 --- a/userbot/plugins/video_dl.py +++ b/userbot/plugins/video_dl.py @@ -26,6 +26,9 @@ # Combined regex for function trigger video_url_regex = f"({instagram_regex}|{tiktok_regex}|{youtube_regex}|{facebook_regex})" +# Cache for the bot's user ID to avoid repeated API calls +_bot_user_id = None + async def get_final_url(url): timeout = aiohttp.ClientTimeout(total=10) @@ -51,6 +54,16 @@ async def process_urls(url): @UserBot.on_message(filters.regex(video_url_regex) & filters.me) async def video_downloader(bot: UserBot, message: Message, from_reply=False): + global _bot_user_id + + # Don't download if the message is sent to saved messages (to myself) + if _bot_user_id is None: + me = await bot.get_me() + _bot_user_id = me.id + + if message.chat.id == _bot_user_id: + return + # Extract the video URL from the message message_text = message.text or message.caption