Fix a bug where we weren't catching the end of the URL appropriately

This commit is contained in:
James Vega 2004-12-29 22:30:54 +00:00
parent ab0eff4eea
commit fd6f4e7e24
2 changed files with 36 additions and 18 deletions

View File

@ -226,7 +226,7 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
gameknotSnarfer = urlSnarfer(gameknotSnarfer) gameknotSnarfer = urlSnarfer(gameknotSnarfer)
def gameknotStatsSnarfer(self, irc, msg, match): def gameknotStatsSnarfer(self, irc, msg, match):
r"http://gameknot\.com/stats\.pl\?([^&]+)" r"http://gameknot\.com/stats\.pl\?([^& ]+)"
if not self.registryValue('statSnarfer', msg.args[0]): if not self.registryValue('statSnarfer', msg.args[0]):
return return
name = match.group(1) name = match.group(1)

View File

@ -61,20 +61,39 @@ if network:
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig) conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig)
def testStatsUrlSnarfer(self): def testStatsUrlSnarfer(self):
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) orig = conf.supybot.plugins.Gameknot.statSnarfer()
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') try:
self.assertRegexp('http://gameknot.com/stats.pl?ddipaolo&1', conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
r'^[^&]+$') self.assertSnarfNotError(
'http://gameknot.com/stats.pl?ironchefchess')
self.assertSnarfRegexp(
'http://gameknot.com/stats.pl?ddipaolo&1',
r'^[^&]+$')
self.assertSnarfRegexp(
'http://gameknot.com/stats.pl?ddipaolo and some extra',
r'^ddipaolo is rated')
finally:
conf.supybot.plugins.Gameknot.statSnarfer.setValue(orig)
def testConfig(self): def testConfig(self):
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(False) game = conf.supybot.plugins.Gameknot.gameSnarfer()
conf.supybot.plugins.Gameknot.statSnarfer.setValue(False) stat = conf.supybot.plugins.Gameknot.statSnarfer()
self.assertNoResponse('http://gameknot.com/stats.pl?ironchefchess') try:
self.assertNoResponse('http://gameknot.com/chess.pl?bd=907498') conf.supybot.plugins.Gameknot.gameSnarfer.setValue(False)
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True) conf.supybot.plugins.Gameknot.statSnarfer.setValue(False)
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True) self.assertSnarfNoResponse(
self.assertNotError('http://gameknot.com/stats.pl?ironchefchess') 'http://gameknot.com/stats.pl?ironchefchess')
self.assertNotError('http://gameknot.com/chess.pl?bd=907498') self.assertSnarfNoResponse(
'http://gameknot.com/chess.pl?bd=907498')
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
conf.supybot.plugins.Gameknot.statSnarfer.setValue(True)
self.assertSnarfNotError(
'http://gameknot.com/stats.pl?ironchefchess', timeout=20)
self.assertSnarfNotError(
'http://gameknot.com/chess.pl?bd=907498')
finally:
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(game)
conf.supybot.plugins.Gameknot.statSnarfer.setValue(stat)
def testSnarfer(self): def testSnarfer(self):
@ -82,15 +101,14 @@ if network:
try: try:
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True) conf.supybot.plugins.Gameknot.gameSnarfer.setValue(True)
self.assertSnarfRegexp( self.assertSnarfRegexp(
'http://gameknot.com/chess.pl?bd=955432', 'http://gameknot.com/chess.pl?bd=955432',
'\x02ddipaolo\x02 lost') '\x02ddipaolo\x02 lost')
self.assertSnarfRegexp( self.assertSnarfRegexp(
'http://gameknot.com/chess.pl?bd=1077345&r=365', 'http://gameknot.com/chess.pl?bd=1077345&r=365',
'draw') 'draw')
finally: finally:
conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig) conf.supybot.plugins.Gameknot.gameSnarfer.setValue(orig)
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: