Fixed snarfer for drawn games.

This commit is contained in:
Jeremy Fincher 2003-09-17 21:31:04 +00:00
parent 70b80f0622
commit fd1aacbd64
2 changed files with 13 additions and 8 deletions

View File

@ -168,16 +168,19 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
else:
# Game is over.
m = self._gkWon.search(s)
winner = m.group(1)
m = self._gkReason.search(s)
if m:
reason = m.group(1)
winner = m.group(1)
m = self._gkReason.search(s)
if m:
reason = m.group(1)
else:
reason = 'lost'
if winner == 'white':
toMove = '%s won, %s %s.' % (wName, bName, reason)
else:
toMove = '%s won, %s %s.' % (bName, wName, reason)
else:
reason = 'lost'
if winner == 'white':
toMove = '%s won, %s %s.' % (wName, bName, reason)
else:
toMove = '%s won, %s %s.' % (bName, wName, reason)
toMove = 'The game was a draw.'
(wRating, wWins, wLosses, wDraws) = \
self._gkRating.search(wRating).groups()
(bRating, bWins, bLosses, bDraws) = \

View File

@ -54,6 +54,8 @@ class GameknotTestCase(PluginTestCase, PluginDocumentation):
'\x02chroniqueur\x0f resigned')
self.assertRegexp('http://gameknot.com/chess.pl?bd=955432',
'\x02ddipaolo\x0f lost')
self.assertRegexp('http://gameknot.com/chess.pl?bd=1077345&r=365',
'draw')