mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 20:52:42 +01:00
Added the undup filter.
This commit is contained in:
parent
d4b30b6214
commit
2c8490c86a
@ -97,7 +97,7 @@ class Filter(callbacks.Privmsg):
|
|||||||
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
_filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp',
|
||||||
'scramble', 'morse', 'reverse', 'colorize', 'squish',
|
'scramble', 'morse', 'reverse', 'colorize', 'squish',
|
||||||
'supa1337', 'colorstrip', 'aol', 'rainbow', 'spellit',
|
'supa1337', 'colorstrip', 'aol', 'rainbow', 'spellit',
|
||||||
'hebrew']
|
'hebrew', 'undup']
|
||||||
def outfilter(self, irc, msg, args, channel, command):
|
def outfilter(self, irc, msg, args, channel, command):
|
||||||
"""[<channel>] [<command>]
|
"""[<channel>] [<command>]
|
||||||
|
|
||||||
@ -138,6 +138,18 @@ class Filter(callbacks.Privmsg):
|
|||||||
irc.reply(text)
|
irc.reply(text)
|
||||||
squish = wrap(squish, ['text'])
|
squish = wrap(squish, ['text'])
|
||||||
|
|
||||||
|
def undup(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Returns <text>, with all consecutive duplicated letters removed.
|
||||||
|
"""
|
||||||
|
L = [text[0]]
|
||||||
|
for c in text:
|
||||||
|
if c != L[-1]:
|
||||||
|
L.append(c)
|
||||||
|
irc.reply(''.join(L))
|
||||||
|
undup = wrap(undup, ['text'])
|
||||||
|
|
||||||
def binary(self, irc, msg, args, text):
|
def binary(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
|
@ -53,6 +53,10 @@ class FilterTest(ChannelPluginTestCase, PluginDocumentation):
|
|||||||
self.assertResponse('squish foo bar baz', 'foobarbaz')
|
self.assertResponse('squish foo bar baz', 'foobarbaz')
|
||||||
self.assertResponse('squish "foo bar baz"', 'foobarbaz')
|
self.assertResponse('squish "foo bar baz"', 'foobarbaz')
|
||||||
|
|
||||||
|
def testUndup(self):
|
||||||
|
self.assertResponse('undup foo bar baz quux', 'fo bar baz qux')
|
||||||
|
self.assertResponse('undup aaaaaaaaaa', 'a')
|
||||||
|
|
||||||
def testLithp(self):
|
def testLithp(self):
|
||||||
self.assertResponse('lithp jamessan', 'jamethan')
|
self.assertResponse('lithp jamessan', 'jamethan')
|
||||||
self.assertResponse('lithp Shame', 'Thame')
|
self.assertResponse('lithp Shame', 'Thame')
|
||||||
|
Loading…
Reference in New Issue
Block a user