From e67dce82d672dde7d115d46d29b8b2972961d9df Mon Sep 17 00:00:00 2001 From: Vladless Date: Wed, 28 May 2025 22:14:07 +0300 Subject: [PATCH] actual commit for admin-menu --- bot.py | 41 ++++++++++++++++++++++++--- handlers/admin/panel/panel_handler.py | 10 +++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index fae803d5..26a9ff9f 100644 --- a/bot.py +++ b/bot.py @@ -20,14 +20,47 @@ dp = Dispatcher(bot=bot, storage=storage) def get_git_commit_number() -> str: + repo_url = "https://github.com/Vladless/Solo_bot" + try: - count = subprocess.check_output(["git", "rev-list", "--count", "HEAD"]) - return count.decode("utf-8").strip() + local_number = subprocess.check_output( + ["git", "rev-list", "--count", "HEAD"] + ).decode().strip() + + local_hash = subprocess.check_output( + ["git", "rev-parse", "HEAD"] + ).decode().strip() except Exception: - return "unknown" + return "\n(Требуется обновление через CLI)" + + try: + remote_commit = subprocess.check_output( + ["git", "ls-remote", "origin", "refs/heads/dev"] + ).decode() + remote_hash = remote_commit.split()[0] + + remote_number = subprocess.check_output( + ["git", "rev-list", "--count", remote_hash] + ).decode().strip() + + if local_hash == remote_hash: + return "\n(Актуальная версия)" + + return ( + f"\n(commit " + f"#{local_number} / actual commit " + f"#{remote_number})" + ) + + except Exception: + return ( + f"\n(commit " + f"#{local_number} / actual commit unknown)" + ) -version = f"4.3-b240504 (commit #{get_git_commit_number()})" +version = f"v4.3-b240504{get_git_commit_number()}" + dp.message.filter(IsPrivateFilter()) dp.callback_query.filter(IsPrivateFilter()) diff --git a/handlers/admin/panel/panel_handler.py b/handlers/admin/panel/panel_handler.py index a7a5a222..0febdab4 100644 --- a/handlers/admin/panel/panel_handler.py +++ b/handlers/admin/panel/panel_handler.py @@ -22,7 +22,9 @@ async def handle_admin_callback_query(callback_query: CallbackQuery, state: FSMC if callback_query.message.text: try: await callback_query.message.edit_text( - text=text, reply_markup=build_panel_kb() + text=text, + reply_markup=build_panel_kb(), + disable_web_page_preview=True, ) except TelegramBadRequest as e: if "message is not modified" in str(e): @@ -37,7 +39,11 @@ async def handle_admin_callback_query(callback_query: CallbackQuery, state: FSMC except Exception as e: logger.error(f"Ошибка при удалении сообщения: {e}") - await callback_query.message.answer(text=text, reply_markup=build_panel_kb()) + await callback_query.message.answer( + text=text, + reply_markup=build_panel_kb(), + disable_web_page_preview=True, + ) @router.callback_query(F.data == "admin", IsAdminFilter())