fix(commands:iplocalise|Network): fix process crashing regex

This commit is contained in:
Romain J 2021-03-05 00:05:24 +01:00
parent 78a5ac9939
commit 0ecc97518f
3 changed files with 10 additions and 7 deletions

View file

@ -1,3 +1,3 @@
DOMAIN_PATTERN = r"^(((.*)+)*\.)+[a-z\-]{2,}\.?$"
DOMAIN_PATTERN = r"^((.*)+\.)+[a-z\-]{2,}\.?$"
IPV4_PATTERN = r"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"
IPV6_PATTERN = r"^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"

View file

@ -10,8 +10,11 @@ from ipinfo.exceptions import RequestQuotaExceededError
from ipwhois import Net
from ipwhois.asn import IPASN
from tuxbot.cogs.Network.functions.consts import DOMAIN_PATTERN, IPV4_PATTERN, \
IPV6_PATTERN
from tuxbot.cogs.Network.functions.consts import (
DOMAIN_PATTERN,
IPV4_PATTERN,
IPV6_PATTERN,
)
from tuxbot.cogs.Network.functions.exceptions import (
VersionNotFound,
@ -54,7 +57,9 @@ async def get_hostname(ip: str) -> str:
return "N/A"
async def get_ipwhois_result(ip_address: str, tmp: discord.Message = None) -> Union[NoReturn, dict]:
async def get_ipwhois_result(
ip_address: str, tmp: discord.Message = None
) -> Union[NoReturn, dict]:
try:
net = Net(ip_address)
obj = IPASN(net)

View file

@ -206,9 +206,7 @@ class Network(commands.Cog, name="Network"):
e = discord.Embed(title=f"DIG {domain} {query_type}", color=0x5858D7)
for i, value in enumerate(pydig_result):
e.add_field(
name=f"#{i}", value=f"```{value}```"
)
e.add_field(name=f"#{i}", value=f"```{value}```")
if not pydig_result:
e.add_field(