From c73542fb3f960e50fbfb5181e7889ccb16c9814c Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 3 Jun 2017 17:28:43 -0700 Subject: [PATCH] DDG: remove the 'zeroclick' command The IRC output is poorly formatted, and doesn't yield useful results most of the time anyways. From: https://github.com/jlu5/SupyPlugins/commit/cdf6c7eb3ec7d0c20bdde367454ce16ccab71d3d --- plugin.py | 37 ------------------------------------- test.py | 6 +----- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/plugin.py b/plugin.py index ee7d2f480..004136efd 100644 --- a/plugin.py +++ b/plugin.py @@ -166,43 +166,6 @@ class DDG(callbacks.Plugin): irc.reply(', '.join(strings)) - @wrap(['text']) - def zeroclick(self, irc, msg, args, text): - """ - - Looks up on DuckDuckGo's zero-click engine.""" - # Zero-click can give multiple replies for things if the - # query is ambiguous, sort of like an encyclopedia. - - # For example, looking up "2^3" will give both: - # Zero-click info: 8 (number) - # Zero-click info: 8 - replies = {} - for td in self._ddgurl(text)[-1]: - if td.text.startswith("Zero-click info:"): - # Make a dictionary of things - item = td.text.split("Zero-click info:", 1)[1].strip() - td = td.parent.next_sibling.next_sibling.\ - find("td") - # Condense newlines (
tags). XXX: make these separators configurable. - for br in td.find_all('br'): - br.replace_with(' - ') - res = ' | '.join(td.text.strip().split("\n")) - try: - # Some zero-click results have an attached link to them. - link = td.a.get('href') - # Others have a piece of meaningless JavaScript... - if link != "javascript:;": - res += format(" %u", link) - except AttributeError: - pass - replies[item] = res - else: - if not replies: - irc.error("No zero-click info could be found for '%s'." % - text, Raise=True) - s = ["%s - %s" % (ircutils.bold(k), v) for k, v in replies.items()] - irc.reply("; ".join(s)) Class = DDG diff --git a/test.py b/test.py index e4613b0bd..6829aa00f 100644 --- a/test.py +++ b/test.py @@ -1,5 +1,5 @@ ### -# Copyright (c) 2014-2015, James Lu +# Copyright (c) 2014-2017, James Lu # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,15 +30,11 @@ from supybot.test import * - class DDGTestCase(PluginTestCase): plugins = ('DDG',) def testSearch(self): self.assertRegexp( 'ddg search wikipedia', 'Wikipedia.*? - .*?https?\:\/\/') - def testZeroclick(self): - self.assertRegexp( - 'zeroclick 2^3', '8') # vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: