-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathforcesubscribe.py
More file actions
46 lines (38 loc) · 1.79 KB
/
forcesubscribe.py
File metadata and controls
46 lines (38 loc) · 1.79 KB
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
# Don't Remove Credit Tg - @VJ_Botz
# Subscribe YouTube Channel For Amazing Bot https://youtube.com/@Tech_VJ
# Ask Doubt on telegram @KingVJ01
# info.py / config.py / vars.py file..
import re
from os import environ
id_pattern = re.compile(r'^.\d+$')
AUTH_CHANNEL = [int(ch) if id_pattern.search(ch) else ch for ch in environ.get('AUTH_CHANNEL', '').split()] # give channel id with seperate space. Ex : ('-10073828 -102782829 -1007282828')
# force subscribe main code :-
from info import AUTH_CHANNEL
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.errors import *
async def is_subscribed(bot, query, channel):
btn = []
for id in channel:
chat = await bot.get_chat(int(id))
try:
await bot.get_chat_member(id, query.from_user.id)
except UserNotParticipant:
btn.append([InlineKeyboardButton(f'Join {chat.title}', url=chat.invite_link)])
except Exception as e:
pass
return btn
#@Client.on_message.....
#async def start(....
if AUTH_CHANNEL:
try:
btn = await is_subscribed(client, message, AUTH_CHANNEL)
if btn:
username = (await client.get_me()).username
if message.command[1]:
btn.append([InlineKeyboardButton("♻️ Try Again ♻️", url=f"https://t.me/{username}?start={message.command[1]}")])
else:
btn.append([InlineKeyboardButton("♻️ Try Again ♻️", url=f"https://t.me/{username}?start=true")])
await message.reply_text(text=f"<b>👋 Hello {message.from_user.mention},\n\nPlease join the channel then click on try again button. 😇</b>", reply_markup=InlineKeyboardMarkup(btn))
return
except Exception as e:
print(e)