userbot icon indicating copy to clipboard operation
userbot copied to clipboard

Disable ytdlp download in saved messages

Open Copilot opened this issue 1 month ago • 0 comments

The ytdlp download feature was triggering when URLs were sent to saved messages (messages to self), creating unwanted downloads.

Changes

  • Early exit for saved messages: Compare message.chat.id with bot's user ID and return before processing
  • User ID caching: Lazily fetch and cache bot user ID to avoid repeated get_me() calls
  • Applies to both triggers: Automatic URL detection and .dl command both skip saved messages
@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
    
    # ... rest of download logic
Original prompt

make it so that the ytdlp download feature does not work when I send a matching URL to saved messages, aka to myself.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot avatar Dec 13 '25 14:12 Copilot