diff --git a/plugins/Filter.py b/plugins/Filter.py index dac72bc59..7ebf1afe7 100644 --- a/plugins/Filter.py +++ b/plugins/Filter.py @@ -97,7 +97,7 @@ class Filter(callbacks.Privmsg): _filterCommands = ['jeffk', 'leet', 'rot13', 'hexlify', 'binary', 'lithp', 'scramble', 'morse', 'reverse', 'colorize', 'squish', 'supa1337', 'colorstrip', 'aol', 'rainbow', 'spellit', - 'hebrew'] + 'hebrew', 'undup'] def outfilter(self, irc, msg, args, channel, command): """[] [] @@ -138,6 +138,18 @@ class Filter(callbacks.Privmsg): irc.reply(text) squish = wrap(squish, ['text']) + def undup(self, irc, msg, args, text): + """ + + Returns , 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): """ diff --git a/test/test_Filter.py b/test/test_Filter.py index 4a9098dd3..f29a96955 100644 --- a/test/test_Filter.py +++ b/test/test_Filter.py @@ -53,6 +53,10 @@ class FilterTest(ChannelPluginTestCase, PluginDocumentation): 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): self.assertResponse('lithp jamessan', 'jamethan') self.assertResponse('lithp Shame', 'Thame')