Failed google now handled in googleSnarfer.

This commit is contained in:
Jeremy Fincher 2003-06-02 05:53:16 +00:00
parent 663a9f75ae
commit c31078339b

View File

@ -170,9 +170,14 @@ class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp):
threaded = True threaded = True
def googleSnarfer(self, irc, msg, match): def googleSnarfer(self, irc, msg, match):
r"^google\s+(.*)$" r"^google\s+(.*)$"
data = google.doGoogleSearch(match.group(1), safeSearch=1) searchString = match.group(1)
url = data.results[0].URL data = google.doGoogleSearch(searchString, safeSearch=1)
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), url)) 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'<br>Subject: ([^<]+)<br>') _ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>') _ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')