From 219cbcc1ebf5c12a07ffcac5d84326ea679fd2a2 Mon Sep 17 00:00:00 2001 From: Gagan Date: Fri, 15 Mar 2024 21:30:19 +0530 Subject: [PATCH] Update pyroplug.py --- main/plugins/pyroplug.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/main/plugins/pyroplug.py b/main/plugins/pyroplug.py index b6da7efd..ae39139b 100644 --- a/main/plugins/pyroplug.py +++ b/main/plugins/pyroplug.py @@ -31,19 +31,16 @@ def thumbnail(sender): # Define a dictionary to store user chat IDs user_chat_ids = {} -# Command function to set user's chat ID -@bot.on_message(filters.command("setchat") & filters.private) -async def set_chat_id(client, message): +@bot.on(events.NewMessage(incoming=True, pattern='/setchat')) +async def set_chat_id(event): # Extract chat ID from the message - chat_id = message.text.split(" ", 1)[1] try: - # Try converting chat ID to integer - chat_id = int(chat_id) + chat_id = int(event.raw_text.split(" ", 1)[1]) # Store user's chat ID - user_chat_ids[message.from_user.id] = chat_id - await message.reply("Chat ID set successfully!") + user_chat_ids[event.sender_id] = chat_id + await event.reply("Chat ID set successfully!") except ValueError: - await message.reply("Invalid chat ID!") + await event.reply("Invalid chat ID!") async def send_video_with_chat_id(client, sender, path, caption, duration, hi, wi, thumb_path, upm): # Get the user's set chat ID, if available; otherwise, use the original sender ID