config command now works fully
This commit is contained in:
@@ -6,17 +6,18 @@ from bot.utils.cooldown import throttle
|
||||
|
||||
|
||||
@throttle(5)
|
||||
async def set_endpoint(message: types.Message):
|
||||
async def set_endpoint(message: types.Message, is_command: bool = True):
|
||||
if message.from_id not in db[DBTables.config].get('admins') and message.from_id != ADMIN:
|
||||
await message.reply('❌ You are not permitted to do that. '
|
||||
'It is only for this bot instance maintainers and admins')
|
||||
return
|
||||
|
||||
if not message.get_args() or not validators.url(message.get_args()):
|
||||
if not (message.get_args() if is_command else message.text) or not \
|
||||
validators.url((message.get_args() if is_command else message.text)):
|
||||
await message.reply("❌ Specify correct url for endpoint")
|
||||
return
|
||||
|
||||
db[DBTables.config]['endpoint'] = encrypt(message.get_args())
|
||||
db[DBTables.config]['endpoint'] = encrypt((message.get_args() if is_command else message.text))
|
||||
|
||||
await db[DBTables.config].write()
|
||||
|
||||
@@ -24,18 +25,19 @@ async def set_endpoint(message: types.Message):
|
||||
|
||||
|
||||
@throttle(5)
|
||||
async def add_admin(message: types.Message):
|
||||
async def add_admin(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
|
||||
|
||||
if not message.get_args().isdecimal() and not hasattr(message.reply_to_message, 'text'):
|
||||
if not (message.get_args() if is_command else message.text).isdecimal() and not \
|
||||
hasattr(message.reply_to_message, 'text'):
|
||||
await message.reply('❌ Put new admin ID to command arguments or answer to users message')
|
||||
return
|
||||
elif not message.get_args().isdecimal():
|
||||
elif not (message.get_args() if is_command else message.text).isdecimal():
|
||||
ID = message.reply_to_message.from_id
|
||||
elif not hasattr(message.reply_to_message, 'text'):
|
||||
ID = int(message.get_args())
|
||||
ID = int((message.get_args() if is_command else message.text))
|
||||
|
||||
if not isinstance(db[DBTables.config].get('admins'), list):
|
||||
db[DBTables.config]['admins'] = list()
|
||||
@@ -54,18 +56,19 @@ async def add_admin(message: types.Message):
|
||||
|
||||
|
||||
@throttle(5)
|
||||
async def remove_admin(message: types.Message):
|
||||
async def remove_admin(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
|
||||
|
||||
if not message.get_args().isdecimal() and not hasattr(message.reply_to_message, 'text'):
|
||||
if not (message.get_args() if is_command else message.text).isdecimal() and not \
|
||||
hasattr(message.reply_to_message, 'text'):
|
||||
await message.reply('❌ Put admin ID to command arguments or answer to users message')
|
||||
return
|
||||
elif not message.get_args().isdecimal():
|
||||
elif not (message.get_args() if is_command else message.text).isdecimal():
|
||||
ID = message.reply_to_message.from_id
|
||||
elif not hasattr(message.reply_to_message, 'text'):
|
||||
ID = int(message.get_args())
|
||||
ID = int((message.get_args() if is_command else message.text))
|
||||
|
||||
if not isinstance(db[DBTables.config].get('admins'), list):
|
||||
db[DBTables.config]['admins'] = list()
|
||||
|
||||
Reference in New Issue
Block a user