From bd12e46731d02595ff16e9910457688eb97d4148 Mon Sep 17 00:00:00 2001 From: Yizhe Shen Date: Fri, 13 Jun 2014 03:33:01 -0400 Subject: [PATCH] Updated 'stop' command. (issue #299) - 'stop' command only responds in-channel now - Partial refactoring of stop() --- plugin.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/plugin.py b/plugin.py index c8ffb0d..90317d8 100644 --- a/plugin.py +++ b/plugin.py @@ -1250,29 +1250,28 @@ class TriviaTime(callbacks.Plugin): start = wrap(start, ['onlyInChannel']) def stop(self, irc, msg, args, user, channel): - """[] + """ Stops the current Trivia round. - Channel is only necessary when using from outside of the channel """ channelCanonical = ircutils.toLower(channel) game = self.getGame(irc, channel) - if game is not None: - if game.questionOver == True: - game.stop() - return - if game.stopPending: - irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia is already pending stop')) - return - if game.active: - game.stopPending = True - irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia will now stop after this question.')) - else: - self.deleteGame(irc, channel) - irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia stopped. :\'(')) - else: + if game is None: irc.sendMsg(ircmsgs.privmsg(channel, 'Game is already stopped')) + elif game.questionOver == True: + game.stop() + return + elif game.stopPending: + irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia is already pending stop')) + return + elif game.active: + game.stopPending = True + irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia will now stop after this question.')) + else: + self.deleteGame(irc, channel) + irc.sendMsg(ircmsgs.privmsg(channel, 'Trivia stopped. :\'(')) + irc.noReply() - stop = wrap(stop, ['user', 'channel']) + stop = wrap(stop, ['user', 'onlyInChannel']) def time(self, irc, msg, arg): """