Skip to content

Commit 471b508

Browse files
authored
Added Link option when batch command works
1 parent b34c1a8 commit 471b508

File tree

1 file changed

+48
-7
lines changed

1 file changed

+48
-7
lines changed

plugins/link_generator.py

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import re
12
from pyrogram import Client, filters
23
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
34
from bot import Bot
@@ -8,26 +9,66 @@
89
async def batch(client: Client, message: Message):
910
while True:
1011
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)
1213
except:
1314
return
1415
if first_message.forward_from_chat:
1516
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
1718
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+
2041
while True:
2142
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)
2344
except:
2445
return
2546
if second_message.forward_from_chat:
2647
if second_message.forward_from_chat.id == client.db_channel.id:
2748
s_msg_id = second_message.forward_from_message_id
2849
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+
3172

3273
string = f"get-{f_msg_id * abs(client.db_channel.id)}-{s_msg_id * abs(client.db_channel.id)}"
3374
base64_string = await encode(string)

0 commit comments

Comments
 (0)