diff --git a/plugins/Filter/plugin.py b/plugins/Filter/plugin.py index cd0905b08..c7247bcf5 100644 --- a/plugins/Filter/plugin.py +++ b/plugins/Filter/plugin.py @@ -156,6 +156,16 @@ class Filter(callbacks.Plugin): irc.reply(''.join(L)) binary = wrap(binary, ['text']) + def unbinary(self, irc, msg, args, text): + """ + + Returns the character representation of binary . + Assumes ASCII, 8 digits per character. + """ + L = [chr(int(text[i:(i+8)], 2)) for i in xrange(0, len(text), 8)] + irc.reply(''.join(L)) + unbinary = wrap(unbinary, ['text']) + def hexlify(self, irc, msg, args, text): """ diff --git a/plugins/Filter/test.py b/plugins/Filter/test.py index d31959f66..9c76e4331 100644 --- a/plugins/Filter/test.py +++ b/plugins/Filter/test.py @@ -86,6 +86,9 @@ class FilterTest(ChannelPluginTestCase): def testBinary(self): self.assertResponse('binary A', '01000001') + + def testUnbinary(self): + self.assertResponse('unbinary 011011010110111101101111', 'moo') def testRot13(self): for s in map(str, range(1000, 1010)):