We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1812d5c commit 918539fCopy full SHA for 918539f
1 file changed
plugins/whois.py
@@ -1,6 +1,10 @@
1
-from contextlib import suppress
+"""
2
+whois.py
3
+Provides a command to allow users to look up information on domain names.
4
5
6
import pythonwhois
7
+from contextlib import suppress
8
9
from cloudbot import hook
10
@@ -10,9 +14,13 @@ def whois(text):
14
"""<domain> -- Does a whois query on <domain>."""
11
15
domain = text.strip().lower()
12
16
13
- data = pythonwhois.get_whois(domain, normalized=True)
17
+ try:
18
+ data = pythonwhois.get_whois(domain, normalized=True)
19
+ except pythonwhois.shared.WhoisException:
20
+ return "Invalid input."
21
info = []
22
23
+ # We suppress errors here because different domains provide different data fields
24
with suppress(KeyError):
25
info.append("\x02Registrar\x02: {}".format(data["registrar"][0]))
26
0 commit comments