iplocalise bug fix + bgp.he.net link
This commit is contained in:
parent
534a78e447
commit
ecdde52ca3
1 changed files with 12 additions and 5 deletions
|
@ -7,6 +7,7 @@ import ipinfo as ipinfoio
|
||||||
|
|
||||||
from ipwhois.net import Net
|
from ipwhois.net import Net
|
||||||
from ipwhois.asn import IPASN
|
from ipwhois.asn import IPASN
|
||||||
|
import ipwhois
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
import requests
|
import requests
|
||||||
|
@ -234,9 +235,14 @@ class Utility(commands.Cog):
|
||||||
|
|
||||||
iploading = await ctx.send("_Récupération des informations..._")
|
iploading = await ctx.send("_Récupération des informations..._")
|
||||||
|
|
||||||
|
try:
|
||||||
net = Net(ipaddress)
|
net = Net(ipaddress)
|
||||||
obj = IPASN(net)
|
obj = IPASN(net)
|
||||||
ipinfo = obj.lookup()
|
ipinfo = obj.lookup()
|
||||||
|
except ipwhois.exceptions.IPDefinedError:
|
||||||
|
await ctx.send("Cette IP est reservée à un usage local selon la RFC 1918. Impossible d'avoir des informations supplémentaires à son propos.")
|
||||||
|
await iploading.delete()
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
iphostname = socket.gethostbyaddr(ipaddress)[0]
|
iphostname = socket.gethostbyaddr(ipaddress)[0]
|
||||||
|
@ -256,9 +262,10 @@ class Utility(commands.Cog):
|
||||||
embed = discord.Embed(title=f"Informations pour ``{realipaddress} ({ipaddress})``", color=0x5858d7)
|
embed = discord.Embed(title=f"Informations pour ``{realipaddress} ({ipaddress})``", color=0x5858d7)
|
||||||
|
|
||||||
if(api_result):
|
if(api_result):
|
||||||
embed.add_field(name="Appartient à :", value=f"{details.org}")
|
asn = details.org.split(" ")[0]
|
||||||
|
embed.add_field(name="Appartient à :", value=f"[{details.org}](https://bgp.he.net/{asn})")
|
||||||
else:
|
else:
|
||||||
embed.add_field(name="Appartient à :", value=f"{ipinfo['asn_description']} (AS{ipinfo['asn']})", inline = False)
|
embed.add_field(name="Appartient à :", value=f"{ipinfo['asn_description']} ([AS{ipinfo['asn']}](https://bgp.he.net/{ipinfo['asn']}))", inline = False)
|
||||||
|
|
||||||
embed.add_field(name="RIR :", value=f"{ipinfo['asn_registry']}", inline = True)
|
embed.add_field(name="RIR :", value=f"{ipinfo['asn_registry']}", inline = True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue