From c31078339be6afde493d6521609e70caf8d8cc37 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 2 Jun 2003 05:53:16 +0000 Subject: [PATCH] Failed google now handled in googleSnarfer. --- plugins/Google.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/Google.py b/plugins/Google.py index f2a960d9e..a31b14da5 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -170,9 +170,14 @@ class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp): threaded = True def googleSnarfer(self, irc, msg, match): r"^google\s+(.*)$" - data = google.doGoogleSearch(match.group(1), safeSearch=1) - url = data.results[0].URL - irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), url)) + searchString = match.group(1) + data = google.doGoogleSearch(searchString, safeSearch=1) + if data.results: + url = data.results[0].URL + irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), url)) + else: + irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), + 'No results for "%s"' % searchString)) _ggThread = re.compile(r'
Subject: ([^<]+)
') _ggGroup = re.compile(r'Newsgroups: ]+>([^<]+)')