diff --git a/apps/tgbot/tgbot/handlers/base.py b/apps/tgbot/tgbot/handlers/base.py index dee57b8..75dc825 100644 --- a/apps/tgbot/tgbot/handlers/base.py +++ b/apps/tgbot/tgbot/handlers/base.py @@ -49,10 +49,13 @@ class CheckerBaseHandler(SimpleCommandHandler): def __init__(self): pass - async def check(self, chat_id: int, bot: Bot, data: dict): + async def check(self, msg: Message, data: dict): # TODO: start check and end check metrics with ident, chat_id and api_endpoint ts = time() ident = uuid4().hex + # refactoring goes brr + chat_id = msg.chat.id + bot = msg.bot logger.info(f"User {chat_id} started check {ident}") # format header rsp_msg = await bot.send_message( @@ -71,8 +74,9 @@ class CheckerBaseHandler(SimpleCommandHandler): iter_keys = iter_keys + 1 if NOTIFY_CHECKS: - notify_text = f"**User {chat_id} issued check: {self.api_endpoint} for {data['target_fq']}**\n\n" \ - f"```{rsp_msg.text}```" + notify_text = f"**User {msg.from_user.full_name} (@{msg.from_user.username}) ({chat_id}) issued check: " \ + f"{self.api_endpoint} for {data['target_fq']}**\n\n" \ + f"```\n{rsp_msg.text}\n```" await send_message_to_admins(notify_text) logger.info(f"User {chat_id} ended check {ident}") @@ -108,8 +112,7 @@ class CheckerTargetPortHandler(CheckerBaseHandler): logger.info(f"User {message.from_user.id} got LocalhostForbidden error") return await message.answer(self.localhost_forbidden_message, parse_mode="Markdown") await self.check( - message.chat.id, - message.bot, + message, dict(target=args[0], port=args[1], target_fq=f"{args[0]}:{args[1]}") ) diff --git a/apps/tgbot/tgbot/handlers/default/icmp.py b/apps/tgbot/tgbot/handlers/default/icmp.py index 6872832..4865219 100644 --- a/apps/tgbot/tgbot/handlers/default/icmp.py +++ b/apps/tgbot/tgbot/handlers/default/icmp.py @@ -30,7 +30,7 @@ class ICMPCheckerHandler(CheckerBaseHandler): except LocalhostForbidden: return await message.answer(self.localhost_forbidden_message, parse_mode="Markdown") else: - await self.check(message.chat.id, message.bot, dict(target=args[0], target_fq=args[0])) + await self.check(message, dict(target=args[0], target_fq=args[0])) def process_args(self, text: str) -> list: args = text.split() diff --git a/apps/tgbot/tgbot/handlers/default/start.py b/apps/tgbot/tgbot/handlers/default/start.py index eaf267b..da867ed 100644 --- a/apps/tgbot/tgbot/handlers/default/start.py +++ b/apps/tgbot/tgbot/handlers/default/start.py @@ -27,7 +27,7 @@ start_message = """ 🚩 [Π­Ρ‚ΠΎΡ‚ Π±ΠΎΡ‚ с ΠΎΡ‚ΠΊΡ€Ρ‹Ρ‚Ρ‹ΠΌ с исходным ΠΊΠΎΠ΄ΠΎΠΌ](https://github.com/catspace-dev/unicheckbot) 🚩 [ΠŸΠΎΠΌΠΎΠ³ΠΈΡ‚Π΅ ΡƒΠ»ΡƒΡ‡ΡˆΠΈΡ‚ΡŒ Π±ΠΎΡ‚Π°](https://github.com/catspace-dev/unicheckbot/issues) ΠΈΠ»ΠΈ [расскаТитС ΠΎΠ± ошибкС](https://github.com/catspace-dev/unicheckbot/issues) -Π Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ: [kiriharu](http://t.me/kiriharu) +Π Π°Π·Ρ€Π°Π±ΠΎΡ‚Ρ‡ΠΈΠΊ: [kiriharu](https://t.me/kiriharu) ΠŸΡ€ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ΅: [SpaceCore.pro](https://spacecore.pro/) """