Added get whitelist command

This commit is contained in:
BarsTiger
2023-05-06 15:06:56 +03:00
parent 892fd3841f
commit f3c372fa8f
3 changed files with 17 additions and 3 deletions

View File

@@ -12,4 +12,5 @@ def register():
dp.register_message_handler(aliases.remove_admin, commands='rmadmin')
dp.register_message_handler(aliases.add_whitelist, commands='addwhitelist')
dp.register_message_handler(aliases.remove_whitelist, commands='rmwhitelist')
dp.register_message_handler(aliases.get_whitelist, commands='getwhitelist')
dp.register_message_handler(tools.hash_command, commands='hash')

View File

@@ -23,6 +23,7 @@ async def set_endpoint(message: types.Message, is_command: bool = True):
await message.reply("✅ New url set")
@throttle(5)
async def add_whitelist(message: types.Message, is_command: bool = True):
if message.from_id != ADMIN:
@@ -57,6 +58,7 @@ async def add_whitelist(message: types.Message, is_command: bool = True):
await message.reply("✅ Added whitelist")
@throttle(5)
async def remove_whitelist(message: types.Message, is_command: bool = True):
if message.from_id != ADMIN:
@@ -64,7 +66,7 @@ async def remove_whitelist(message: types.Message, is_command: bool = True):
return
if not (message.get_args() if is_command else message.text).isdecimal() and not \
hasattr(message.reply_to_message, 'text') and (message.chat.id >= 0:
hasattr(message.reply_to_message, 'text') and (message.chat.id) >= 0:
await message.reply('❌ Put whitelist ID to command arguments or answer to users message')
return
elif not (message.get_args() if is_command else message.text).isdecimal() and not \
@@ -92,6 +94,16 @@ async def remove_whitelist(message: types.Message, is_command: bool = True):
await message.reply("✅ Removed whitelist")
@throttle(5)
async def get_whitelist(message: types.Message, is_command: bool = True):
if message.from_id != ADMIN:
await message.reply('❌ You are not permitted to do that. It is only for main admin')
return
await message.reply(f"✅ Whitelisted ids: {db[DBTables.config].get('whitelist')}"
if db[DBTables.config].get('whitelist') else
'❌ Whitelist is disabled. Everyone can use the bot. Add someone to whitelist to enable it')
@throttle(5)
async def add_admin(message: types.Message, is_command: bool = True):