MCPcopy Index your code
hub / github.com/CodeXBotz/File-Sharing-Bot / channel_post

Function channel_post

plugins/channel_post.py:13–34  ·  view source on GitHub ↗
(client: Client, message: Message)

Source from the content-addressed store, hash-verified

11
12@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','users','broadcast','batch','genlink','stats']))
13async def channel_post(client: Client, message: Message):
14 reply_text = await message.reply_text("Please Wait...!", quote = True)
15 try:
16 post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True)
17 except FloodWait as e:
18 await asyncio.sleep(e.x)
19 post_message = await message.copy(chat_id = client.db_channel.id, disable_notification=True)
20 except Exception as e:
21 print(e)
22 await reply_text.edit_text("Something went Wrong..!")
23 return
24 converted_id = post_message.id * abs(client.db_channel.id)
25 string = f"get-{converted_id}"
26 base64_string = await encode(string)
27 link = f"https://t.me/{client.username}?start={base64_string}"
28
29 reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
30
31 await reply_text.edit(f"<b>Here is your link</b>\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True)
32
33 if not DISABLE_CHANNEL_BUTTON:
34 await post_message.edit_reply_markup(reply_markup)
35
36@Bot.on_message(filters.channel & filters.incoming & filters.chat(CHANNEL_ID))
37async def new_post(client: Client, message: Message):

Callers

nothing calls this directly

Calls 1

encodeFunction · 0.90

Tested by

no test coverage detected