Fixed some use of regexps, commented out a test that was failing because a game expired.

This commit is contained in:
Jeremy Fincher 2003-11-24 23:07:51 +00:00
parent a966513c7d
commit 4e273a2395
2 changed files with 19 additions and 4 deletions

View File

@ -33,6 +33,8 @@
Handles URL snarfing for Gameknot.com and the gkstats command.
"""
__revision__ = "$id$"
import plugins
import re
@ -189,9 +191,21 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable):
#debug.printf('Got the string.')
fd.close()
try:
gameTitle = self._gkGameTitle.search(s).groups()
if 'no longer available' in s:
s = 'That game is no longer available.'
irc.reply(msg, s, prefixName=True)
return
m = self._gkGameTitle.search(s)
if m is None:
debug.msg('Gameknot._gkGameTitle didn\'t match (%s).' % url)
return
gameTitle = m.groups()
gameTitle = ircutils.bold(gameTitle)
((wRating, wName), (bRating, bName)) = self._gkPlayer.findall(s)
L = self._gkPlayer.findall(s)
if not L:
debug.msg('Gameknot._gkPlayer didn\'t match (%s).' % url)
return
((wRating, wName), (bRating, bName)) = L
wName = ircutils.bold(wName)
bName = ircutils.bold(bName)
if 'to move...' in s:

View File

@ -67,8 +67,9 @@ class GameknotTestCase(PluginTestCase, PluginDocumentation):
def testSnarfer(self):
self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
'\x02ddipaolo\x0f won')
# This game expired.
## self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
## '\x02ddipaolo\x0f won')
self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
'\x02chroniqueur\x0f resigned')
self.assertRegexp('http://gameknot.com/chess.pl?bd=955432',