TheHamkerCat 5 лет назад
Родитель
Сommit
f1519605d3
1 измененных файлов с 3 добавлено и 24 удалено
  1. 3 24
      wbb/modules/greetings.py

+ 3 - 24
wbb/modules/greetings.py

@@ -1,14 +1,8 @@
 """
 """
  Thanks to @dashezup for this module
  Thanks to @dashezup for this module
  Repo - https://github.com/dashezup/tgbot
  Repo - https://github.com/dashezup/tgbot
-
-A Pyrogram Smart Plugin to verify if new members are human
-# the bot must be admin in the chat
-# should not be lesser than 30 or the user may be banned if he didn't
-# press the verification button
 """
 """
 
 
-
 import asyncio
 import asyncio
 from datetime import datetime
 from datetime import datetime
 from pyrogram import filters
 from pyrogram import filters
@@ -32,13 +26,7 @@ async def welcome(_, message: Message):
         text = (f"Welcome, {(member.mention())}\n**Are you human?**\n"
         text = (f"Welcome, {(member.mention())}\n**Are you human?**\n"
                 "You will be removed from this chat if you are not verified "
                 "You will be removed from this chat if you are not verified "
                 f"in {WELCOME_DELAY_KICK_SEC} seconds")
                 f"in {WELCOME_DELAY_KICK_SEC} seconds")
-        await message.chat.promote_member(user_id=member.id, can_post_messages=False)
-        #await message.chat.restrict_member(member.id, ChatPermissions())
-        user = await app.get_users(member.id)
-        name_length = len(str(user.first_name) + str(user.last_name))
-        if name_length > 50:
-            await message.reply_text("[ERROR: MAX_NAME_LENGH_EXCEEDED]: Your Name Is Too Long And Weird, Change It!")
-
+        await message.chat.restrict_member(member.id, ChatPermissions())
         button_message = await message.reply(
         button_message = await message.reply(
             text,
             text,
             reply_markup=InlineKeyboardMarkup(
             reply_markup=InlineKeyboardMarkup(
@@ -46,7 +34,6 @@ async def welcome(_, message: Message):
                     [
                     [
                         InlineKeyboardButton(
                         InlineKeyboardButton(
                             "Press Here to Verify",
                             "Press Here to Verify",
-                            # According to the docs, the user can send arbitrary data in this field, yet, I'm not able to do so, so until there's a db to pass data, imma use it like this so it will be very easy to change it to use a db in the future
                             callback_data="pressed_button {}".format(member.id)
                             callback_data="pressed_button {}".format(member.id)
                         )
                         )
                     ]
                     ]
@@ -54,9 +41,6 @@ async def welcome(_, message: Message):
             ),
             ),
             quote=True
             quote=True
         )
         )
-        # await message.reply_animation("CgACAgQAAx0CWIlO9AABATjjYBrlKqQID0SQ7Ey7bkVRKM5gNn8AAl8CAAIm39VRHDx6EoKU6W0eBA")
-        # wtf is this? "file_id is unique for each individual bot and can't be transferred from one bot to another." source: https://core.telegram.org/bots/api#sending-files
-        # and here is the error I just received -- pyrogram.errors.exceptions.bad_request_400.MediaEmpty: [400 MEDIA_EMPTY]: The media you tried to send is invalid (caused by "messages.SendMedia")
         asyncio.create_task(kick_restricted_after_delay(
         asyncio.create_task(kick_restricted_after_delay(
             WELCOME_DELAY_KICK_SEC, button_message, member))
             WELCOME_DELAY_KICK_SEC, button_message, member))
         await asyncio.sleep(0.5)
         await asyncio.sleep(0.5)
@@ -68,21 +52,16 @@ async def callback_query_welcome_button(client, callback_query):
     chat permissions, delete button message and join message
     chat permissions, delete button message and join message
     """
     """
     button_message = callback_query.message
     button_message = callback_query.message
-    pending_user = await client.get_users(int(callback_query.data.replace('pressed_button ', '')))
+    pending_user = await app.get_users(int(callback_query.data.replace('pressed_button ', '')))
     pressed_user_id = callback_query.from_user.id
     pressed_user_id = callback_query.from_user.id
     pending_user_id = pending_user.id
     pending_user_id = pending_user.id
     if pending_user_id == pressed_user_id:
     if pending_user_id == pressed_user_id:
-        await callback_query.answer("Congrats, captcha passed!")
+        await callback_query.answer("Captcha passed!, Have a nice stay.")
         await button_message.chat.unban_member(pending_user_id)
         await button_message.chat.unban_member(pending_user_id)
         await button_message.delete()
         await button_message.delete()
     else:
     else:
         await callback_query.answer("This is not for you")
         await callback_query.answer("This is not for you")
 
 
-# This code is really dumb
-# If anyone is interested, we should use threads and kill them when the user has verified himself.
-# Also, once there's a db, we should save this data and re-create the threads in case the bot crashed, tho pyrogram doesn't support history messages (obviously)
-# so in such a case we may lose data anyway
-
 
 
 async def kick_restricted_after_delay(delay, button_message: Message, user: User):
 async def kick_restricted_after_delay(delay, button_message: Message, user: User):
     """If the new member is still restricted after the delay, delete
     """If the new member is still restricted after the delay, delete