]> jfr.im git - irc/rizon/acid.git/commitdiff
Allow channel half operators or higher to skip a trivia question
authorOrillion <redacted>
Sun, 19 Nov 2017 09:07:44 +0000 (10:07 +0100)
committerOrillion <redacted>
Sun, 19 Nov 2017 09:07:44 +0000 (10:07 +0100)
pyva/pyva/src/main/python/trivia/trivia.py
pyva/pyva/src/main/python/trivia/trivia_engine.py

index d8db1a8667b9adc7818e145fca60194405ae1d01..8ff7f8b951a6f97d95063a27cdaf0666b2fb0d6e 100644 (file)
@@ -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 <name> - 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
index 26827e8be981a0f1a4891122129f3452a5bdc7d8..29e664b91b6821c2ef8f45e7c5beb1e443906497 100644 (file)
@@ -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")