diff --git a/apps/tgbot/tgbot/handlers/base.py b/apps/tgbot/tgbot/handlers/base.py index ee77eb8..63ee141 100644 --- a/apps/tgbot/tgbot/handlers/base.py +++ b/apps/tgbot/tgbot/handlers/base.py @@ -28,10 +28,10 @@ class SimpleCommandHandler: async def handler(self, message: Message): pass - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: raise NotImplemented - async def validate_target(self, target: str): + def validate_target(self, target: str): for validator in self.validators: validator.validate(target) @@ -81,7 +81,7 @@ class CheckerTargetPortHandler(CheckerBaseHandler): async def handler(self, message: Message): """This hanler can be used if you need target port args""" try: - args = await self.process_args(message.text) + args = self.process_args(message.text) except NotEnoughArgs: logger.info(f"User {message.from_user.id} got NotEnoughArgs error") return await message.answer(self.help_message, parse_mode="Markdown") @@ -89,7 +89,7 @@ class CheckerTargetPortHandler(CheckerBaseHandler): logger.info(f"User {message.from_user.id} got InvalidPort error") return await message.answer(self.invalid_port_message, parse_mode="Markdown") try: - await self.validate_target(args[0]) + self.validate_target(args[0]) except ValueError: # For ip check pass except LocalhostForbidden: diff --git a/apps/tgbot/tgbot/handlers/default/icmp.py b/apps/tgbot/tgbot/handlers/default/icmp.py index 4de783f..a79a3c4 100644 --- a/apps/tgbot/tgbot/handlers/default/icmp.py +++ b/apps/tgbot/tgbot/handlers/default/icmp.py @@ -23,7 +23,7 @@ class ICMPCheckerHandler(CheckerBaseHandler): @rate_limit async def handler(self, message: Message): try: - args = await self.process_args(message.text) + args = self.process_args(message.text) except NotEnoughArgs: return await message.answer(icmp_help_message, parse_mode="Markdown") except LocalhostForbidden: @@ -31,13 +31,13 @@ class ICMPCheckerHandler(CheckerBaseHandler): 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: + def process_args(self, text: str) -> list: args = text.split() if len(args) == 1: raise NotEnoughArgs() if len(args) >= 2: target = args[1] - await self.validate_target(target) + self.validate_target(target) return [target] async def prepare_message(self, res: Response): diff --git a/apps/tgbot/tgbot/handlers/default/ipcalc.py b/apps/tgbot/tgbot/handlers/default/ipcalc.py index eb15d69..83d18a4 100644 --- a/apps/tgbot/tgbot/handlers/default/ipcalc.py +++ b/apps/tgbot/tgbot/handlers/default/ipcalc.py @@ -24,7 +24,7 @@ class IPCalcCommandHandler(SimpleCommandHandler): @rate_limit async def handler(self, message: Message): try: - args = await self.process_args(message.text) + args = self.process_args(message.text) network = ipaddress.ip_network(args[1], False) except NotEnoughArgs: await message.answer(self.help_message, parse_mode='Markdown') @@ -34,7 +34,7 @@ class IPCalcCommandHandler(SimpleCommandHandler): msg = await self.prepare_message(network) await message.answer(msg) - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: args = text.split() if len(args) == 1: raise NotEnoughArgs diff --git a/apps/tgbot/tgbot/handlers/default/minecraft.py b/apps/tgbot/tgbot/handlers/default/minecraft.py index 4811c39..cdbf9c4 100644 --- a/apps/tgbot/tgbot/handlers/default/minecraft.py +++ b/apps/tgbot/tgbot/handlers/default/minecraft.py @@ -24,7 +24,7 @@ class MinecraftCheckerHandler(CheckerTargetPortHandler): def __init__(self): super().__init__() - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: return process_args_for_host_port(text, 25565) async def prepare_message(self, res: Response): diff --git a/apps/tgbot/tgbot/handlers/default/tcp.py b/apps/tgbot/tgbot/handlers/default/tcp.py index c3bf612..f0025a8 100644 --- a/apps/tgbot/tgbot/handlers/default/tcp.py +++ b/apps/tgbot/tgbot/handlers/default/tcp.py @@ -29,7 +29,7 @@ class TCPCheckerHandler(CheckerTargetPortHandler): async def handler(self, message: Message): await super(TCPCheckerHandler, self).handler(message) - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: args = text.split(' ', 1) if len(args) != 2: raise NotEnoughArgs() diff --git a/apps/tgbot/tgbot/handlers/default/web.py b/apps/tgbot/tgbot/handlers/default/web.py index b0ca9aa..7fce4a3 100644 --- a/apps/tgbot/tgbot/handlers/default/web.py +++ b/apps/tgbot/tgbot/handlers/default/web.py @@ -22,7 +22,7 @@ class WebCheckerHandler(CheckerTargetPortHandler): def __init__(self): super().__init__() - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: return process_args_for_host_port(text, 80) async def prepare_message(self, res: Response): diff --git a/apps/tgbot/tgbot/handlers/default/whois.py b/apps/tgbot/tgbot/handlers/default/whois.py index 4220cda..98188e8 100644 --- a/apps/tgbot/tgbot/handlers/default/whois.py +++ b/apps/tgbot/tgbot/handlers/default/whois.py @@ -116,7 +116,7 @@ class WhoisCommandHandler(SimpleCommandHandler): @rate_limit async def handler(self, message: Message): try: - args = await self.process_args(message.text) + args = self.process_args(message.text) except NotEnoughArgs: await message.answer(no_domain_text, parse_mode='Markdown') except LocalhostForbidden: @@ -124,13 +124,13 @@ class WhoisCommandHandler(SimpleCommandHandler): else: await message.answer(create_whois_message(args[0]), parse_mode='html') - async def process_args(self, text: str) -> list: + def process_args(self, text: str) -> list: args = text.split() if len(args) == 1: raise NotEnoughArgs if len(args) >= 2: host = args[1] - await self.validate_target(host) + self.validate_target(host) return [host] # only domain name async def prepare_message(self) -> str: