diff --git a/plugins/Google.py b/plugins/Google.py index 7e40d3632..f6c5c62db 100644 --- a/plugins/Google.py +++ b/plugins/Google.py @@ -36,6 +36,7 @@ Acceses Google for various things. from baseplugin import * import re +import sets import time import getopt import urllib2 @@ -85,10 +86,11 @@ def search(*args, **kwargs): last24hours.dequeue() return data -class GooglePrivmsg(callbacks.Privmsg): +class Google(callbacks.PrivmsgCommandAndRegexp): threaded = True + regexps = sets.Set(['googleSnarfer', 'googleGroups']) def __init__(self): - callbacks.Privmsg.__init__(self) + callbacks.PrivmsgCommandAndRegexp.__init__(self) self.total = 0 self.totalTime = 0 self.last24hours = structures.queue() @@ -217,9 +219,6 @@ class GooglePrivmsg(callbacks.Privmsg): recent, recent != 1 and 's ' or ' ', totalTime)) - -class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp): - threaded = True def googleSnarfer(self, irc, msg, match): r"^google\s+(.*)$" searchString = match.group(1) @@ -233,7 +232,7 @@ class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp): _ggThread = re.compile(r'
Subject: ([^<]+)
') _ggGroup = re.compile(r'Newsgroups: ]+>([^<]+)') - def googlegroups(self, irc, msg, match): + def googleGroups(self, irc, msg, match): r"http://groups.google.com/[^\s]+" request = urllib2.Request(match.group(0), headers=\ {'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'}) @@ -262,9 +261,6 @@ class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp): -class Google(callbacks.Combine): - classes = [GooglePrivmsg, GooglePrivmsgRegexp] - Class = Google # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: