diff --git a/plugins/Filter/plugin.py b/plugins/Filter/plugin.py index 9cc264465..fcc247116 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..2a73e5f9f 100644 --- a/plugins/Filter/test.py +++ b/plugins/Filter/test.py @@ -87,6 +87,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)): self.assertResponse('rot13 [rot13 %s]' % s, s)