From: Orillion Date: Sun, 19 Nov 2017 09:07:44 +0000 (+0100) Subject: Allow channel half operators or higher to skip a trivia question X-Git-Url: https://jfr.im/git/irc/rizon/acid.git/commitdiff_plain/520ccd8f66dce51f4e5f231f31490efa49ea3c3c?ds=sidebyside;hp=11b922ba27da9f7865e310fc1d1132ea310e335a Allow channel half operators or higher to skip a trivia question --- diff --git a/pyva/pyva/src/main/python/trivia/trivia.py b/pyva/pyva/src/main/python/trivia/trivia.py index d8db1a8..8ff7f8b 100644 --- a/pyva/pyva/src/main/python/trivia/trivia.py +++ b/pyva/pyva/src/main/python/trivia/trivia.py @@ -22,6 +22,7 @@ import cmd_admin, sys_auth, trivia_engine import pyva_net_rizon_acid_core_Acidictive as Acidictive import pyva_net_rizon_acid_core_AcidCore as AcidCore import pyva_net_rizon_acid_core_User as User +import pyva_net_rizon_acid_core_Channel as Channel class trivia( AcidPlugin, @@ -181,6 +182,13 @@ class trivia( cid = self.dbp.fetchone()[0] return cid + def skip_trivia(self, cname): + '''Skips a trivia question and moves on to the next''' + if istring(cname) not in self.trivias: + return + + self.trivias[istring(cname)].skip() + def stop_trivia(self, cname, forced): '''Stops a trivia instance and removes it from our dict.''' if istring(cname) not in self.trivias: @@ -231,8 +239,7 @@ class trivia( self.notice(sender, "Trivia: .strivia - to stop current round.") self.notice(sender, "Trivia: .topten/.tt - lists top ten players.") self.notice(sender, "Trivia: .rank [nick] - shows yours or given nicks current rank.") - # Defunct in orig trivia - #self.notice(sender, "Trivia: .next - skips question.") + self.notice(sender, "Trivia: .next - skips question. (Must be half operator or higher on the channel)") self.notice(sender, "Trivia: .themes - lists available question themes.") self.notice(sender, "Trivia: .theme set - changes current question theme (must be channel founder).") elif command == 'trivia': @@ -302,6 +309,22 @@ class trivia( self.notice(sender, "Checking if you are the channel founder.") self.auth.request(sender, channel, 'set_theme_' + args[1]) + elif command == 'skip' or command == 'next': + channelObj = Channel.findChannel(channel); + + if not channelObj: + return + + membership = channelObj.findUser(userinfo) + + if not membership: + return + + if not membership.isOp(): + self.notice(sender, "You're not an (half)operator on the channel") + return + + self.skip_trivia(channel) else: # not a command, but might be an answer! if istring(channel) not in self.trivias: return # no trivia running, disregard that diff --git a/pyva/pyva/src/main/python/trivia/trivia_engine.py b/pyva/pyva/src/main/python/trivia/trivia_engine.py index 26827e8..29e664b 100644 --- a/pyva/pyva/src/main/python/trivia/trivia_engine.py +++ b/pyva/pyva/src/main/python/trivia/trivia_engine.py @@ -266,3 +266,17 @@ class Trivia(object): self.module.msg(self.cname, msg + " '.trivia [number]' to start playing again.") + def skip(self): + '''Stops the current question and asks the next question''' + try: + self.question_timer.stop() + self.hint_timer.stop() + except AttributeError: + return + + self.answer = [] + self.hints_given = 0 + self.hint_timer = task.LoopingCall(self.ask) + self.hint_timer.start(5, False) + + self.module.msg(self.cname, "Skipping question")