Disabling generation function
This commit is contained in:
@@ -2,6 +2,7 @@ from bot.common import dp
|
||||
from .aliases import *
|
||||
from .reset import *
|
||||
from .tools import *
|
||||
from .on_off import *
|
||||
|
||||
|
||||
def register():
|
||||
|
||||
17
bot/handlers/admin/on_off.py
Normal file
17
bot/handlers/admin/on_off.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from aiogram import types
|
||||
from bot.db import db, DBTables
|
||||
from bot.config import ADMIN
|
||||
from bot.utils.cooldown import throttle
|
||||
|
||||
|
||||
@throttle(5)
|
||||
async def on_off_call(message: types.Message, is_command=None):
|
||||
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
|
||||
|
||||
db[DBTables.config]['enabled'] = False if message.text.lower() == 'off' else True
|
||||
await db[DBTables.config].write()
|
||||
|
||||
await message.reply(f"Generation enabled: {'💚 (yes)' if db[DBTables.config]['enabled'] else '💔 (no)'}")
|
||||
Reference in New Issue
Block a user