mirror of
https://github.com/catspace-dev/unicheckbot.git
synced 2024-11-21 13:36:37 +03:00
rewrited commands
This commit is contained in:
parent
352d27f8b2
commit
8afcb2e087
|
@ -28,7 +28,8 @@ class ICMPCheckerHandler(CheckerBaseHandler):
|
|||
return await message.answer(icmp_help_message, parse_mode="Markdown")
|
||||
except LocalhostForbidden:
|
||||
return await message.answer(self.localhost_forbidden_message, parse_mode="Markdown")
|
||||
await self.check(message.chat.id, message.bot, dict(target=args[0], target_fq=args[0]))
|
||||
else:
|
||||
await self.check(message.chat.id, message.bot, dict(target=args[0], target_fq=args[0]))
|
||||
|
||||
async def process_args(self, text: str) -> list:
|
||||
args = text.split()
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
from aiogram.types import Message
|
||||
from core.coretypes import ResponseStatus, ErrorPayload, MinecraftResponse
|
||||
from httpx import Response
|
||||
|
||||
from tgbot.handlers.base import CheckerBaseHandler, process_args_for_host_port
|
||||
from tgbot.handlers.base import CheckerTargetPortHandler, process_args_for_host_port
|
||||
from tgbot.handlers.metrics import push_status_metric
|
||||
from tgbot.middlewares.throttling import rate_limit
|
||||
|
||||
minecraft_help_message = """
|
||||
❓ Получает статистику о Minecraft сервере
|
||||
|
@ -18,17 +16,13 @@ minecraft_help_message = """
|
|||
invalid_port = """❗Неправильный порт. Напишите /minecraft чтобы увидеть справку к данному способу проверки."""
|
||||
|
||||
|
||||
class MinecraftCheckerHandler(CheckerBaseHandler):
|
||||
class MinecraftCheckerHandler(CheckerTargetPortHandler):
|
||||
help_message = minecraft_help_message
|
||||
api_endpoint = "minecraft"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@rate_limit
|
||||
async def handler(self, message: Message):
|
||||
await self.target_port_handler(message)
|
||||
|
||||
async def process_args(self, text: str) -> list:
|
||||
return process_args_for_host_port(text, 25565)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ from aiogram.types import Message
|
|||
from core.coretypes import ResponseStatus, ErrorPayload, PortResponse
|
||||
from httpx import Response
|
||||
|
||||
from tgbot.handlers.base import CheckerBaseHandler, NotEnoughArgs, InvalidPort
|
||||
from tgbot.handlers.base import CheckerTargetPortHandler, NotEnoughArgs, InvalidPort
|
||||
from tgbot.handlers.helpers import check_int
|
||||
from tgbot.handlers.metrics import push_status_metric
|
||||
from tgbot.middlewares.throttling import rate_limit
|
||||
|
@ -17,7 +17,7 @@ tcp_help_message = """
|
|||
invalid_port = """❗Неправильный порт. Напишите /tcp чтобы увидеть справку к данному способу проверки."""
|
||||
|
||||
|
||||
class TCPCheckerHandler(CheckerBaseHandler):
|
||||
class TCPCheckerHandler(CheckerTargetPortHandler):
|
||||
help_message = tcp_help_message
|
||||
api_endpoint = "tcp_port"
|
||||
|
||||
|
@ -26,7 +26,7 @@ class TCPCheckerHandler(CheckerBaseHandler):
|
|||
|
||||
@rate_limit
|
||||
async def handler(self, message: Message):
|
||||
await self.target_port_handler(message)
|
||||
await super(TCPCheckerHandler, self).handler(message)
|
||||
|
||||
async def process_args(self, text: str) -> list:
|
||||
port = None
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
from aiogram.types import Message
|
||||
from httpx import Response
|
||||
from core.coretypes import ResponseStatus, HTTP_EMOJI, HttpCheckerResponse, ErrorPayload
|
||||
from ..base import CheckerBaseHandler, process_args_for_host_port
|
||||
from ..base import CheckerTargetPortHandler, process_args_for_host_port
|
||||
from ..metrics import push_status_metric
|
||||
from tgbot.middlewares.throttling import rate_limit
|
||||
|
||||
web_help_message = """
|
||||
❓ Производит проверку хоста по протоколу HTTP.
|
||||
|
@ -16,17 +14,13 @@ web_help_message = """
|
|||
invalid_port = """❗Неправильный порт. Напишите /web чтобы увидеть справку к данному способу проверки."""
|
||||
|
||||
|
||||
class WebCheckerHandler(CheckerBaseHandler):
|
||||
class WebCheckerHandler(CheckerTargetPortHandler):
|
||||
help_message = web_help_message
|
||||
api_endpoint = "http"
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
|
||||
@rate_limit
|
||||
async def handler(self, message: Message):
|
||||
await self.target_port_handler(message)
|
||||
|
||||
async def process_args(self, text: str) -> list:
|
||||
return process_args_for_host_port(text, 80)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user