]> jfr.im git - irc/rizon/acid.git/blobdiff - pyva/pyva/src/main/python/trivia/trivia.py
Allow channel half operators or higher to skip a trivia question
[irc/rizon/acid.git] / pyva / pyva / src / main / python / trivia / trivia.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