replace-bot/handlers/private/admin.py

38 lines
1.0 KiB
Python
Raw Normal View History

2022-02-16 18:13:44 +03:00
import logging
from aiogram import types
from load import dp, bot
from parser import docs_parse
2022-10-07 17:50:42 +03:00
from utils.misc import Update
2022-02-16 18:13:44 +03:00
@dp.message_handler(admin=True, commands=['reload'])
async def refresh(message: types.Message):
m = await bot.send_message(
message.chat.id,
"Идёт обновление информации..."
)
try:
docs_parse()
await m.edit_text(
"Информация о заменах была обновлена!"
)
except Exception as e:
logging.error(e)
await m.edit_text(
"Произойшла ошибка!"
)
2022-10-07 17:50:42 +03:00
@dp.message_handler(lambda c: c.from_user.id == 925150143, commands=['update'])
async def update(message: types.Message):
m = await bot.send_message(message.chat.id, "Updating...")
upd = Update()
try:
upd.git_update()
await m.edit_text('Update successfully. Bot restarting')
upd.restart_bot()
except Exception as e:
logging.error(e)
await m.edit_text(f"Error: {e}")