mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-19 08:59:27 +01:00
Changed format of gameknot URL snarfer.
This commit is contained in:
parent
7e5162d8e4
commit
94c10ca5da
@ -34,6 +34,7 @@ from baseplugin import *
|
||||
import re
|
||||
import urllib2
|
||||
|
||||
import debug
|
||||
import ircmsgs
|
||||
import ircutils
|
||||
import ircutils
|
||||
@ -62,25 +63,31 @@ class Forums(callbacks.PrivmsgRegexp):
|
||||
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
||||
'That doesn\'t appear to be a proper Google Groups page.'))
|
||||
|
||||
gkPlayer = re.compile(r"popd\('(Rating[^']+)'\).*?>([^<]+)<")
|
||||
_gkPlayer = re.compile(r"popd\('(Rating[^']+)'\).*?>([^<]+)<")
|
||||
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
|
||||
def gameknot(self, irc, msg, match):
|
||||
r"http://(?:www\.)?gameknot.com/chess.pl\?bd=\d+&r=\d+"
|
||||
fd = urllib2.urlopen(match.group(0))
|
||||
s = fd.read()
|
||||
fd.close()
|
||||
try:
|
||||
((wRating, wName), (bRating, bName)) = self.gkPlayer.findall(s)
|
||||
((wRating, wName), (bRating, bName)) = self._gkPlayer.findall(s)
|
||||
wName = ircutils.bold(wName)
|
||||
bName = ircutils.bold(bName)
|
||||
wRating = wRating.replace('<br>', ' ')
|
||||
bRating = bRating.replace('<br>', ' ')
|
||||
wRating = wRating.replace('Wins', '; Wins')
|
||||
bRating = bRating.replace('Wins', '; Wins ')
|
||||
(wRating, wWins, wLosses, wDraws) = \
|
||||
self._gkRating.search(wRating).groups()
|
||||
(bRating, bWins, bLosses, bDraws) = \
|
||||
self._gkRating.search(bRating).groups()
|
||||
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)' % (wName, wRating, bName, bRating)))
|
||||
'%s (%s) vs. %s (%s)' % (wName, wStats, bName, bStats)))
|
||||
|
||||
except ValueError:
|
||||
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
||||
'That doesn\'t appear to be a proper Gameknot game.'))
|
||||
except Exception, e:
|
||||
irc.error(msg, debug.exnToString(e))
|
||||
|
||||
|
||||
Class = Forums
|
||||
|
Loading…
Reference in New Issue
Block a user