randydev commited on
Commit
94c7f54
·
verified ·
1 Parent(s): 4b4237c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +28 -23
main.py CHANGED
@@ -53,31 +53,32 @@ api = ak.PornoHub(key=API_KEY)
53
 
54
  not_allowed = ["hi", "hello", "hey", "hai", "help"]
55
 
56
- @Client.on_message(filters.incoming & filters.private)
57
  async def must_join_channel(bot: Client, msg: Message):
58
  MUST_JOIN = "RendyProjects"
 
 
59
  try:
60
- if not await check_membership(MUST_JOIN, bot, msg):
61
- force_button = InlineKeyboardMarkup(
62
- [
63
- [
64
- InlineKeyboardButton(
65
- text="Rendy Projects",
66
- url=f"https://t.me/{MUST_JOIN}"
67
- )
68
- ]
69
- ]
70
- )
71
- mention = msg.from_user.mention if msg.from_user else ""
72
- user_id = msg.from_user.id if msg.from_user else 0
73
- await msg.delete()
74
- await msg.reply(
75
- f"Hey {mention}\n⚠️ To use this bot you have to <b>subscribe to our channel</b>",
76
- disable_web_page_preview=True,
77
- reply_markup=force_button
78
- )
79
- await msg.stop_propagation()
80
- except Exception:
81
  pass
82
 
83
  async def check_membership(channel_id, bot, msg):
@@ -107,7 +108,11 @@ async def check_membership(channel_id, bot, msg):
107
  except UserNotParticipant:
108
  return False
109
 
110
- @client.on_message(filters.command("start") & filters.private)
 
 
 
 
111
  async def welcome_start(client: Client, message: Message):
112
  keyboard = InlineKeyboardMarkup(
113
  [
 
53
 
54
  not_allowed = ["hi", "hello", "hey", "hai", "help"]
55
 
56
+ @Client.on_message(filters.incoming & filters.private, group=-1)
57
  async def must_join_channel(bot: Client, msg: Message):
58
  MUST_JOIN = "RendyProjects"
59
+ if not MUST_JOIN:
60
+ return
61
  try:
62
+ try:
63
+ await bot.get_chat_member(MUST_JOIN, msg.from_user.id)
64
+ except UserNotParticipant:
65
+ if MUST_JOIN.isalpha():
66
+ link = "https://t.me/" + MUST_JOIN
67
+ else:
68
+ chat_info = await bot.get_chat(MUST_JOIN)
69
+ link = chat_info.invite_link
70
+ try:
71
+ await msg.reply(
72
+ f"You must join [this channel]({link}) to use me. After joining try again !",
73
+ disable_web_page_preview=True,
74
+ reply_markup=InlineKeyboardMarkup([
75
+ [InlineKeyboardButton("Join Channel", url=link)]
76
+ ])
77
+ )
78
+ await msg.stop_propagation()
79
+ except ChatWriteForbidden:
80
+ pass
81
+ except ChatAdminRequired:
 
82
  pass
83
 
84
  async def check_membership(channel_id, bot, msg):
 
108
  except UserNotParticipant:
109
  return False
110
 
111
+ @client.on_message(
112
+ filters.incoming
113
+ & filters.command("start")
114
+ & filters.private
115
+ )
116
  async def welcome_start(client: Client, message: Message):
117
  keyboard = InlineKeyboardMarkup(
118
  [