Admin and start handlers work. Added testing txt2img from first bot version (will be replaced soon)

This commit is contained in:
BarsTiger
2023-02-14 13:49:58 +02:00
parent 7ba5482e6a
commit dcdb4ef60d
20 changed files with 234 additions and 19 deletions

View File

@@ -0,0 +1,6 @@
from bot.common import dp
from .aliases import *
def register():
dp.register_message_handler(set_endpoint, commands='setendpoint')

View File

@@ -0,0 +1,23 @@
from aiogram import types
from bot.db import db, DBTables
import validators
from bot.config import ADMIN
from bot.utils.cooldown import throttle
@throttle(5)
async def set_endpoint(message: types.Message):
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()):
await message.reply("❌ Specify correct url for endpoint")
return
db[DBTables.config]['endpoint'] = message.get_args()
await db[DBTables.config].write()
await message.reply("✅ New url set")