From 21d06ae4f0892a93a4db37eb580e8d54403a752e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Sun, 2 Mar 2014 14:01:15 +1300 Subject: [PATCH] Removed old duplicate suggest plugin --- disabled_stuff/suggest.py | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 disabled_stuff/suggest.py diff --git a/disabled_stuff/suggest.py b/disabled_stuff/suggest.py deleted file mode 100644 index 92f9405..0000000 --- a/disabled_stuff/suggest.py +++ /dev/null @@ -1,33 +0,0 @@ -import json -import random -import re - -from util import hook, http - - -@hook.command -def suggest(inp, inp_unstripped=''): - ".suggest [#n] -- gets a random/the nth suggested google search" - - inp = inp_unstripped - m = re.match('^#(\d+) (.+)$', inp) - if m: - num, inp = m.groups() - num = int(num) - if num > 10: - return 'I can only get the first ten suggestions.' - else: - num = 0 - - page = http.get('http://google.com/complete/search', output='json', client='hp', q=inp) - page_json = page.split('(', 1)[1][:-1] - suggestions = json.loads(page_json)[1] - if not suggestions: - return 'No suggestions found.' - if num: - if len(suggestions) + 1 <= num: - return 'I only got %d suggestions.' % len(suggestions) - out = suggestions[num - 1] - else: - out = random.choice(suggestions) - return '#%d: %s' % (int(out[2][0]) + 1, out[0].replace('', '').replace('', '')) \ No newline at end of file