|
| 1 | +import re |
1 | 2 | from pyrogram import Client, filters |
2 | 3 | from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton |
3 | 4 | from bot import Bot |
|
8 | 9 | async def batch(client: Client, message: Message): |
9 | 10 | while True: |
10 | 11 | try: |
11 | | - first_message = await client.ask(text = "Forward the First Message from the DB Channel (with Quotes)..", chat_id = message.from_user.id, filters=filters.forwarded, timeout=30) |
| 12 | + first_message = await client.ask(text = "Forward the First Message from DB Channel (with Quotes)..\nor Send the Post Link", chat_id = message.from_user.id, filters=filters.forwarded, timeout=30) |
12 | 13 | except: |
13 | 14 | return |
14 | 15 | if first_message.forward_from_chat: |
15 | 16 | if first_message.forward_from_chat.id == client.db_channel.id: |
16 | | - f_msg_id = first_message.forward_from_message_id |
| 17 | + s_msg_id = first_message.forward_from_message_id |
17 | 18 | break |
18 | | - await first_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
19 | | - continue |
| 19 | + await first_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
| 20 | + continue |
| 21 | + elif first_message.forward_sender_name: |
| 22 | + await second_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
| 23 | + continue |
| 24 | + elif first_message.text: |
| 25 | + pattern = "https://t.me/(?:c/)?(.*)/(\d+)" |
| 26 | + matches = re.match(pattern,first_message.text) |
| 27 | + if not matches: |
| 28 | + await first_message.reply("This is not a Proper telegram post link", quote=True) |
| 29 | + continue |
| 30 | + channel_id = matches.group(1) |
| 31 | + s_msg_id = matches.group(2) |
| 32 | + if channel_id.isdigit(): |
| 33 | + if channel_id == client.db_channel.id |
| 34 | + break |
| 35 | + else: |
| 36 | + if channel_id == client.db_channel.username |
| 37 | + break |
| 38 | + await first_message.reply("Send the link of post from the db channel only", quote=True) |
| 39 | + continue |
| 40 | + |
20 | 41 | while True: |
21 | 42 | try: |
22 | | - second_message = await client.ask(text = "Forward the Last Message from DB Channel (with Quotes)..", chat_id = message.from_user.id, filters=filters.forwarded, timeout=30) |
| 43 | + second_message = await client.ask(text = "Forward the Last Message from DB Channel (with Quotes)..\nor Send the Post Link", chat_id = message.from_user.id, filters=filters.forwarded, timeout=30) |
23 | 44 | except: |
24 | 45 | return |
25 | 46 | if second_message.forward_from_chat: |
26 | 47 | if second_message.forward_from_chat.id == client.db_channel.id: |
27 | 48 | s_msg_id = second_message.forward_from_message_id |
28 | 49 | break |
29 | | - await second_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
30 | | - continue |
| 50 | + await second_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
| 51 | + continue |
| 52 | + elif second_message.forward_sender_name: |
| 53 | + await second_message.reply_text("Forward from the Assigned Channel only...", quote = True) |
| 54 | + continue |
| 55 | + elif second_message.text: |
| 56 | + pattern = "https://t.me/(?:c/)?(.*)/(\d+)" |
| 57 | + matches = re.match(pattern,text) |
| 58 | + if not matches: |
| 59 | + await second_message.reply("This is not a Proper telegram post link", quote=True) |
| 60 | + continue |
| 61 | + channel_id = matches.group(1) |
| 62 | + s_msg_id = matches.group(2) |
| 63 | + if channel_id.isdigit(): |
| 64 | + if channel_id == client.db_channel.id |
| 65 | + break |
| 66 | + else: |
| 67 | + if channel_id == client.db_channel.username |
| 68 | + break |
| 69 | + await second_message.reply("Send the link of post from the db channel only", quote=True) |
| 70 | + continue |
| 71 | + |
31 | 72 |
|
32 | 73 | string = f"get-{f_msg_id * abs(client.db_channel.id)}-{s_msg_id * abs(client.db_channel.id)}" |
33 | 74 | base64_string = await encode(string) |
|
0 commit comments