Spaces:
Running
Running
taslim19
commited on
Commit
·
39a9010
1
Parent(s):
54ef848
feat: Add checkban command for owner to check and unban themselves
Browse files
DragMusic/plugins/tools/dev.py
CHANGED
|
@@ -11,7 +11,8 @@ from pyrogram import filters
|
|
| 11 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery
|
| 12 |
|
| 13 |
from DragMusic import app
|
| 14 |
-
from config import OWNER_ID
|
|
|
|
| 15 |
|
| 16 |
|
| 17 |
async def aexec(code, client, message):
|
|
@@ -113,3 +114,28 @@ async def close_command(_, CallbackQuery: CallbackQuery):
|
|
| 113 |
|
| 114 |
await CallbackQuery.message.delete()
|
| 115 |
await CallbackQuery.answer()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery
|
| 12 |
|
| 13 |
from DragMusic import app
|
| 14 |
+
from config import OWNER_ID, BANNED_USERS
|
| 15 |
+
from DragMusic.utils.database import is_banned_user, remove_banned_user, is_gbanned_user, remove_gban_user
|
| 16 |
|
| 17 |
|
| 18 |
async def aexec(code, client, message):
|
|
|
|
| 114 |
|
| 115 |
await CallbackQuery.message.delete()
|
| 116 |
await CallbackQuery.answer()
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
@app.on_message(filters.command("checkban") & filters.user(OWNER_ID))
|
| 120 |
+
async def check_ban_status(client, message):
|
| 121 |
+
"""Check if owner is banned and unban if needed."""
|
| 122 |
+
user_id = message.from_user.id
|
| 123 |
+
|
| 124 |
+
# Check if user is banned locally
|
| 125 |
+
is_banned = await is_banned_user(user_id)
|
| 126 |
+
# Check if user is globally banned
|
| 127 |
+
is_gbanned = await is_gbanned_user(user_id)
|
| 128 |
+
|
| 129 |
+
if is_banned:
|
| 130 |
+
await remove_banned_user(user_id)
|
| 131 |
+
await message.reply_text("✅ You were locally banned. You have been unbanned.")
|
| 132 |
+
elif is_gbanned:
|
| 133 |
+
await remove_gban_user(user_id)
|
| 134 |
+
await message.reply_text("✅ You were globally banned. You have been unbanned.")
|
| 135 |
+
else:
|
| 136 |
+
await message.reply_text("✅ You are not banned.")
|
| 137 |
+
|
| 138 |
+
# Also remove from BANNED_USERS set if present
|
| 139 |
+
if user_id in BANNED_USERS:
|
| 140 |
+
BANNED_USERS.remove(user_id)
|
| 141 |
+
await message.reply_text("✅ Removed from BANNED_USERS set.")
|