From afb4e1e07ff5846729ad9f2325505d29eb55611e Mon Sep 17 00:00:00 2001 From: James Vega Date: Sat, 28 Nov 2009 21:21:00 -0500 Subject: [PATCH] Use 0 when no results are returned for Google.fight Signed-off-by: James Vega (cherry picked from commit 3689460d0fa2e7ef8a6c95feda217b2fa6f4e73d) --- plugins/Google/plugin.py | 3 ++- plugins/Google/test.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 1d889edba..a78b1d981 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -219,7 +219,8 @@ class Google(callbacks.PluginRegexp): results = [] for arg in args: data = self.search(arg, channel, {'smallsearch': True}) - count = data['responseData']['cursor']['estimatedResultCount'] + count = data['responseData']['cursor'].get('estimatedResultCount', + 0) results.append((int(count), arg)) results.sort() results.reverse() diff --git a/plugins/Google/test.py b/plugins/Google/test.py index 83d498530..695e95037 100644 --- a/plugins/Google/test.py +++ b/plugins/Google/test.py @@ -1,6 +1,6 @@ ### # Copyright (c) 2002-2004, Jeremiah Fincher -# Copyright (c) 2008, James Vega +# Copyright (c) 2008-2009, James Vega # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -55,6 +55,7 @@ class GoogleTestCase(ChannelPluginTestCase): def testFight(self): self.assertRegexp('fight supybot moobot', r'.*supybot.*: \d+') + self.assertNotError('fight ... !') def testTranslate(self): self.assertRegexp('translate en es hello world', 'mundo')