rate limit for ipcalc handler

This commit is contained in:
kiriharu 2021-01-11 12:01:46 +03:00
parent 335074d693
commit 5ab4d79b6e
2 changed files with 3 additions and 0 deletions

View File

@ -96,6 +96,7 @@ class CheckerBaseHandler(SimpleCommandHandler):
te = time() te = time()
logger.info(f"func {__name__} took {te - ts} sec") logger.info(f"func {__name__} took {te - ts} sec")
# TODO: Validation classes
async def validate_target(self, target: str): async def validate_target(self, target: str):
if validate_local(target): if validate_local(target):
raise LocalhostForbidden() raise LocalhostForbidden()

View File

@ -3,6 +3,7 @@ from typing import Union
import ipaddress import ipaddress
from tgbot.handlers.base import SimpleCommandHandler, NotEnoughArgs from tgbot.handlers.base import SimpleCommandHandler, NotEnoughArgs
from tgbot.middlewares.throttling import rate_limit
ipcalc_help_message = """ ipcalc_help_message = """
Калькулятор IP подсетей. Калькулятор IP подсетей.
@ -20,6 +21,7 @@ class IPCalcCommandHandler(SimpleCommandHandler):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
@rate_limit
async def handler(self, message: Message): async def handler(self, message: Message):
try: try:
args = await self.process_args(message.text) args = await self.process_args(message.text)