]+)>no',text)
url = 'http://groups.google.com'
request = urllib2.Request('%s%s' % (url,path.group(1)),
headers={'User-agent': 'Mozilla/4.0 (compatible; MSIE 5.5;'
'Windows NT 4.0)'})
fd = urllib2.urlopen(request)
text = fd.read()
fd.close()
mThread = self._ggThread.search(text)
mGroup = self._ggGroup.search(text)
if mThread and mGroup:
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg),
'Google Groups: %s, %s' % (mGroup.group(1), mThread.group(1))))
else:
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
'That doesn\'t appear to be a proper Google Groups page.'))
_gkPlayer = re.compile(r"popd\('(Rating[^']+)'\).*?>([^<]+)<")
_gkRating = re.compile(r": (\d+)[^:]+:
(\d+)[^,]+, (\d+)[^,]+, (\d+)")
_gkGameTitle = re.compile(r"(.*?)\s* \s*\(started")
def gameknot(self, irc, msg, match):
r"http://(?:www\.)?gameknot.com/chess.pl\?bd=\d+(&r=\d+)?"
#debug.printf('Got a GK URL from %s' % msg.prefix)
url = match.group(0)
fd = urllib2.urlopen(url)
#debug.printf('Got the connection.')
s = fd.read()
#debug.printf('Got the string.')
fd.close()
try:
gameTitle = self._gkGameTitle.search(s).groups()
gameTitle = ircutils.bold(gameTitle)
((wRating, wName), (bRating, bName)) = self._gkPlayer.findall(s)
wName = ircutils.bold(wName)
bName = ircutils.bold(bName)
(wRating, wWins, wLosses, wDraws) = \
self._gkRating.search(wRating).groups()
(bRating, bWins, bLosses, bDraws) = \
self._gkRating.search(bRating).groups()
wStats = '%s; W-%s, L-%s, D-%s' % (wRating, wWins, wLosses, wDraws)
bStats = '%s; W-%s, L-%s, D-%s' % (bRating, bWins, bLosses, bDraws)
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
'%s: %s (%s) vs. %s (%s) <%s>' % (
gameTitle, wName, wStats, bName, bStats, url)))
except ValueError:
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
'That doesn\'t appear to be a proper Gameknot game.'))
except Exception, e:
irc.error(msg, debug.exnToString(e))
Class = Forums
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: