From 5e50eb00f2243ea44028f3d7ecdaaa282ace90e0 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Wed, 31 Aug 2011 14:11:13 -0400 Subject: [PATCH] Remove ddg.py since sbp added new DuckDuckGo search feature to search.py --- modules/ddg.py | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100755 modules/ddg.py diff --git a/modules/ddg.py b/modules/ddg.py deleted file mode 100755 index ef25734..0000000 --- a/modules/ddg.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python2 -""" -ddg.py - duck duck go module -author: mutantmonkey -portions based on search.py by sean b palmer -""" - -import random - -from urllib import quote as urlquote -from urllib2 import urlopen, HTTPError -import lxml.html - -import web - -def search(query): - uri = 'https://api.duckduckgo.com/' - args = '?q=%s&o=json' % web.urllib.quote(query.encode('utf-8')) - bytes = web.get(uri + args) - return web.json(bytes) - -def result(query): - results = search(query) - try: - return results['Results'][0]['FirstURL'] - except IndexError: - return None - -def ddg(phenny, input): - """.ddg - Search Duck Duck Go for the specified query.""" - - query = input.group(2) - if not query: - return phenny.reply(".ddg what?") - - uri = result(query) - resultsuri = "https://duckduckgo.com/?q=" + web.urllib.quote(query.encode('utf-8')) - if uri: - phenny.reply("%s - Results from %s" % (uri, resultsuri)) - else: - phenny.reply("No results found for '%s'; try %s" % (query, resultsuri)) -ddg.rule = (['ddg'], r'(.*)') - -if __name__ == '__main__': - print __doc__.strip() -