diff --git a/plugins/cb_data.py b/plugins/cb_data.py index d76ae55..56547b5 100644 --- a/plugins/cb_data.py +++ b/plugins/cb_data.py @@ -12,7 +12,7 @@ # --------------------------- Source Button Action ------------------------------ # @Client.on_callback_query(filters.regex(r'^source_btn$')) async def source_chat_config(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) await cb.message.delete() source = await client.send_message( chat_id=cb.message.chat.id, @@ -29,7 +29,7 @@ async def source_chat_config(client: Bot, cb: CallbackQuery): # --------------------------- Destination Button Action ------------------------- # @Client.on_callback_query(filters.regex(r'^dest_btn$')) async def dest_chat_config(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) await cb.message.delete() dest = await client.send_message( chat_id=cb.message.chat.id, @@ -46,7 +46,7 @@ async def dest_chat_config(client: Bot, cb: CallbackQuery): # ---------------------------- Chat View Button Action -------------------------- # @Client.on_callback_query(filters.regex(r'^view_btn$')) async def view_config(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) if usr in source_chat and destination_chat: await cb.message.delete() await client.send_message( @@ -63,7 +63,7 @@ async def view_config(client: Bot, cb: CallbackQuery): # --------------------------- Delete configuration Button Action --------------- # @Client.on_callback_query(filters.regex(r'^del_cfg_btn$')) async def del_config(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) if usr in source_chat and destination_chat: source_chat.pop(usr) destination_chat.pop(usr) @@ -75,7 +75,7 @@ async def del_config(client: Bot, cb: CallbackQuery): # --------------------------- Clone Button Action ----------------------------- # @Client.on_callback_query(filters.regex(r'^clone_btn$')) async def clone_button(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) if usr in source_chat and destination_chat: await cb.message.delete() await clone_medias(client, cb.message) @@ -93,7 +93,7 @@ async def help_txt(client: Bot, cb: CallbackQuery): # --------------------------- Stop Button Action ----------------------------- # @Client.on_callback_query(filters.regex(r'^stop_clone$')) async def stop_process(client: Bot, cb: CallbackQuery): - usr = int(cb.message.chat.id) + usr = int(cb.from_user.id) await cb.message.delete() clone_status.pop(usr) diff --git a/plugins/chat_config.py b/plugins/chat_config.py index c8a5201..a6e82c8 100644 --- a/plugins/chat_config.py +++ b/plugins/chat_config.py @@ -4,6 +4,7 @@ from presets import Presets from pyrogram import filters, Client from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton +from pyrogram.errors import FloodWait from init import source_chat, destination_chat, source_message_id, dest_message_id, help_message_id @@ -59,22 +60,41 @@ async def start_bot(client: Bot, message: Message): async def chat_reply(client: Bot, message: Message): usr = int(message.from_user.id) user_bot_me = await client.USER.get_me() + chat_status = [] try: if message.reply_to_message.message_id == source_message_id[usr]: if str(message.text).startswith('-100') and message.text[1:].isdigit(): - bot_msg = await message.reply_text(text=Presets.WAIT_MSG) - await asyncio.sleep(1) - try: - if destination_chat[usr] == message.text: - await message.delete() - await client.delete_messages(message.chat.id, source_message_id[usr]) - await bot_msg.edit(Presets.CHAT_DUPLICATED_MSG) - await asyncio.sleep(5) - await bot_msg.delete() - await start_bot(client, message) - return - except Exception: - pass + chat_id = int(message.text) + elif str(message.text).startswith('@') and bool(str(message.text).isdigit()) == bool(0): + chat_id = str(message.text) + else: + return + bot_msg = await message.reply_text(text=Presets.WAIT_MSG) + await asyncio.sleep(1) + try: + chat_status = await client.USER.get_chat(chat_id) + except FloodWait as e: + await asyncio.sleep(e.x) + except Exception: + await client.delete_messages(message.chat.id, source_message_id[usr]) + await bot_msg.edit(Presets.INVALID_CHAT_ID) + await message.delete() + await asyncio.sleep(3) + await bot_msg.delete() + await start_bot(client, message) + return + try: + if destination_chat[usr] == message.text: + await message.delete() + await client.delete_messages(message.chat.id, source_message_id[usr]) + await bot_msg.edit(Presets.CHAT_DUPLICATED_MSG) + await asyncio.sleep(5) + await bot_msg.delete() + await start_bot(client, message) + return + except Exception: + pass + if bool(chat_status.username) == bool(0): try: await client.USER.get_chat_member(chat_id=int(message.text), user_id=int(user_bot_me.id)) except Exception: @@ -86,23 +106,23 @@ async def chat_reply(client: Bot, message: Message): await bot_msg.delete() await start_bot(client, message) return - await client.delete_messages(message.chat.id, source_message_id[usr]) - source_chat[usr] = message.text - await message.delete() - source_message_id.pop(usr) - await bot_msg.edit(Presets.SOURCE_CONFIRM.format(source_chat[usr])) - await asyncio.sleep(2) - await start_bot(client, message) - return - else: - await client.delete_messages(message.chat.id, source_message_id[usr]) - warn = await message.reply_text(Presets.INVALID_CHAT_ID) - await message.delete() - source_message_id.pop(usr) - await asyncio.sleep(3) - await warn.delete() - await start_bot(client, message) - return + await client.delete_messages(message.chat.id, source_message_id[usr]) + source_chat[usr] = message.text + await message.delete() + source_message_id.pop(usr) + await bot_msg.edit(Presets.SOURCE_CONFIRM.format(source_chat[usr])) + await asyncio.sleep(2) + await start_bot(client, message) + return + else: + await client.delete_messages(message.chat.id, source_message_id[usr]) + warn = await message.reply_text(Presets.INVALID_CHAT_ID) + await message.delete() + source_message_id.pop(usr) + await asyncio.sleep(3) + await warn.delete() + await start_bot(client, message) + return except Exception: if message.reply_to_message.message_id == dest_message_id[usr]: if str(message.text).startswith('-100') and message.text[1:].isdigit(): diff --git a/presets.py b/presets.py index a237e0c..7c1ed35 100644 --- a/presets.py +++ b/presets.py @@ -22,7 +22,7 @@ class Presets(object): โžก๏ธ ๐‰๐จ๐ข๐ง ๐ญ๐ก๐ž ๐๐ž๐ฌ๐ญ๐ข๐ง๐š๐ญ๐ข๐จ๐ง ๐œ๐ก๐š๐ญ ๐š๐ฌ ๐š๐๐ฆ๐ข๐ง โžก๏ธ ๐๐จ๐ญ ๐๐จ๐ž๐ฌ๐ง'๐ญ ๐ง๐ž๐ž๐ ๐ญ๐จ ๐›๐ž ๐ข๐ง ๐›๐จ๐ญ๐ก ๐œ๐ก๐š๐ญ๐ฌ. โžก๏ธ ๐’๐ญ๐š๐ซ๐ญ ๐ญ๐ก๐ž ๐›๐จ๐ญ -โžก๏ธ ๐ˆ๐ง๐ฉ๐ฎ๐ญ ๐’๐จ๐ฎ๐ซ๐œ๐ž & ๐ƒ๐ž๐ฌ๐ญ๐ข๐ง๐š๐ญ๐ข๐จ๐ง ๐œ๐ก๐š๐ญ๐ฌ +โžก๏ธ ๐ˆ๐ง๐ฉ๐ฎ๐ญ ๐’๐จ๐ฎ๐ซ๐œ๐ž & ๐ƒ๐ž๐ฌ๐ญ๐ข๐ง๐š๐ญ๐ข๐จ๐ง ๐œ๐ก๐š๐ญ๐ฌ : ๐‘ข๐‘ ๐‘’ '@๐‘๐‘ฆ๐‘กโ„Ž๐‘œ๐‘›' ๐‘™๐‘–๐‘˜๐‘’ ๐‘ข๐‘ ๐‘’๐‘Ÿ ๐‘›๐‘Ž๐‘š๐‘’ ๐‘“๐‘œ๐‘Ÿ ๐‘๐‘ข๐‘๐‘™๐‘–๐‘ ๐‘โ„Ž๐‘Ž๐‘ก๐‘  โžก๏ธ ๐‘๐ฎ๐ง ๐‚๐ฅ๐จ๐ง๐ž ๐‘€๐“Ž ๐“‡๐‘’๐“…๐‘œ ๐’ธ๐’ถ๐“ƒ ๐’ท๐‘’ ๐“ˆ๐‘’๐‘’ (โฆฟโ€ฟโฆฟ) ๐™ƒ๐™š๐™ง๐™š