From d778e3b485996ca255acc86467f5f2229dc18b92 Mon Sep 17 00:00:00 2001 From: kiriharu Date: Mon, 11 Jan 2021 11:59:29 +0300 Subject: [PATCH] small rewrite for base handlers again --- apps/tgbot/tgbot/handlers/base.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/tgbot/tgbot/handlers/base.py b/apps/tgbot/tgbot/handlers/base.py index 2e1168a..551b26b 100644 --- a/apps/tgbot/tgbot/handlers/base.py +++ b/apps/tgbot/tgbot/handlers/base.py @@ -29,6 +29,7 @@ class LocalhostForbidden(Exception): class SimpleCommandHandler: + help_message = "Set help message in class!" async def handler(self, message: Message): pass @@ -36,21 +37,23 @@ class SimpleCommandHandler: async def process_args(self, text: str) -> list: raise NotImplemented - async def prepare_message(self, res: Response) -> str: + async def validate_target(self, target: str): + raise NotImplemented + + async def prepare_message(self, *args) -> str: raise NotImplemented class CheckerBaseHandler(SimpleCommandHandler): - help_message = "Set help message in class!" - header_message = header localhost_forbidden_message = "❗ Локальные адреса запрещены" invalid_port_message = "Invalid port!" - + header_message = header api_endpoint = "Set api endpoint in class!" def __init__(self): pass + # TODO: create class CheckerTargetPortHandler async def target_port_handler(self, message: Message): """This hanler can be used if you need target port args""" try: