replace-bot/handlers/private/admin.py

38 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import logging
from aiogram import types
from load import dp, bot
from parser import docs_parse
from utils.misc import Update
@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(
"Произойшла ошибка!"
)
@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}")