randydev commited on
Commit
bb78f77
Β·
verified Β·
1 Parent(s): 2dee48c

Update chatbot/plugins/join_request.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/join_request.py +18 -2
chatbot/plugins/join_request.py CHANGED
@@ -98,6 +98,7 @@ async def join_request(client: Client, event: ChatJoinRequest):
98
  captcha_text, img_path, choices = generate_captcha_multiple_choice()
99
  captcha_texts[event.from_user.id] = captcha_text
100
  captcha_texts["chat_id"] = event.chat.id
 
101
  keyboard = InlineKeyboardMarkup(
102
  [
103
  [InlineKeyboardButton(choice, callback_data=f"verify_{event.from_user.id}_{choice}")]
@@ -138,6 +139,18 @@ async def cancel_captcha_callback(client: Client, cb: CallbackQuery):
138
  else:
139
  await cb.answer("No active CAPTCHA verification found.", show_alert=True)
140
 
 
 
 
 
 
 
 
 
 
 
 
 
141
  @Client.on_callback_query(filters.regex("^refresh_captcha$"))
142
  async def refresh_captcha_callback(client: Client, cb: CallbackQuery):
143
  user_id = cb.from_user.id
@@ -178,7 +191,10 @@ async def verify_captcha_multiple_choice_callback(client: Client, cb: CallbackQu
178
  correct_captcha = captcha_texts.get(user_id)
179
  logger.info(f"User {user_id} selected CAPTCHA: {user_choice} (Expected: {correct_captcha})")
180
  if user_choice == correct_captcha:
181
- await cb.edit_message_text("βœ… CAPTCHA verification successful!")
 
 
 
182
  logger.info(f"User {user_id} successfully verified CAPTCHA.")
183
  await client.approve_chat_join_request(
184
  chat_id=captcha_texts.get("chat_id"),
@@ -205,4 +221,4 @@ async def verify_captcha_callback(client: Client, cb: CallbackQuery):
205
  return
206
  await cb.message.reply_text("πŸ” **Please enter the CAPTCHA text exactly as shown in the image:**")
207
  await cb.answer()
208
- logger.info(f"User {user_id} is attempting to verify CAPTCHA.")
 
98
  captcha_text, img_path, choices = generate_captcha_multiple_choice()
99
  captcha_texts[event.from_user.id] = captcha_text
100
  captcha_texts["chat_id"] = event.chat.id
101
+ captcha_texts["username"] = event.from_user.username
102
  keyboard = InlineKeyboardMarkup(
103
  [
104
  [InlineKeyboardButton(choice, callback_data=f"verify_{event.from_user.id}_{choice}")]
 
139
  else:
140
  await cb.answer("No active CAPTCHA verification found.", show_alert=True)
141
 
142
+ @Client.on_callback_query(filters.regex("^close$"))
143
+ async def close_final(client: Client, cb: CallbackQuery):
144
+ await cb.message.delete()
145
+
146
+ def create_button_join_group(username):
147
+ return InlineKeyboardMarkup(
148
+ [
149
+ [InlineKeyboardButton("πŸ”˜ Close", callback_data="close")],
150
+ [InlineKeyboardButton("πŸ‘οΈ Join chat", url=f"https://t.me/{username}")],
151
+ ]
152
+ )
153
+
154
  @Client.on_callback_query(filters.regex("^refresh_captcha$"))
155
  async def refresh_captcha_callback(client: Client, cb: CallbackQuery):
156
  user_id = cb.from_user.id
 
191
  correct_captcha = captcha_texts.get(user_id)
192
  logger.info(f"User {user_id} selected CAPTCHA: {user_choice} (Expected: {correct_captcha})")
193
  if user_choice == correct_captcha:
194
+ await cb.edit_message_text(
195
+ "βœ… CAPTCHA verification successful!",
196
+ reply_markup=create_button_join_group(captcha_texts.get("username"))
197
+ )
198
  logger.info(f"User {user_id} successfully verified CAPTCHA.")
199
  await client.approve_chat_join_request(
200
  chat_id=captcha_texts.get("chat_id"),
 
221
  return
222
  await cb.message.reply_text("πŸ” **Please enter the CAPTCHA text exactly as shown in the image:**")
223
  await cb.answer()
224
+ logger.info(f"User {user_id} is attempting to verify CAPTCHA.")