mirror of https://github.com/Mikaela/Limnoria.git
Merge pull request #1167 from GLolol/filter/unbinary-strip-spaces
Filter: strip spaces in "unbinary" (Closes #1166)
This commit is contained in:
commit
7c0e9c77d4
|
@ -118,14 +118,16 @@ class Filter(callbacks.Plugin):
|
||||||
irc.reply(self._hebrew_remover(text))
|
irc.reply(self._hebrew_remover(text))
|
||||||
hebrew = wrap(hebrew, ['text'])
|
hebrew = wrap(hebrew, ['text'])
|
||||||
|
|
||||||
|
def _squish(self, text):
|
||||||
|
return text.replace(' ', '')
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
def squish(self, irc, msg, args, text):
|
def squish(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
Removes all the spaces from <text>.
|
Removes all the spaces from <text>.
|
||||||
"""
|
"""
|
||||||
text = ''.join(text.split())
|
irc.reply(self._squish(text))
|
||||||
irc.reply(text)
|
|
||||||
squish = wrap(squish, ['text'])
|
squish = wrap(squish, ['text'])
|
||||||
|
|
||||||
@internationalizeDocstring
|
@internationalizeDocstring
|
||||||
|
@ -182,6 +184,7 @@ class Filter(callbacks.Plugin):
|
||||||
Returns the character representation of binary <text>.
|
Returns the character representation of binary <text>.
|
||||||
Assumes ASCII, 8 digits per character.
|
Assumes ASCII, 8 digits per character.
|
||||||
"""
|
"""
|
||||||
|
text = self._squish(text) # Strip spaces.
|
||||||
try:
|
try:
|
||||||
L = [chr(int(text[i:(i+8)], 2)) for i in range(0, len(text), 8)]
|
L = [chr(int(text[i:(i+8)], 2)) for i in range(0, len(text), 8)]
|
||||||
irc.reply(''.join(L))
|
irc.reply(''.join(L))
|
||||||
|
|
|
@ -86,13 +86,11 @@ 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 testUnbinary(self):
|
def testUnbinary(self):
|
||||||
self.assertResponse('unbinary 011011010110111101101111', 'moo')
|
self.assertResponse('unbinary 011011010110111101101111', 'moo')
|
||||||
self.assertError('unbinary moo')
|
self.assertError('unbinary moo')
|
||||||
|
self.assertResponse('unbinary 01101101 01101111 01101111', 'moo')
|
||||||
|
|
||||||
def testRot13(self):
|
def testRot13(self):
|
||||||
for s in map(str, range(1000, 1010)):
|
for s in map(str, range(1000, 1010)):
|
||||||
|
|
Loading…
Reference in New Issue