Quellcode durchsuchen

Adding unlock all (#126)

* formatting moment

* Update locks.py
Aarav Arora vor 5 Jahren
Ursprung
Commit
70a2764332
2 geänderte Dateien mit 17 neuen und 5 gelöschten Zeilen
  1. 11 1
      wbb/modules/locks.py
  2. 6 4
      wbb/modules/sudo.py

+ 11 - 1
wbb/modules/locks.py

@@ -115,7 +115,17 @@ async def locks_func(_, message):
         await app.set_chat_permissions(chat_id, ChatPermissions())
         await message.reply_text("Locked Everything.")
 
-
+    elif parameter == "all" and state == "unlock":
+        await app.set_chat_permissions(
+         chat_id,
+         ChatPermissions(
+            can_send_messages=True,
+            can_send_media_messages=True,
+            can_send_stickers=True,
+            can_send_animations=True,
+            can_invite_users=True
+                        )
+                                 )
 @app.on_message(filters.command("locks") & ~filters.private)
 @capture_err
 async def locktypes(_, message):

+ 6 - 4
wbb/modules/sudo.py

@@ -56,9 +56,10 @@ async def useradd(_, message: Message):
             text="Reply to someone's message to add him to sudoers.",
         )
     user_id = message.reply_to_message.from_user.id
+    umention = (await app2.get_users(user_id)).mention
     sudoers = await get_sudoers()
     if user_id in sudoers:
-        return await eor(message, text="User is already in sudoers.")
+        return await eor(message, text=f"{umention} is already in sudoers.")
     if user_id == BOT_ID:
         return await eor(
             message, text="You can't add assistant bot in sudoers."
@@ -67,7 +68,7 @@ async def useradd(_, message: Message):
     if added:
         await eor(
             message,
-            text="Successfully added user in sudoers, Bot will be restarted now.",
+            text=f"Successfully added {umention} in sudoers, Bot will be restarted now.",
         )
         return await restart(None)
     await eor(message, text="Something wrong happened, check logs.")
@@ -84,13 +85,14 @@ async def userdel(_, message: Message):
             text="Reply to someone's message to remove him to sudoers.",
         )
     user_id = message.reply_to_message.from_user.id
+    umention = (await app2.get_users(user_id)).mention
     if user_id not in await get_sudoers():
-        return await eor(message, text="User is not in sudoers.")
+        return await eor(message, text=f"{umention} is not in sudoers.")
     removed = await remove_sudo(user_id)
     if removed:
         await eor(
             message,
-            text="Successfully removed user from sudoers, Bot will be restarted now.",
+            text=f"Successfully removed {umention} from sudoers, Bot will be restarted now.",
         )
         return await restart(None)
     await eor(message, text="Something wrong happened, check logs.")