mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Filter: catch invalid input for unbinary command.
This commit is contained in:
parent
920c37c314
commit
4aa876255c
@ -162,8 +162,11 @@ 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.
|
||||||
"""
|
"""
|
||||||
L = [chr(int(text[i:(i+8)], 2)) for i in xrange(0, len(text), 8)]
|
try:
|
||||||
irc.reply(''.join(L))
|
L = [chr(int(text[i:(i+8)], 2)) for i in xrange(0, len(text), 8)]
|
||||||
|
irc.reply(''.join(L))
|
||||||
|
except ValueError:
|
||||||
|
irc.error('Invalid input.')
|
||||||
unbinary = wrap(unbinary, ['text'])
|
unbinary = wrap(unbinary, ['text'])
|
||||||
|
|
||||||
def hexlify(self, irc, msg, args, text):
|
def hexlify(self, irc, msg, args, text):
|
||||||
|
@ -89,6 +89,7 @@ class FilterTest(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testUnbinary(self):
|
def testUnbinary(self):
|
||||||
self.assertResponse('unbinary 011011010110111101101111', 'moo')
|
self.assertResponse('unbinary 011011010110111101101111', 'moo')
|
||||||
|
self.assertError('unbinary 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
Block a user