forked from mrismanaziz/File-Sharing-Man
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel_post.py
87 lines (75 loc) · 2.55 KB
/
channel_post.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# (©)Codexbotz
# Recode by @mrismanaziz
# t.me/SharingUserbot & t.me/Lunatic0de
import asyncio
from pyrogram import Client, filters
from pyrogram.errors import FloodWait
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message
from bot import Bot
from config import ADMINS, CHANNEL_ID, DISABLE_CHANNEL_BUTTON
from helper_func import encode
@Bot.on_message(
filters.private
& filters.user(ADMINS)
& ~filters.command(
["start", "users", "broadcast", "ping", "uptime", "batch", "genlink"]
)
)
async def channel_post(client: Client, message: Message):
reply_text = await message.reply_text("<code>Tunggu Sebentar...</code>", quote=True)
try:
post_message = await message.copy(
chat_id=client.db_channel.id, disable_notification=True
)
except FloodWait as e:
await asyncio.sleep(e.x)
post_message = await message.copy(
chat_id=client.db_channel.id, disable_notification=True
)
except Exception as e:
print(e)
await reply_text.edit_text("<b>Telah Terjadi Error...</b>")
return
converted_id = post_message.message_id * abs(client.db_channel.id)
string = f"get-{converted_id}"
base64_string = await encode(string)
link = f"https://t.me/{client.username}?start={base64_string}"
reply_markup = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"🔁 Share Link", url=f"https://telegram.me/share/url?url={link}"
)
]
]
)
await reply_text.edit(
f"<b>Link Sharing File Berhasil Di Buat :</b>\n\n{link}",
reply_markup=reply_markup,
disable_web_page_preview=True,
)
if not DISABLE_CHANNEL_BUTTON:
await post_message.edit_reply_markup(reply_markup)
@Bot.on_message(
filters.channel & filters.incoming & filters.chat(CHANNEL_ID) & ~filters.edited
)
async def new_post(client: Client, message: Message):
if DISABLE_CHANNEL_BUTTON:
return
converted_id = message.message_id * abs(client.db_channel.id)
string = f"get-{converted_id}"
base64_string = await encode(string)
link = f"https://t.me/{client.username}?start={base64_string}"
reply_markup = InlineKeyboardMarkup(
[
[
InlineKeyboardButton(
"🔁 Share Link", url=f"https://telegram.me/share/url?url={link}"
)
]
]
)
try:
await message.edit_reply_markup(reply_markup)
except Exception as e:
print(e)