From cdab11c81496716bcacc0aca6b669cd4cc188bf6 Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Thu, 28 Nov 2019 12:42:06 -0600 Subject: [PATCH] dig.py: Retire dig command The jsondns API no longer exists --- CHANGELOG.md | 1 + plugins/dig.py | 38 +++------------------------------- tests/plugin_tests/test_dig.py | 4 ++++ 3 files changed, 8 insertions(+), 35 deletions(-) create mode 100644 tests/plugin_tests/test_dig.py diff --git a/CHANGELOG.md b/CHANGELOG.md index e4c9e1476..a0c0e29df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix listfacts not listing some facts ### Removed - Removed rottentomatoes plugin as the API has been removed +- Removed dig plugin as jsondns is gone ## [1.2.0] 2019-11-27 - Many undocumented changes diff --git a/plugins/dig.py b/plugins/dig.py index 0c1fa11c7..5ad1a70c5 100644 --- a/plugins/dig.py +++ b/plugins/dig.py @@ -1,39 +1,7 @@ -import requests - from cloudbot import hook @hook.command -def dig(text, nick, notice): - """ - returns a list of records for the specified domain valid record types are A, NS, TXT, - and MX. If a record type is not chosen A will be the default.""" - args = text.split() - domain = args.pop(0) - - if args: - rtype = args.pop(0).upper() - else: - rtype = "A" - - if rtype not in ("A", "NS", "MX", "TXT"): - rtype = "A" - - url = "http://dig.jsondns.org/IN/{}/{}".format(domain, rtype) - r = requests.get(url) - r.raise_for_status() - results = r.json() - if results['header']['rcode'] == "NXDOMAIN": - return "no dns record for {} was found".format(domain) - notice("The following records were found for \x02{}\x02: ".format(domain), nick) - for r in range(len(results['answer'])): - domain = results['answer'][r]['name'] - rtype = results['answer'][r]['type'] - ttl = results['answer'][r]['ttl'] - if rtype == "MX": - rdata = results['answer'][r]['rdata'][1] - elif rtype == "TXT": - rdata = results['answer'][r]['rdata'][0] - else: - rdata = results['answer'][r]['rdata'] - notice("name: \x02{}\x02 type: \x02{}\x02 ttl: \x02{}\x02 rdata: \x02{}\x02".format( - domain, rtype, ttl, rdata), nick) +def dig(): + """- This command is retired""" + return "The jsondns API no longer exists. This command is retired." diff --git a/tests/plugin_tests/test_dig.py b/tests/plugin_tests/test_dig.py new file mode 100644 index 000000000..ab9ef3d83 --- /dev/null +++ b/tests/plugin_tests/test_dig.py @@ -0,0 +1,4 @@ +def test_dig(): + from plugins import dig + s = "The jsondns API no longer exists. This command is retired." + assert dig.dig() == s