Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions plugins/whois.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,33 @@ def whois(text, reply):
info = []

# We suppress errors here because different domains provide different data fields
with suppress(KeyError):
try:
info.append(("Registrar", data["registrar"][0]))
except KeyError:
info.append(("Registrar", 'Not Found'))
except TypeError:
info.append(("Registrar", 'Not Found'))

try:
info.append(("Registrant", data["contacts"]["registrant"]["name"]))
except KeyError:
info.append(("Registrant", 'Not Found'))
except TypeError:
info.append(("Registrant", 'Not Found'))

with suppress(KeyError):
try:
info.append(("Registered", data["creation_date"][0].strftime("%d-%m-%Y")))
except KeyError:
info.append(("Registered", 'Not Found'))
except TypeError:
info.append(("Registered", 'Not Found'))

with suppress(KeyError):
try:
info.append(("Expires", data["expiration_date"][0].strftime("%d-%m-%Y")))
except KeyError:
info.append(("Expires", 'Not Found'))
except TypeError:
info.append(("Expires", 'Not Found'))

if not info:
return "No information returned."
Expand Down