Fixed shrink command.

This commit is contained in:
Jeremy Fincher 2004-10-24 03:04:29 +00:00
parent a19bf090e5
commit b8621f0c34
2 changed files with 4 additions and 2 deletions

View File

@ -619,7 +619,7 @@ class Filter(callbacks.Privmsg):
irc.reply(' '.join(['GNU/' + s for s in text.split()])) irc.reply(' '.join(['GNU/' + s for s in text.split()]))
gnu = wrap(gnu, ['text']) gnu = wrap(gnu, ['text'])
def shrink(self, irc, msg, args): def shrink(self, irc, msg, args, text):
"""<text> """<text>
Returns <text> with each word longer than Returns <text> with each word longer than
@ -628,11 +628,12 @@ class Filter(callbacks.Privmsg):
""" """
L = [] L = []
minimum = self.registryValue('shrink.minimum', msg.args[0]) minimum = self.registryValue('shrink.minimum', msg.args[0])
for word in args: for word in text.split():
if len(word) >= minimum: if len(word) >= minimum:
word = '%s%s%s' % (word[0], len(word)-2, word[-1]) word = '%s%s%s' % (word[0], len(word)-2, word[-1])
L.append(word) L.append(word)
irc.reply(' '.join(L)) irc.reply(' '.join(L))
shrink = wrap(shrink, ['text'])
Class = Filter Class = Filter

View File

@ -160,5 +160,6 @@ class FilterTest(ChannelPluginTestCase, PluginDocumentation):
def testShrink(self): def testShrink(self):
self.assertResponse('shrink I love you', 'I l2e you') self.assertResponse('shrink I love you', 'I l2e you')
self.assertResponse('shrink internationalization', 'i18n') self.assertResponse('shrink internationalization', 'i18n')
self.assertResponse('shrink "I love you"', 'I l2e you')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: