aboutsummaryrefslogtreecommitdiff
path: root/modules/dns.py
diff options
context:
space:
mode:
authorGravatar jesopo2016-03-29 12:56:58 +0100
committerGravatar jesopo2016-03-29 12:56:58 +0100
commitf943d63098a50746f4e470e403a991a4d9713030 (patch)
treedeeb98058917d0155227211d72576f0cbab28d3f /modules/dns.py
parentInitial commit (diff)
first commit.
Diffstat (limited to 'modules/dns.py')
-rw-r--r--modules/dns.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/dns.py b/modules/dns.py
new file mode 100644
index 00000000..95c1b80c
--- /dev/null
+++ b/modules/dns.py
@@ -0,0 +1,21 @@
+import socket
+
+class Module(object):
+ _name = "DNS"
+ def __init__(self, bot):
+ bot.events.on("received").on("command").on("dns").hook(
+ self.dns, min_args=1,
+ help="Get all addresses for a given hostname (IPv4/IPv6)")
+
+ def dns(self, event):
+ hostname = event["args_split"][0]
+ try:
+ address_info = socket.getaddrinfo(hostname, 1, 0,
+ socket.SOCK_DGRAM)
+ except socket.gaierror:
+ event["stderr"].write("Failed to find hostname")
+ return
+ ips = []
+ for _, _, _, _, address in address_info:
+ ips.append(address[0])
+ event["stdout"].write("%s: %s" % (hostname, ", ".join(ips)))