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:
James Vega 2003-10-21 16:43:02 +00:00
parent d959f84b73
commit 46907405d9
5 changed files with 58 additions and 25 deletions

View File

@ -69,6 +69,11 @@ example = utils.wrapLines("""
class Gameknot(callbacks.PrivmsgCommandAndRegexp):
threaded = True
regexps = sets.Set(['gameknotSnarfer', 'gameknotStatsSnarfer'])
def __init__(self):
callbacks.PrivmsgCommandAndRegexp.__init__(self)
self.snarfer = True
_gkrating = re.compile(r'<font color="#FFFF33">(\d+)</font>')
_gkgames = re.compile(r's:&nbsp;&nbsp;</td><td class=sml>(\d+)</td></tr>')
_gkrecord = re.compile(r'"#FFFF00">(\d+)[^"]+"#FFFF00">(\d+)[^"]+'\
@ -141,6 +146,18 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
name = privmsgs.getArgs(args)
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[^']+)'\).*?>([^<]+)<")
_gkRating = re.compile(r": (\d+)[^:]+:<br>(\d+)[^,]+, (\d+)[^,]+, (\d+)")
_gkGameTitle = re.compile(r"<p><b>(.*?)\s*</b>&nbsp;\s*<span.*?>\(started")
@ -148,6 +165,8 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
_gkReason = re.compile(r'won\s+\(\S+\s+(\S+)\)')
def gameknotSnarfer(self, irc, msg, match):
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)
url = match.group(0)
fd = urllib2.urlopen(url)
@ -192,12 +211,15 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
(gameTitle, wName, wStats, bName, bStats, toMove)
irc.reply(msg, s, prefixName=False)
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:
irc.error(msg, debug.exnToString(e))
def gameknotStatsSnarfer(self, irc, msg, match):
r"http://gameknot\.com/stats\.pl\?([^&]+)"
if not self.snarfer:
return
name = match.group(1)
s = self.getStats(name)
irc.reply(msg, s, prefixName=False)

View File

@ -150,15 +150,17 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
irc.reply(msg, conf.replySuccess)
licensekey = privmsgs.checkCapability(licensekey, 'admin')
def disablesnarfer(self, irc, msg, args):
def togglesnarfer(self, irc, msg, args):
"""takes no argument
Disables the snarfer that responds to all messages that begin with
'google'
Disables the snarfer that responds to all Sourceforge Tracker links
"""
self.snarfer = False
irc.reply(msg, conf.replySuccess)
disablesnarfer=privmsgs.checkCapability(disablesnarfer, 'admin')
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')
def google(self, irc, msg, args):
"""<search> [--{language,restrict}=<value>] [--{notsafe,similar}]
@ -267,10 +269,9 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
data = search(searchString, safeSearch=1)
if data.results:
url = data.results[0].URL
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg), url))
irc.reply(msg, url)
else:
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg),
'No results for "%s"' % searchString))
irc.reply(msg, 'No results for "%s"' % searchString)
_ggThread = re.compile(r'<br>Subject: ([^<]+)<br>')
_ggGroup = re.compile(r'Newsgroups: <a[^>]+>([^<]+)</a>')
@ -297,11 +298,11 @@ class Google(callbacks.PrivmsgCommandAndRegexp):
mThread = self._ggThread.search(text)
mGroup = self._ggGroup.search(text)
if mThread and mGroup:
irc.queueMsg(ircmsgs.privmsg(ircutils.replyTo(msg),
'Google Groups: %s, %s' % (mGroup.group(1), mThread.group(1))))
irc.reply(msg, 'Google Groups: %s, %s' % (mGroup.group(1),
mThread.group(1)), prefixName = False)
else:
irc.queueMsg(ircmsgs.privmsg(msg.args[0],
'That doesn\'t appear to be a proper Google Groups page.'))
irc.error(msg, 'That doesn\'t appear to be a proper '\
'Google Groups page. (%s)' % conf.replyPossibleBug)
Class = Google

View File

@ -53,7 +53,7 @@ def configure(onStart, afterConnect, advanced):
# 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.
from questions import expect, anything, something, yn
onStart.append('load Sf')
onStart.append('load Sourceforge')
example = utils.wrapLines("""
<@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>
""")
class Sf(callbacks.PrivmsgCommandAndRegexp):
class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
"""
Module for Sourceforge stuff. Currently contains commands to query a
project's most recent bugs and rfes.
@ -117,14 +117,17 @@ class Sf(callbacks.PrivmsgCommandAndRegexp):
matches.append((item[0], utils.htmlToText(item[2])))
return matches
def disablesfsnarfer(self, irc, msg, args):
def togglesnarfer(self, irc, msg, args):
"""takes no argument
Disables the snarfer that responds to all Sourceforge Tracker links
"""
self.snarfer = False
irc.reply(msg, conf.replySuccess)
disablesfsnarfer=privmsgs.checkCapability(disablesfsnarfer,'admin')
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')
_bugLink = re.compile(r'"([^"]+)">Bugs')
def bugs(self, irc, msg, args):
@ -263,13 +266,13 @@ class Sf(callbacks.PrivmsgCommandAndRegexp):
pass
linktype = utils.depluralize(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:
irc.error(msg, 'That doesn\'t appear to be a proper Sourceforge '\
'Tracker page.')
'Tracker page. (%s)' % conf.replyPossibleBug)
except Exception, e:
irc.error(msg, debug.exnToString(e))
Class = Sf
Class = Sourceforge
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:

View File

@ -137,6 +137,9 @@ replyNotRegistered = 'You must be registered to use this command.'
replyInvalidArgument = 'I can\'t send \\r, \\n, or \\0 (\\x00).'
replyRequiresPrivacy = 'That can\'t be done in a channel.'
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

View File

@ -34,7 +34,7 @@ import re
from test import *
class SfTest(PluginTestCase, PluginDocumentation):
plugins = ('Sf',)
plugins = ('Sourceforge',)
def testBugs(self):
self.assertNotError('bugs')
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?'\
'func=detail&aid=540223&group_id=235&atid=300235',
r';.*Status.*: \w+;')
self.assertNotError('disablesfsnarfer')
self.assertNotError('togglesnarfer')
self.assertNoResponse('http://sourceforge.net/tracker/index.php?'\
'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: