Add support for plain-text google groups links.

This commit is contained in:
James Vega 2003-11-11 16:32:28 +00:00
parent 2b55842655
commit e9b64d443a
2 changed files with 12 additions and 3 deletions

View File

@ -287,7 +287,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
googleSnarfer = privmsgs.urlSnarfer(googleSnarfer)
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
_ggPlainThread = re.compile(r'Subject: (.*)')
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
_ggPlainGroup = re.compile(r'Newsgroups: (.*)')
def googleGroups(self, irc, msg, match):
r"http://groups.google.com/[^\s]+"
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)
text = fd.read()
fd.close()
if match.group(0).find('&prev=/') >= 0:
if '&prev=/' in match.group(0):
path = re.search('view the <a href=([^>]+)>no',text)
if path is None:
return
@ -308,8 +310,12 @@ class Google(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
fd = urllib2.urlopen(request)
text = fd.read()
fd.close()
mThread = self._ggThread.search(text)
mGroup = self._ggGroup.search(text)
if '&output=gplain' not in match.group(0):
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:
irc.reply(msg, 'Google Groups: %s, %s' % (mGroup.group(1),
mThread.group(1)), prefixName = False)

View File

@ -42,6 +42,9 @@ class GoogleTestCase(ChannelPluginTestCase, PluginDocumentation):
'lr=lang_en&ie=UTF-8&oe=UTF-8&selm=698f09f8.'
'0310132012.738e22fc%40posting.google.com',
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: