mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-19 23:20:57 +01:00
Made to use new PrivmsgCommandAndRegexp callback.
This commit is contained in:
parent
f203bca787
commit
0cf850dfc1
@ -36,6 +36,7 @@ Acceses Google for various things.
|
|||||||
from baseplugin import *
|
from baseplugin import *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import sets
|
||||||
import time
|
import time
|
||||||
import getopt
|
import getopt
|
||||||
import urllib2
|
import urllib2
|
||||||
@ -85,10 +86,11 @@ def search(*args, **kwargs):
|
|||||||
last24hours.dequeue()
|
last24hours.dequeue()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
class GooglePrivmsg(callbacks.Privmsg):
|
class Google(callbacks.PrivmsgCommandAndRegexp):
|
||||||
threaded = True
|
threaded = True
|
||||||
|
regexps = sets.Set(['googleSnarfer', 'googleGroups'])
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
self.total = 0
|
self.total = 0
|
||||||
self.totalTime = 0
|
self.totalTime = 0
|
||||||
self.last24hours = structures.queue()
|
self.last24hours = structures.queue()
|
||||||
@ -217,9 +219,6 @@ class GooglePrivmsg(callbacks.Privmsg):
|
|||||||
recent, recent != 1 and 's ' or ' ',
|
recent, recent != 1 and 's ' or ' ',
|
||||||
totalTime))
|
totalTime))
|
||||||
|
|
||||||
|
|
||||||
class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp):
|
|
||||||
threaded = True
|
|
||||||
def googleSnarfer(self, irc, msg, match):
|
def googleSnarfer(self, irc, msg, match):
|
||||||
r"^google\s+(.*)$"
|
r"^google\s+(.*)$"
|
||||||
searchString = match.group(1)
|
searchString = match.group(1)
|
||||||
@ -233,7 +232,7 @@ class GooglePrivmsgRegexp(callbacks.PrivmsgRegexp):
|
|||||||
|
|
||||||
_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>')
|
||||||
def googlegroups(self, irc, msg, match):
|
def googleGroups(self, irc, msg, match):
|
||||||
r"http://groups.google.com/[^\s]+"
|
r"http://groups.google.com/[^\s]+"
|
||||||
request = urllib2.Request(match.group(0), headers=\
|
request = urllib2.Request(match.group(0), headers=\
|
||||||
{'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)'})
|
{'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
|
Class = Google
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user