python discord py whois lookup

Solutions on MaxInterview for python discord py whois lookup by the best coders in the world

showing results for - "python discord py whois lookup"
Lylou
30 Feb 2019
1@commands.command()
2@commands.has_guild_permissions(administrator=True)
3async def whois(self, ctx, ip=None):
4	if ip is None:
5    	print('\n[LOGS] Must enter a ip!')
6        await ctx.send('Must enter a ip!')
7    else:
8        print(f'\n[LOGS] Running whois on {ip}')
9        host = socket.gethostbyname(ip)
10        w = IPWhois(host)
11        res = w.lookup_whois(inc_nir=True)
12        final_res = """
13IP: {}
14IP Range: {}
15Name: {}
16Handle: {}
17Registry: {}
18Description: {}
19Date: {}
20Updated: {}
21Country: {} 
22State: {}
23City: {}
24Address: {}
25Postal Code: {}
26        """.format(res['query'], res['nets'][0]['range'], res['nets'][0]['name'], res['nets'][0]['handle'], res['asn_registry'], res['asn_description'], res['asn_date'], res['nets'][0]['updated'], res['nets'][0]['country'], res['nets'][0]['state'], res['nets'][0]['city'], res['nets'][0]['address'], res['nets'][0]['postal_code'])
27        print(final_res)
28        await ctx.send(final_res)