mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Add support for plain-text google groups links.
This commit is contained in:
parent
2b55842655
commit
e9b64d443a
@ -287,7 +287,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
googleSnarfer = privmsgs.urlSnarfer(googleSnarfer)
|
googleSnarfer = privmsgs.urlSnarfer(googleSnarfer)
|
||||||
|
|
||||||
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
|
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
|
||||||
|
_ggPlainThread = re.compile(r'Subject: (.*)')
|
||||||
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
|
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
|
||||||
|
_ggPlainGroup = re.compile(r'Newsgroups: (.*)')
|
||||||
def googleGroups(self, irc, msg, match):
|
def googleGroups(self, irc, msg, match):
|
||||||
r"http://groups.google.com/[^\s]+"
|
r"http://groups.google.com/[^\s]+"
|
||||||
if not self.configurables.get('groups-snarfer', channel=msg.args[0]):
|
if not self.configurables.get('groups-snarfer', channel=msg.args[0]):
|
||||||
@ -297,7 +299,7 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
fd = urllib2.urlopen(request)
|
fd = urllib2.urlopen(request)
|
||||||
text = fd.read()
|
text = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
if match.group(0).find('&prev=/') >= 0:
|
if '&prev=/' in match.group(0):
|
||||||
path = re.search('view the <a href=([^>]+)>no',text)
|
path = re.search('view the <a href=([^>]+)>no',text)
|
||||||
if path is None:
|
if path is None:
|
||||||
return
|
return
|
||||||
@ -308,8 +310,12 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
|
|||||||
fd = urllib2.urlopen(request)
|
fd = urllib2.urlopen(request)
|
||||||
text = fd.read()
|
text = fd.read()
|
||||||
fd.close()
|
fd.close()
|
||||||
mThread = self._ggThread.search(text)
|
if '&output=gplain' not in match.group(0):
|
||||||
mGroup = self._ggGroup.search(text)
|
mThread = self._ggThread.search(text)
|
||||||
|
mGroup = self._ggGroup.search(text)
|
||||||
|
else:
|
||||||
|
mThread = self._ggPlainThread.search(text)
|
||||||
|
mGroup = self._ggPlainGroup.search(text)
|
||||||
if mThread and mGroup:
|
if mThread and mGroup:
|
||||||
irc.reply(msg, 'Google Groups: %s, %s' % (mGroup.group(1),
|
irc.reply(msg, 'Google Groups: %s, %s' % (mGroup.group(1),
|
||||||
mThread.group(1)), prefixName = False)
|
mThread.group(1)), prefixName = False)
|
||||||
|
@ -42,6 +42,9 @@ class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
|
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
|
||||||
'0310132012.738e22fc%40posting.google.com',
|
'0310132012.738e22fc%40posting.google.com',
|
||||||
r'comp\.lang\.python.*question: usage of __slots__')
|
r'comp\.lang\.python.*question: usage of __slots__')
|
||||||
|
self.assertRegexp('http://groups.google.com/groups?selm=ExDm.'
|
||||||
|
'8bj.23%40gated-at.bofh.it&oe=UTF-8&output=gplain',
|
||||||
|
r'linux\.kernel.*NFS client freezes')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user