This commit is contained in:
kiriharu 2021-01-07 02:07:38 +03:00
parent a37f07e125
commit b0e7f71d0f
2 changed files with 8 additions and 3 deletions

View File

@ -21,6 +21,7 @@ start_message = f"""
""" """
@rate_limit @rate_limit
async def start_cmd(msg: Message): async def start_cmd(msg: Message):
await msg.answer(start_message, parse_mode='markdown') await msg.answer(start_message, parse_mode='markdown')

View File

@ -1,5 +1,6 @@
import whois from whois import whois, parser
from aiogram.types import Message from aiogram.types import Message
from aiogram.utils.markdown import quote_html
from tgbot.handlers.helpers import validate_local from tgbot.handlers.helpers import validate_local
from tgbot.middlewares.throttling import rate_limit from tgbot.middlewares.throttling import rate_limit
@ -21,7 +22,10 @@ localhost_exception = "❗Локальные адреса запрещены!"
# TODO: Very shitty code. I should rewrite this. # TODO: Very shitty code. I should rewrite this.
def create_whois_message(domain: str) -> str: def create_whois_message(domain: str) -> str:
domain_info = whois.whois(domain) try:
domain_info = whois(domain)
except parser.PywhoisError as e:
return f"❗ Домен {domain} свободен или не был найден."
domain_name = domain_info.get("domain_name") domain_name = domain_info.get("domain_name")
if domain_name is None: if domain_name is None:
return no_domain_text return no_domain_text