This repository has been archived on 2023-04-13. You can view files and clone it, but cannot push or open issues or pull requests.
CloudBot/plugins/whois.py

43 lines
1 KiB
Python
Raw Normal View History

2012-02-22 06:03:28 +01:00
from util import pywhois, hook
2012-02-29 06:58:38 +01:00
2012-02-22 06:03:28 +01:00
@hook.command
def whois(inp, say=None):
2012-02-28 03:03:43 +01:00
".whois <domain> -- Look up ownership infomation for <domain>"
2012-02-22 06:03:28 +01:00
try:
w = pywhois.whois(inp)
except:
return "Failed to check domain info. This domain may not exist."
print w
2012-02-24 04:17:59 +01:00
try:
domain_name = w.domain_name[0]
except IndexError, e:
2012-02-29 06:58:38 +01:00
domain_name = "None"
2012-02-24 04:17:59 +01:00
try:
expiration_date = w.expiration_date[0]
except IndexError, e:
2012-02-29 06:58:38 +01:00
expiration_date = "None"
2012-02-24 04:17:59 +01:00
try:
creation_date = w.creation_date[0]
except IndexError, e:
2012-02-29 06:58:38 +01:00
creation_date = "None"
2012-02-24 04:17:59 +01:00
try:
registrant_email = w.emails[0]
except:
2012-02-29 06:58:38 +01:00
registrant_email = "None"
2012-02-24 04:17:59 +01:00
try:
administrative_email = w.emails[1]
except:
2012-02-29 06:58:38 +01:00
administrative_email = "None"
2012-02-22 06:03:28 +01:00
2012-02-29 06:58:38 +01:00
say("Domain recognised! %s was registered on \x02%s\x02 and will "\
"expire on \x02%s\x02" % (domain_name, creation_date, expiration_date))
say("Registrant email: %s "\
"Administrative email: %s" % (registrant_email, administrative_email))