mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 02:49:27 +01:00
Added shrink filter.
This commit is contained in:
parent
168e61aef8
commit
1745c6d144
@ -61,6 +61,10 @@ conf.registerGlobalValue(conf.supybot.plugins.Filter.spellit,
|
|||||||
conf.registerGlobalValue(conf.supybot.plugins.Filter.spellit,
|
conf.registerGlobalValue(conf.supybot.plugins.Filter.spellit,
|
||||||
'replaceNumbers', registry.Boolean(True, """Determines whether or not to
|
'replaceNumbers', registry.Boolean(True, """Determines whether or not to
|
||||||
replace numbers in the output of spellit."""))
|
replace numbers in the output of spellit."""))
|
||||||
|
conf.registerGroup(conf.supybot.plugins.Filter, 'shrink')
|
||||||
|
conf.registerChannelValue(conf.supybot.plugins.Filter.shrink, 'minimum',
|
||||||
|
registry.PositiveInteger(4, """Determines the minimum number of a letters
|
||||||
|
in a word before it will be shrunken by the shrink command/filter."""))
|
||||||
|
|
||||||
class MyFilterProxy(object):
|
class MyFilterProxy(object):
|
||||||
def reply(self, s):
|
def reply(self, s):
|
||||||
@ -615,6 +619,21 @@ 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):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Returns <text> with each word longer than
|
||||||
|
supybot.plugins.Filter.shrink.minimum being shrunken (i.e., like
|
||||||
|
"internationalization" becomes "i18n").
|
||||||
|
"""
|
||||||
|
L = []
|
||||||
|
minimum = self.registryValue('shrink.minimum', msg.args[0])
|
||||||
|
for word in args:
|
||||||
|
if len(word) >= minimum:
|
||||||
|
word = '%s%s%s' % (word[0], len(word)-2, word[-1])
|
||||||
|
L.append(word)
|
||||||
|
irc.reply(' '.join(L))
|
||||||
|
|
||||||
|
|
||||||
Class = Filter
|
Class = Filter
|
||||||
|
|
||||||
|
@ -157,4 +157,8 @@ class FilterTest(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('echo foo bar baz', 'GNU/foo GNU/bar GNU/baz')
|
self.assertResponse('echo foo bar baz', 'GNU/foo GNU/bar GNU/baz')
|
||||||
self.assertNotError('outfilter')
|
self.assertNotError('outfilter')
|
||||||
|
|
||||||
|
def testShrink(self):
|
||||||
|
self.assertResponse('shrink I love you', 'I l2e you')
|
||||||
|
self.assertResponse('shrink internationalization', 'i18n')
|
||||||
|
|
||||||
# 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