|
1 |
| -import requests |
2 |
| - |
3 | 1 | from cloudbot import hook
|
4 | 2 |
|
5 | 3 |
|
6 | 4 | @hook.command
|
7 |
| -def dig(text, nick, notice): |
8 |
| - """<domain> <recordtype> - returns a list of records for the specified domain valid record types are A, NS, TXT, |
9 |
| - and MX. If a record type is not chosen A will be the default.""" |
10 |
| - args = text.split() |
11 |
| - domain = args.pop(0) |
12 |
| - |
13 |
| - if args: |
14 |
| - rtype = args.pop(0).upper() |
15 |
| - else: |
16 |
| - rtype = "A" |
17 |
| - |
18 |
| - if rtype not in ("A", "NS", "MX", "TXT"): |
19 |
| - rtype = "A" |
20 |
| - |
21 |
| - url = "http://dig.jsondns.org/IN/{}/{}".format(domain, rtype) |
22 |
| - r = requests.get(url) |
23 |
| - r.raise_for_status() |
24 |
| - results = r.json() |
25 |
| - if results['header']['rcode'] == "NXDOMAIN": |
26 |
| - return "no dns record for {} was found".format(domain) |
27 |
| - notice("The following records were found for \x02{}\x02: ".format(domain), nick) |
28 |
| - for r in range(len(results['answer'])): |
29 |
| - domain = results['answer'][r]['name'] |
30 |
| - rtype = results['answer'][r]['type'] |
31 |
| - ttl = results['answer'][r]['ttl'] |
32 |
| - if rtype == "MX": |
33 |
| - rdata = results['answer'][r]['rdata'][1] |
34 |
| - elif rtype == "TXT": |
35 |
| - rdata = results['answer'][r]['rdata'][0] |
36 |
| - else: |
37 |
| - rdata = results['answer'][r]['rdata'] |
38 |
| - notice("name: \x02{}\x02 type: \x02{}\x02 ttl: \x02{}\x02 rdata: \x02{}\x02".format( |
39 |
| - domain, rtype, ttl, rdata), nick) |
| 5 | +def dig(): |
| 6 | + """- This command is retired""" |
| 7 | + return "The jsondns API no longer exists. This command is retired." |
0 commit comments