mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Filter: add unbinary command, as counterpart to binary command.
This commit is contained in:
parent
6ccd1ce3d6
commit
f6c9543dc3
@ -163,6 +163,17 @@ class Filter(callbacks.Plugin):
|
|||||||
irc.reply(''.join(L))
|
irc.reply(''.join(L))
|
||||||
binary = wrap(binary, ['text'])
|
binary = wrap(binary, ['text'])
|
||||||
|
|
||||||
|
@internationalizeDocstring
|
||||||
|
def unbinary(self, irc, msg, args, text):
|
||||||
|
"""<text>
|
||||||
|
|
||||||
|
Returns the character representation of binary <text>.
|
||||||
|
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'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def hexlify(self, irc, msg, args, text):
|
def hexlify(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
@ -87,6 +87,9 @@ class FilterTest(ChannelPluginTestCase):
|
|||||||
def testBinary(self):
|
def testBinary(self):
|
||||||
self.assertResponse('binary A', '01000001')
|
self.assertResponse('binary A', '01000001')
|
||||||
|
|
||||||
|
def testUnbinary(self):
|
||||||
|
self.assertResponse('unbinary 011011010110111101101111', 'moo')
|
||||||
|
|
||||||
def testRot13(self):
|
def testRot13(self):
|
||||||
for s in map(str, range(1000, 1010)):
|
for s in map(str, range(1000, 1010)):
|
||||||
self.assertResponse('rot13 [rot13 %s]' % s, s)
|
self.assertResponse('rot13 [rot13 %s]' % s, s)
|
||||||
|
Loading…
Reference in New Issue
Block a user