small rewrite for base handlers again

This commit is contained in:
kiriharu 2021-01-11 11:59:29 +03:00
parent b6918d8724
commit d778e3b485

View File

@ -29,6 +29,7 @@ class LocalhostForbidden(Exception):
class SimpleCommandHandler: class SimpleCommandHandler:
help_message = "Set help message in class!"
async def handler(self, message: Message): async def handler(self, message: Message):
pass pass
@ -36,21 +37,23 @@ class SimpleCommandHandler:
async def process_args(self, text: str) -> list: async def process_args(self, text: str) -> list:
raise NotImplemented 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 raise NotImplemented
class CheckerBaseHandler(SimpleCommandHandler): class CheckerBaseHandler(SimpleCommandHandler):
help_message = "Set help message in class!"
header_message = header
localhost_forbidden_message = "❗ Локальные адреса запрещены" localhost_forbidden_message = "❗ Локальные адреса запрещены"
invalid_port_message = "Invalid port!" invalid_port_message = "Invalid port!"
header_message = header
api_endpoint = "Set api endpoint in class!" api_endpoint = "Set api endpoint in class!"
def __init__(self): def __init__(self):
pass pass
# TODO: create class CheckerTargetPortHandler
async def target_port_handler(self, message: Message): async def target_port_handler(self, message: Message):
"""This hanler can be used if you need target port args""" """This hanler can be used if you need target port args"""
try: try: