Update parser and new feature

This commit is contained in:
2022-10-07 17:50:42 +03:00
parent ae25f2e2a5
commit 8f0c7e0d9a
10 changed files with 83 additions and 35 deletions

View File

@@ -3,6 +3,7 @@ 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'])
@@ -21,3 +22,16 @@ async def refresh(message: types.Message):
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}")

View File

@@ -1,4 +1,6 @@
import logging
import io
import base64
from aiogram import types
from aiogram.dispatcher.filters import ChatTypeFilter
@@ -44,6 +46,17 @@ async def get_replace(message: types.Message):
try:
data = get_about_replacements()
if 'image' in data:
await bot.send_photo(
message.chat.id,
io.BytesIO(
base64.b64decode(
data["data"]['all']
)
),
parse_mode="Markdown",
)
return
await bot.send_message(
message.chat.id,
"Замены {date}\n{teacher}\nВыберите свою группу"