mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-20 01:19:26 +01:00
Found a bug, wrote a test, yay.
This commit is contained in:
parent
5ab19c44ce
commit
e05a0d18c9
@ -115,7 +115,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
_gkPlayer = re.compile(r"popd\('(Rating[^']+)'\).*?>([^<]+)<")
|
_gkPlayer = re.compile(r"popd\('(Rating[^']+)'\).*?>([^<]+)<")
|
||||||
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
|
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
|
||||||
_gkGameTitle = re.compile(r"<p><b>(.*?)\s*</b> \s*<span.*?>\(started")
|
_gkGameTitle = re.compile(r"<p><b>(.*?)\s*</b> \s*<span.*?>\(started")
|
||||||
_gkWon = re.compile(r'>(\S+)\s+won\s+\((\S+)\s+(\S+)\)')
|
_gkWon = re.compile(r'>(\S+)\s+won')
|
||||||
|
_gkReason = re.compile(r'won\s+\(\S+\s+(\S+)\)')
|
||||||
def gameknotSnarfer(self, irc, msg, match):
|
def gameknotSnarfer(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)
|
#debug.printf('Got a GK URL from %s' % msg.prefix)
|
||||||
@ -139,8 +140,12 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
else:
|
else:
|
||||||
# Game is over.
|
# Game is over.
|
||||||
m = self._gkWon.search(s)
|
m = self._gkWon.search(s)
|
||||||
(winner, loser, reason) = m.groups()
|
winner = m.group(1)
|
||||||
debug.printf((winner, loser, reason))
|
m = self._gkReason.match(s)
|
||||||
|
if m:
|
||||||
|
reason = m.group(1)
|
||||||
|
else:
|
||||||
|
reason = 'lost'
|
||||||
if winner == 'white':
|
if winner == 'white':
|
||||||
toMove = '%s won, %s %s.' % (wName, bName, reason)
|
toMove = '%s won, %s %s.' % (wName, bName, reason)
|
||||||
else:
|
else:
|
||||||
|
@ -48,6 +48,8 @@ class GameknotTestCase(PluginTestCase):
|
|||||||
def testSnarfer(self):
|
def testSnarfer(self):
|
||||||
self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
|
self.assertRegexp('http://gameknot.com/chess.pl?bd=907498',
|
||||||
'\x02ddipaolo\x02 won')
|
'\x02ddipaolo\x02 won')
|
||||||
|
self.assertRegexp('http://gameknot.com/chess.pl?bd=955432',
|
||||||
|
'\x02ddipaolo\x02 lost')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user