mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-30 22:24:20 +01:00
Slightly changed format of gameknot URL snarfer
This commit is contained in:
parent
300cb1d766
commit
8c27ab7917
@ -37,7 +37,6 @@ import urllib2
|
|||||||
import debug
|
import debug
|
||||||
import ircmsgs
|
import ircmsgs
|
||||||
import ircutils
|
import ircutils
|
||||||
import ircutils
|
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
htmlStripper = re.compile(r'<[^>]+>')
|
htmlStripper = re.compile(r'<[^>]+>')
|
||||||
@ -67,8 +66,12 @@ class Forums(callbacks.PrivmsgRegexp):
|
|||||||
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
|
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
|
||||||
def gameknot(self, irc, msg, match):
|
def gameknot(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+"
|
||||||
fd = urllib2.urlopen(match.group(0))
|
#debug.printf('Got a GK URL from %s' % msg.prefix)
|
||||||
|
url = match.group(0)
|
||||||
|
fd = urllib2.urlopen(url)
|
||||||
|
#debug.printf('Got the connection.')
|
||||||
s = fd.read()
|
s = fd.read()
|
||||||
|
#debug.printf('Got the string.')
|
||||||
fd.close()
|
fd.close()
|
||||||
try:
|
try:
|
||||||
((wRating, wName), (bRating, bName)) = self._gkPlayer.findall(s)
|
((wRating, wName), (bRating, bName)) = self._gkPlayer.findall(s)
|
||||||
@ -81,8 +84,7 @@ class Forums(callbacks.PrivmsgRegexp):
|
|||||||
wStats = '%s; W-%s, L-%s, D-%s' % (wRating, wWins, wLosses, wDraws)
|
wStats = '%s; W-%s, L-%s, D-%s' % (wRating, wWins, wLosses, wDraws)
|
||||||
bStats = '%s; W-%s, L-%s, D-%s' % (bRating, bWins, bLosses, bDraws)
|
bStats = '%s; W-%s, L-%s, D-%s' % (bRating, bWins, bLosses, bDraws)
|
||||||
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
||||||
'%s (%s) vs. %s (%s)' % (wName, wStats, bName, bStats)))
|
'%s (%s) vs. %s (%s) [%s]' % (wName,wStats,bName,bStats,url)))
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
||||||
'That doesn\'t appear to be a proper Gameknot game.'))
|
'That doesn\'t appear to be a proper Gameknot game.'))
|
||||||
|
Loading…
Reference in New Issue
Block a user