MCPcopy Create free account
hub / github.com/VJBots/VJ-File-Store / gen_link_batch

Function gen_link_batch

plugins/genlink.py:86–179  ·  view source on GitHub ↗
(bot, message)

Source from the content-addressed store, hash-verified

84
85@Client.on_message(filters.command(['batch']) & filters.create(allowed))
86async def gen_link_batch(bot, message):
87 username = (await bot.get_me()).username
88 if " " not in message.text:
89 return await message.reply("Use correct format.\nExample /batch https://t.me/vj_botz/10 https://t.me/vj_botz/20.")
90 links = message.text.strip().split(" ")
91 if len(links) != 3:
92 return await message.reply("Use correct format.\nExample /batch https://t.me/vj_botz/10 https://t.me/vj_botz/20.")
93 cmd, first, last = links
94 regex = re.compile("(https://)?(t\.me/|telegram\.me/|telegram\.dog/)(c/)?(\d+|[a-zA-Z_0-9]+)/(\d+)$")
95 match = regex.match(first)
96 if not match:
97 return await message.reply('Invalid link')
98 f_chat_id = match.group(4)
99 f_msg_id = int(match.group(5))
100 if f_chat_id.isnumeric():
101 f_chat_id = int(("-100" + f_chat_id))
102
103# Don't Remove Credit Tg - @VJ_Bots
104# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ
105# Ask Doubt on telegram @KingVJ01
106
107 match = regex.match(last)
108 if not match:
109 return await message.reply('Invalid link')
110 l_chat_id = match.group(4)
111 l_msg_id = int(match.group(5))
112 if l_chat_id.isnumeric():
113 l_chat_id = int(("-100" + l_chat_id))
114
115 if f_chat_id != l_chat_id:
116 return await message.reply("Chat ids not matched.")
117 try:
118 chat_id = (await bot.get_chat(f_chat_id)).id
119 except ChannelInvalid:
120 return await message.reply('This may be a private channel / group. Make me an admin over there to index the files.')
121 except (UsernameInvalid, UsernameNotModified):
122 return await message.reply('Invalid Link specified.')
123 except Exception as e:
124 return await message.reply(f'Errors - {e}')
125
126# Don't Remove Credit Tg - @VJ_Bots
127# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ
128# Ask Doubt on telegram @KingVJ01
129
130 sts = await message.reply("**ɢᴇɴᴇʀᴀᴛɪɴɢ ʟɪɴᴋ ғᴏʀ ʏᴏᴜʀ ᴍᴇssᴀɢᴇ**.\n**ᴛʜɪs ᴍᴀʏ ᴛᴀᴋᴇ ᴛɪᴍᴇ ᴅᴇᴘᴇɴᴅɪɴɢ ᴜᴘᴏɴ ɴᴜᴍʙᴇʀ ᴏғ ᴍᴇssᴀɢᴇs**")
131
132 FRMT = "**ɢᴇɴᴇʀᴀᴛɪɴɢ ʟɪɴᴋ...**\n**ᴛᴏᴛᴀʟ ᴍᴇssᴀɢᴇs:** {total}\n**ᴅᴏɴᴇ:** {current}\n**ʀᴇᴍᴀɪɴɪɴɢ:** {rem}\n**sᴛᴀᴛᴜs:** {sts}"
133
134 outlist = []
135
136# Don't Remove Credit Tg - @VJ_Bots
137# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ
138# Ask Doubt on telegram @KingVJ01
139
140 # file store without db channel
141 og_msg = 0
142 tot = 0
143 async for msg in bot.iter_messages(f_chat_id, l_msg_id, f_msg_id):

Callers

nothing calls this directly

Calls 3

get_userFunction · 0.90
get_short_linkFunction · 0.90
iter_messagesMethod · 0.80

Tested by

no test coverage detected