commands.wrap update

This commit is contained in:
James Vega 2004-10-16 02:52:31 +00:00
parent 242ecb4f8f
commit c6afe40abc
3 changed files with 19 additions and 15 deletions

View File

@ -47,7 +47,7 @@ from itertools import imap
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
from supybot.commands import wrap from supybot.commands import *
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.registry as registry import supybot.registry as registry
@ -300,27 +300,27 @@ class Fun(callbacks.Privmsg):
length, use 0. length, use 0.
""" """
irc.reply(utils.soundex(text, length)) irc.reply(utils.soundex(text, length))
soundex = wrap(soundex, ['text', ('?int', 4)]) soundex = wrap(soundex, ['text', optional('int', 4)])
# The list of words and algorithm are pulled straight the mozbot # The list of words and algorithm are pulled straight the mozbot
# MagicEightBall.bm module: http://tinyurl.com/7ytg7 # MagicEightBall.bm module: http://tinyurl.com/7ytg7
_responses = {'positive': ['It is possible.', 'Yes!', 'Of course.', _responses = {'positive': ['It is possible.', 'Yes!', 'Of course.',
'Naturally.', 'Obviously.', 'It shall be.', 'Naturally.', 'Obviously.', 'It shall be.',
'The outlook is good.', 'It is so.', 'The outlook is good.', 'It is so.',
'One would be wise to think so.', 'One would be wise to think so.',
'The answer is certainly yes.'], 'The answer is certainly yes.'],
'negative': ['In your dreams.', 'I doubt it very much.', 'negative': ['In your dreams.', 'I doubt it very much.',
'No chance.', 'The outlook is poor.', 'No chance.', 'The outlook is poor.',
'Unlikely.', 'About as likely as pigs flying.', 'Unlikely.', 'About as likely as pigs flying.',
'You\'re kidding, right?', 'NO!', 'NO.', 'No.', 'You\'re kidding, right?', 'NO!', 'NO.', 'No.',
'The answer is a resounding no.', ], 'The answer is a resounding no.', ],
'unknown' : ['Maybe...', 'No clue.', '_I_ don\'t know.', 'unknown' : ['Maybe...', 'No clue.', '_I_ don\'t know.',
'The outlook is hazy, please ask again later.', 'The outlook is hazy, please ask again later.',
'What are you asking me for?', 'Come again?', 'What are you asking me for?', 'Come again?',
'You know the answer better than I.', 'You know the answer better than I.',
'The answer is def-- oooh! shiny thing!'], 'The answer is def-- oooh! shiny thing!'],
} }
def _checkTheBall(self, questionLength): def _checkTheBall(self, questionLength):
if questionLength % 3 == 0: if questionLength % 3 == 0:
category = 'positive' category = 'positive'
@ -339,7 +339,7 @@ class Fun(callbacks.Privmsg):
irc.reply(self._checkTheBall(len(text))) irc.reply(self._checkTheBall(len(text)))
else: else:
irc.reply(self._checkTheBall(random.randint(0, 2))) irc.reply(self._checkTheBall(random.randint(0, 2)))
eightball = wrap(eightball, ['?text']) eightball = wrap(eightball, [optional('text')])
_rouletteChamber = random.randrange(0, 6) _rouletteChamber = random.randrange(0, 6)
_rouletteBullet = random.randrange(0, 6) _rouletteBullet = random.randrange(0, 6)
@ -367,7 +367,7 @@ class Fun(callbacks.Privmsg):
irc.reply('*click*') irc.reply('*click*')
self._rouletteChamber += 1 self._rouletteChamber += 1
self._rouletteChamber %= 6 self._rouletteChamber %= 6
roulette = wrap(roulette, ['public', ('?literal', False, 'spin')]) roulette = wrap(roulette, ['public', optional(('literal', 'spin'))])
def monologue(self, irc, msg, args, channel): def monologue(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]

View File

@ -42,7 +42,7 @@ import supybot.registry as registry
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
from supybot.commands import wrap from supybot.commands import *
import supybot.plugins as plugins import supybot.plugins as plugins
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.webutils as webutils import supybot.webutils as webutils
@ -149,15 +149,15 @@ class Gameknot(callbacks.PrivmsgCommandAndRegexp):
raise callbacks.Error, webutils.strError(e) raise callbacks.Error, webutils.strError(e)
def gkstats(self, irc, msg, args): def gkstats(self, irc, msg, args, name):
"""<name> """<name>
Returns the stats Gameknot keeps on <name>. Gameknot is an online Returns the stats Gameknot keeps on <name>. Gameknot is an online
website for playing chess (rather similar to correspondence chess, just website for playing chess (rather similar to correspondence chess, just
somewhat faster) against players from all over the world. somewhat faster) against players from all over the world.
""" """
name = privmsgs.getArgs(args)
irc.reply(self.getStats(name)) irc.reply(self.getStats(name))
gkstats = wrap(gkstats, ['text'])
_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+)")

View File

@ -77,6 +77,8 @@ class FunTest(ChannelPluginTestCase, PluginDocumentation):
self.assertRegexp('chr %s' % i, regexp) self.assertRegexp('chr %s' % i, regexp)
def testXor(self): def testXor(self):
# This no longer works correctly. It almost seems like were throwing
# in a repr() somewhere.
L = [nick for nick in nicks if '|' not in nick and L = [nick for nick in nicks if '|' not in nick and
'[' not in nick and '[' not in nick and
']' not in nick] ']' not in nick]
@ -93,6 +95,8 @@ class FunTest(ChannelPluginTestCase, PluginDocumentation):
self.assertResponse('ord %s' % utils.dqrepr(c), str(i)) self.assertResponse('ord %s' % utils.dqrepr(c), str(i))
def testEncodeDecode(self): def testEncodeDecode(self):
# This no longer works correctly. It almost seems like were throwing
# in a repr() somewhere.
s = 'the recalcitrant jamessan tests his scramble function' s = 'the recalcitrant jamessan tests his scramble function'
self.assertNotRegexp('encode aldkfja foobar', 'LookupError') self.assertNotRegexp('encode aldkfja foobar', 'LookupError')
self.assertNotRegexp('decode asdflkj foobar', 'LookupError') self.assertNotRegexp('decode asdflkj foobar', 'LookupError')