Made a DNS module\!
[scrappy.git] / modules / dns / dns.py
blobe6c41576be3f1237b2d20bdc36e4125e53e5a248
1 import socket
3 def init(bot):
4 bot.register_event("msg", dns)
6 def dns(c, args, bot):
7 cmd = args[4].split(" ")[0]
8 if cmd == "dns":
9 if not args[4].split(" ")[1:]:
10 ret = "Nothing to look up!"
11 else:
12 ret = args[4].split(" ")[1]
13 if ret[-1].isdigit():
14 try:
15 host, alias, ip = socket.gethostbyaddr(ret)
16 ret = "%s -> %s" % (ret, host)
17 except socket.gaierror:
18 ret = "No result for '%s'" % ret
19 else:
20 try:
21 ret = "%s -> %s" % (ret, socket.gethostbyname(ret))
22 except socket.gaierror:
23 ret = "No result for '%s'" % ret
25 c.privmsg(args[5], ret)