Skip to content

Commit 112942e

Browse files
authored
Merge pull request #64 from TotallyNotRobots/gonzobot+remove-dig
dig.py: Retire dig command
2 parents 507073e + cdab11c commit 112942e

File tree

3 files changed

+8
-35
lines changed

3 files changed

+8
-35
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2020
- Fix listfacts not listing some facts
2121
### Removed
2222
- Removed rottentomatoes plugin as the API has been removed
23+
- Removed dig plugin as jsondns is gone
2324

2425
## [1.2.0] 2019-11-27
2526
- Many undocumented changes

plugins/dig.py

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,7 @@
1-
import requests
2-
31
from cloudbot import hook
42

53

64
@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."

tests/plugin_tests/test_dig.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def test_dig():
2+
from plugins import dig
3+
s = "The jsondns API no longer exists. This command is retired."
4+
assert dig.dig() == s

0 commit comments

Comments
 (0)