From d4442a04ffb267130878e6b8708161bad78b2e58 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 3 Dec 2003 01:55:19 +0000 Subject: [PATCH] Slightly tweaked, added test. --- plugins/Fun.py | 4 +++- test/test_Fun.py | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/Fun.py b/plugins/Fun.py index 448e40430..d65f10375 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -510,8 +510,10 @@ class Fun(callbacks.Privmsg): """ nick = msg.nick channel = msg.args[0] + if not ircutils.isChannel(channel): + irc.error(msg, 'This message must be sent in a channel.') if random.randint(1, 6) == 1: - irc.queueMsg(ircmsgs.kick(channel, nick)) + irc.queueMsg(ircmsgs.kick(channel, nick, 'BANG!')) else: irc.reply(msg, '*click*') diff --git a/test/test_Fun.py b/test/test_Fun.py index 83dece44a..f2b5a1a8f 100644 --- a/test/test_Fun.py +++ b/test/test_Fun.py @@ -37,6 +37,19 @@ import utils class FunTest(ChannelPluginTestCase, PluginDocumentation): plugins = ('Fun',) + def testRoulette(self): + sawKick = False + for i in xrange(100): + m = self.getMsg('roulette') + if m.command == 'PRIVMSG': + self.failUnless('click' in m.args[1].lower()) + elif m.command == 'KICK': + sawKick = True + self.failUnless('bang' in m.args[2].lower()) + else: + self.fail('Got something other than a kick or a privmsg.') + self.failUnless(sawKick, 'Didn\'t get a kick in %s iterations!' % i) + def testNoErrors(self): self.assertNotError('leet foobar') self.assertNotError('lithp meghan sweeney')