From 99666246eda0dfbbe218f9796969ffd81aa1fd91 Mon Sep 17 00:00:00 2001 From: Daniel DiPaolo Date: Sat, 19 Apr 2003 04:43:46 +0000 Subject: [PATCH] * Corrected the gameknot Forums regex to not require the ("&r=\d+") part since not all the URLs necessarily have it. * Added the game title to the output as well (haven't done a ton of testing on the regex, but it worked on every game I tried it on) --- plugins/Forums.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/Forums.py b/plugins/Forums.py index c1aed4c31..829ef8d52 100644 --- a/plugins/Forums.py +++ b/plugins/Forums.py @@ -76,8 +76,9 @@ class Forums(callbacks.PrivmsgRegexp): _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+" + 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) @@ -86,6 +87,8 @@ class Forums(callbacks.PrivmsgRegexp): #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) @@ -96,7 +99,8 @@ class Forums(callbacks.PrivmsgRegexp): 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) vs. %s (%s) <%s>' % (wName,wStats,bName,bStats,url))) + '%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.'))