MCPcopy Create free account
hub / github.com/VJBots/VJ-Forward-Bot / unequify

Function unequify

plugins/unequeify.py:73–149  ·  view source on GitHub ↗
(client, message)

Source from the content-addressed store, hash-verified

71
72@Client.on_message(filters.command("unequify") & filters.private)
73async def unequify(client, message):
74 user_id = message.from_user.id
75 temp.CANCEL[user_id] = False
76 if temp.lock.get(user_id) and str(temp.lock.get(user_id))=="True":
77 return await message.reply("**please wait until previous task complete**")
78 _bot = await db.get_userbot(user_id)
79 if not _bot:
80 return await message.reply("<b>Need userbot to do this process. Please add a userbot using /settings</b>")
81 target = await client.ask(user_id, text="**Forward the last message from target chat or send last message link.**\n/cancel - `cancel this process`")
82 if target.text and target.text.startswith("/"):
83 return await message.reply("**process cancelled !**")
84 elif target.text:
85 regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")
86 match = regex.match(target.text.replace("?single", ""))
87 if not match:
88 return await message.reply('**Invalid link**')
89 chat_id = match.group(4)
90 last_msg_id = int(match.group(5))
91 if chat_id.isnumeric():
92 chat_id = int(("-100" + chat_id))
93 elif target.forward_from_chat.type in [enums.ChatType.CHANNEL, 'supergroup']:
94 last_msg_id = target.forward_from_message_id
95 chat_id = target.forward_from_chat.username or target.forward_from_chat.id
96 else:
97 return await message.reply_text("**invalid !**")
98 confirm = await client.ask(user_id, text="**send /yes to start the process and /no to cancel this process**")
99 if confirm.text.lower() == '/no':
100 return await confirm.reply("**process cancelled !**")
101 sts = await confirm.reply("`processing..`")
102 il = False
103 data = _bot['session']
104 try:
105 bot = await get_client(data, is_bot=il)
106 await bot.start()
107 except Exception as e:
108 return await sts.edit(e)
109 try:
110 k = await bot.send_message(chat_id, text="testing")
111 await k.delete()
112 except:
113 await sts.edit(f"**please make your [userbot](t.me/{_bot['username']}) admin in target chat with full permissions**")
114 return await bot.stop()
115 MESSAGES = []
116 DUPLICATE = []
117 total=deleted=0
118 temp.lock[user_id] = True
119 temp.CANCEL[user_id] = False
120 try:
121 await sts.edit(Script.DUPLICATE_TEXT.format(total, deleted, "ᴘʀᴏɢʀᴇssɪɴɢ"), reply_markup=CANCEL_BTN)
122 async for message in bot.search_messages(chat_id=chat_id, filter=enums.MessagesFilter.DOCUMENT):
123 if temp.CANCEL.get(user_id) == True:
124 await sts.edit(Script.DUPLICATE_TEXT.format(total, deleted, "ᴄᴀɴᴄᴇʟʟᴇᴅ"), reply_markup=COMPLETED_BTN)
125 return await bot.stop()
126 file = message.document
127 file_id = unpack_new_file_id(file.file_id)
128 if file_id in MESSAGES:
129 DUPLICATE.append(message.id)
130 else:

Callers

nothing calls this directly

Calls 4

get_clientFunction · 0.85
unpack_new_file_idFunction · 0.85
getMethod · 0.80
get_userbotMethod · 0.80

Tested by

no test coverage detected