Skip to content

Commit 2035bc5

Browse files
authored
Create channel_post.py
1 parent 2d646fe commit 2035bc5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

plugins/channel_post.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import asyncio
2+
from pyrogram import filters, Client
3+
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
4+
from pyrogram.errors import FloodWait
5+
6+
from bot import Bot
7+
from config import ADMINS, CHANNEL_ID
8+
from helper_func import encode
9+
10+
@Bot.on_message(filters.private & filters.user(ADMINS) & ~filters.command(['start','batch']))
11+
async def channel_post(client: Client, message: Message):
12+
reply_text = await message.reply_text("Please Wait...!", quote = True)
13+
try:
14+
post_message = await message.copy(chat_id = CHANNEL_ID, disable_notification=True)
15+
except FloodWait as e:
16+
await asyncio.sleep(e.x)
17+
post_message = await message.copy(chat_id = CHANNEL_ID, disable_notification=True)
18+
except Exception as e:
19+
print(e)
20+
await reply_text.edit_text("Something went Wrong..!")
21+
return
22+
converted_id = post_message.message_id * abs(CHANNEL_ID)
23+
string = f"get-{converted_id}"
24+
base64_string = await encode(string)
25+
link = f"https://t.me/{client.username}?start={base64_string}"
26+
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔁 Share URL", url=f'https://telegram.me/share/url?url={link}')]])
27+
await reply_text.edit(f"<b>Here is your link</b>\n\n{link}", reply_markup=reply_markup, disable_web_page_preview = True)

0 commit comments

Comments
 (0)