diff --git a/src/Channel.py b/src/Channel.py index 13fec327a..84feb2aad 100755 --- a/src/Channel.py +++ b/src/Channel.py @@ -183,7 +183,11 @@ class Channel(callbacks.Privmsg): self.log.warning('%r tried to make me kban myself.', msg.prefix) irc.error(msg, 'I cowardly refuse to kickban myself.') return - length = int(length or 0) + try: + length = int(length or 0) + except ValueError: + irc.error(msg, 'Ban length must be a valid integer.') + return try: bannedHostmask = irc.state.nickToHostmask(bannedNick) except KeyError: diff --git a/test/test_Channel.py b/test/test_Channel.py index 85c8ac69b..66b89bb0d 100644 --- a/test/test_Channel.py +++ b/test/test_Channel.py @@ -96,6 +96,7 @@ class ChannelTestCase(ChannelPluginTestCase, PluginDocumentation): m = self.getMsg(' ') self.assertEqual(m, ircmsgs.kick(self.channel, 'foobar', self.nick)) self.assertNotRegexp('kban adlkfajsdlfkjsd', 'KeyError') + self.assertNotRegexp('kban foobar time', 'ValueError') self.assertError('kban %s' % self.nick) def testLobotomizers(self):