-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathforcesub.py
54 lines (51 loc) · 2.3 KB
/
forcesub.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
# (c) @AbirHasan2005
import asyncio
from configs import Config
from pyrogram import Client
from pyrogram.errors import FloodWait, UserNotParticipant
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message
async def ForceSub(bot: Client, cmd: Message):
try:
invite_link = await bot.create_chat_invite_link(chat_id=(int(Config.UPDATES_CHANNEL) if Config.UPDATES_CHANNEL.startswith("-100") else Config.UPDATES_CHANNEL))
except FloodWait as e:
await asyncio.sleep(e.x)
invite_link = await bot.create_chat_invite_link(chat_id=(int(Config.UPDATES_CHANNEL) if Config.UPDATES_CHANNEL.startswith("-100") else Config.UPDATES_CHANNEL))
except Exception as err:
print(f"Unable to do Force Subscribe to {Config.UPDATES_CHANNEL}\n\nError: {err}")
return 200
try:
user = await bot.get_chat_member(chat_id=(int(Config.UPDATES_CHANNEL) if Config.UPDATES_CHANNEL.startswith("-100") else Config.UPDATES_CHANNEL), user_id=cmd.from_user.id)
if user.status == "kicked":
await bot.send_message(
chat_id=cmd.from_user.id,
text="Sorry Sir, You are Banned to use me. Contact my [Support Group](https://t.me/linux_repo).",
parse_mode="markdown",
disable_web_page_preview=True
)
return 400
except UserNotParticipant:
await bot.send_message(
chat_id=cmd.from_user.id,
text="**Please Join My Updates Channel to use this Bot!**\n\nDue to Overload, Only Channel Subscribers can use the Bot!",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🤖 Join Updates Channel", url=invite_link.invite_link)
],
[
InlineKeyboardButton("🔄 Refresh 🔄", callback_data="refreshFsub")
]
]
),
parse_mode="markdown"
)
return 400
except Exception:
await bot.send_message(
chat_id=cmd.from_user.id,
text="Something went Wrong. Contact my [Support Group](https://t.me/linux_repo).",
parse_mode="markdown",
disable_web_page_preview=True
)
return 400
return 200