38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
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}")
|