mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 20:22:45 +01:00
Switch Sf back to Sourceforge due to a conversation I wasn't aware of where
they reversed the naming-decision
This commit is contained in:
parent
d959f84b73
commit
46907405d9
@ -69,6 +69,11 @@ example = utils.wrapLines("""
|
|||||||
class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
||||||
threaded = True
|
threaded = True
|
||||||
regexps = sets.Set(['gameknotSnarfer', 'gameknotStatsSnarfer'])
|
regexps = sets.Set(['gameknotSnarfer', 'gameknotStatsSnarfer'])
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
callbacks.PrivmsgCommandAndRegexp.__init__(self)
|
||||||
|
self.snarfer = True
|
||||||
|
|
||||||
_gkrating = re.compile(r'<font color="#FFFF33">(\d+)</font>')
|
_gkrating = re.compile(r'<font color="#FFFF33">(\d+)</font>')
|
||||||
_gkgames = re.compile(r's: </td><td class=sml>(\d+)</td></tr>')
|
_gkgames = re.compile(r's: </td><td class=sml>(\d+)</td></tr>')
|
||||||
_gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'\
|
_gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'\
|
||||||
@ -141,6 +146,18 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
name = privmsgs.getArgs(args)
|
name = privmsgs.getArgs(args)
|
||||||
irc.reply(msg, self.getStats(name))
|
irc.reply(msg, self.getStats(name))
|
||||||
|
|
||||||
|
def togglesnarfer(self, irc, msg, args):
|
||||||
|
"""takes no argument
|
||||||
|
|
||||||
|
Disables the snarfer that responds to all Sourceforge Tracker links
|
||||||
|
"""
|
||||||
|
self.snarfer = not self.snarfer
|
||||||
|
if self.snarfer:
|
||||||
|
irc.reply(msg, '%s (Snarfer is enabled)' % conf.replySuccess)
|
||||||
|
else:
|
||||||
|
irc.reply(msg, '%s (Snarfer is disabled)' % conf.replySuccess)
|
||||||
|
togglesnarfer=privmsgs.checkCapability(togglesnarfer, 'admin')
|
||||||
|
|
||||||
_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")
|
||||||
@ -148,6 +165,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
_gkReason = re.compile(r'won\s+\(\S+\s+(\S+)\)')
|
_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+)?"
|
||||||
|
if not self.snarfer:
|
||||||
|
return
|
||||||
#debug.printf('Got a GK URL from %s' % msg.prefix)
|
#debug.printf('Got a GK URL from %s' % msg.prefix)
|
||||||
url = match.group(0)
|
url = match.group(0)
|
||||||
fd = urllib2.urlopen(url)
|
fd = urllib2.urlopen(url)
|
||||||
@ -192,12 +211,15 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
(gameTitle, wName, wStats, bName, bStats, toMove)
|
(gameTitle, wName, wStats, bName, bStats, toMove)
|
||||||
irc.reply(msg, s, prefixName=False)
|
irc.reply(msg, s, prefixName=False)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
irc.error(msg,'That doesn\'t appear to be a proper Gameknot game.')
|
irc.error(msg,'That doesn\'t appear to be a proper Gameknot game.'\
|
||||||
|
' (%s)' % conf.replyPossibleBug)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(msg, debug.exnToString(e))
|
irc.error(msg, debug.exnToString(e))
|
||||||
|
|
||||||
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.snarfer:
|
||||||
|
return
|
||||||
name = match.group(1)
|
name = match.group(1)
|
||||||
s = self.getStats(name)
|
s = self.getStats(name)
|
||||||
irc.reply(msg, s, prefixName=False)
|
irc.reply(msg, s, prefixName=False)
|
||||||
|
@ -150,15 +150,17 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
irc.reply(msg, conf.replySuccess)
|
irc.reply(msg, conf.replySuccess)
|
||||||
licensekey = privmsgs.checkCapability(licensekey, 'admin')
|
licensekey = privmsgs.checkCapability(licensekey, 'admin')
|
||||||
|
|
||||||
def disablesnarfer(self, irc, msg, args):
|
def togglesnarfer(self, irc, msg, args):
|
||||||
"""takes no argument
|
"""takes no argument
|
||||||
|
|
||||||
Disables the snarfer that responds to all messages that begin with
|
Disables the snarfer that responds to all Sourceforge Tracker links
|
||||||
'google'
|
|
||||||
"""
|
"""
|
||||||
self.snarfer = False
|
self.snarfer = not self.snarfer
|
||||||
irc.reply(msg, conf.replySuccess)
|
if self.snarfer:
|
||||||
disablesnarfer=privmsgs.checkCapability(disablesnarfer, 'admin')
|
irc.reply(msg, '%s (Snarfer is enabled)' % conf.replySuccess)
|
||||||
|
else:
|
||||||
|
irc.reply(msg, '%s (Snarfer is disabled)' % conf.replySuccess)
|
||||||
|
togglesnarfer=privmsgs.checkCapability(togglesnarfer, 'admin')
|
||||||
|
|
||||||
def google(self, irc, msg, args):
|
def google(self, irc, msg, args):
|
||||||
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
|
||||||
@ -267,10 +269,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
data = search(searchString, safeSearch=1)
|
data = search(searchString, safeSearch=1)
|
||||||
if data.results:
|
if data.results:
|
||||||
url = data.results[0].URL
|
url = data.results[0].URL
|
||||||
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), url))
|
irc.reply(msg, url)
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg),
|
irc.reply(msg, 'No results for "%s"' % searchString)
|
||||||
'No results for "%s"' % searchString))
|
|
||||||
|
|
||||||
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
|
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
|
||||||
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
|
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
|
||||||
@ -297,11 +298,11 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
mThread = self._ggThread.search(text)
|
mThread = self._ggThread.search(text)
|
||||||
mGroup = self._ggGroup.search(text)
|
mGroup = self._ggGroup.search(text)
|
||||||
if mThread and mGroup:
|
if mThread and mGroup:
|
||||||
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg),
|
irc.reply(msg, 'Google Groups: %s, %s' % (mGroup.group(1),
|
||||||
'Google Groups: %s, %s' % (mGroup.group(1), mThread.group(1))))
|
mThread.group(1)), prefixName = False)
|
||||||
else:
|
else:
|
||||||
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
|
irc.error(msg, 'That doesn\'t appear to be a proper '\
|
||||||
'That doesn\'t appear to be a proper Google Groups page.'))
|
'Google Groups page. (%s)' % conf.replyPossibleBug)
|
||||||
|
|
||||||
|
|
||||||
Class = Google
|
Class = Google
|
||||||
|
@ -53,7 +53,7 @@ def configure(onStart, afterConnect, advanced):
|
|||||||
# like to be run when the bot is started; append to afterConnect the
|
# like to be run when the bot is started; append to afterConnect the
|
||||||
# commands you would like to be run when the bot has finished connecting.
|
# commands you would like to be run when the bot has finished connecting.
|
||||||
from questions import expect, anything, something, yn
|
from questions import expect, anything, something, yn
|
||||||
onStart.append('load Sf')
|
onStart.append('load Sourceforge')
|
||||||
|
|
||||||
example = utils.wrapLines("""
|
example = utils.wrapLines("""
|
||||||
<@jamessan|work> @bugs
|
<@jamessan|work> @bugs
|
||||||
@ -69,7 +69,7 @@ in 0.71, Bug #820961: dock icon doesn't show up with..., Bug #820879: Cannot con
|
|||||||
< supybot> jamessan|work: Improve CLI interface <http://sourceforge.net/tracker/index.php?func=detail&aid=720757&group_id=75946&atid=545548>
|
< supybot> jamessan|work: Improve CLI interface <http://sourceforge.net/tracker/index.php?func=detail&aid=720757&group_id=75946&atid=545548>
|
||||||
""")
|
""")
|
||||||
|
|
||||||
class Sf(callbacks.PrivmsgCommandAndRegexp):
|
class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
||||||
"""
|
"""
|
||||||
Module for Sourceforge stuff. Currently contains commands to query a
|
Module for Sourceforge stuff. Currently contains commands to query a
|
||||||
project's most recent bugs and rfes.
|
project's most recent bugs and rfes.
|
||||||
@ -117,14 +117,17 @@ class Sf(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
matches.append((item[0], utils.htmlToText(item[2])))
|
matches.append((item[0], utils.htmlToText(item[2])))
|
||||||
return matches
|
return matches
|
||||||
|
|
||||||
def disablesfsnarfer(self, irc, msg, args):
|
def togglesnarfer(self, irc, msg, args):
|
||||||
"""takes no argument
|
"""takes no argument
|
||||||
|
|
||||||
Disables the snarfer that responds to all Sourceforge Tracker links
|
Disables the snarfer that responds to all Sourceforge Tracker links
|
||||||
"""
|
"""
|
||||||
self.snarfer = False
|
self.snarfer = not self.snarfer
|
||||||
irc.reply(msg, conf.replySuccess)
|
if self.snarfer:
|
||||||
disablesfsnarfer=privmsgs.checkCapability(disablesfsnarfer,'admin')
|
irc.reply(msg, '%s (Snarfer is enabled)' % conf.replySuccess)
|
||||||
|
else:
|
||||||
|
irc.reply(msg, '%s (Snarfer is disabled)' % conf.replySuccess)
|
||||||
|
togglesnarfer=privmsgs.checkCapability(togglesnarfer,'admin')
|
||||||
|
|
||||||
_bugLink = re.compile(r'"([^"]+)">Bugs')
|
_bugLink = re.compile(r'"([^"]+)">Bugs')
|
||||||
def bugs(self, irc, msg, args):
|
def bugs(self, irc, msg, args):
|
||||||
@ -263,13 +266,13 @@ class Sf(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
pass
|
pass
|
||||||
linktype = utils.depluralize(linktype)
|
linktype = utils.depluralize(linktype)
|
||||||
irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype),
|
irc.reply(msg, '%s #%s: %s' % (ircutils.bold(linktype),
|
||||||
ircutils.bold(num), '; '.join(resp)))
|
ircutils.bold(num), '; '.join(resp)), prefixName = False)
|
||||||
except AttributeError, e:
|
except AttributeError, e:
|
||||||
irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\
|
irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\
|
||||||
'Tracker page.')
|
'Tracker page. (%s)' % conf.replyPossibleBug)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
irc.error(msg, debug.exnToString(e))
|
irc.error(msg, debug.exnToString(e))
|
||||||
|
|
||||||
Class = Sf
|
Class = Sourceforge
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
@ -137,6 +137,9 @@ replyNotRegistered = 'You must be registered to use this command.'
|
|||||||
replyInvalidArgument = 'I can\'t send \\r, \\n, or \\0 (\\x00).'
|
replyInvalidArgument = 'I can\'t send \\r, \\n, or \\0 (\\x00).'
|
||||||
replyRequiresPrivacy = 'That can\'t be done in a channel.'
|
replyRequiresPrivacy = 'That can\'t be done in a channel.'
|
||||||
replyEvalNotAllowed = 'You must enable conf.allowEval for that to work.'
|
replyEvalNotAllowed = 'You must enable conf.allowEval for that to work.'
|
||||||
|
replyPossibleBug = 'This may be a bug. If you think it is, please file a bug'\
|
||||||
|
'report at http://sourceforge.net/tracker/?func=add&group_id=58965&'\
|
||||||
|
'atid=489447'
|
||||||
|
|
||||||
###
|
###
|
||||||
# errorReplyPrivate: True if errors should be reported privately so as not to
|
# errorReplyPrivate: True if errors should be reported privately so as not to
|
||||||
|
@ -34,7 +34,7 @@ import re
|
|||||||
from test import *
|
from test import *
|
||||||
|
|
||||||
class SfTest(PluginTestCase, PluginDocumentation):
|
class SfTest(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Sf',)
|
plugins = ('Sourceforge',)
|
||||||
def testBugs(self):
|
def testBugs(self):
|
||||||
self.assertNotError('bugs')
|
self.assertNotError('bugs')
|
||||||
self.assertResponse('bugs alkjfi83fa8', 'Can\'t find the "Bugs" link.')
|
self.assertResponse('bugs alkjfi83fa8', 'Can\'t find the "Bugs" link.')
|
||||||
@ -107,9 +107,13 @@ class SfTest(PluginTestCase, PluginDocumentation):
|
|||||||
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=540223&group_id=235&atid=300235',
|
'func=detail&aid=540223&group_id=235&atid=300235',
|
||||||
r';.*Status.*: \w+;')
|
r';.*Status.*: \w+;')
|
||||||
self.assertNotError('disablesfsnarfer')
|
self.assertNotError('togglesnarfer')
|
||||||
self.assertNoResponse('http://sourceforge.net/tracker/index.php?'\
|
self.assertNoResponse('http://sourceforge.net/tracker/index.php?'\
|
||||||
'func=detail&aid=540223&group_id=235&atid=300235')
|
'func=detail&aid=540223&group_id=235&atid=300235')
|
||||||
|
self.assertNotError('togglesnarfer')
|
||||||
|
self.assertRegexp('http://sourceforge.net/tracker/index.php?'\
|
||||||
|
'func=detail&aid=540223&group_id=235&atid=300235',
|
||||||
|
r';.*Status.*: \w+;')
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user