]> jfr.im git - erebus.git/commitdiff
trivia - two bugfixes
authorJohn Runyon <redacted>
Sun, 30 Jan 2022 08:23:16 +0000 (02:23 -0600)
committerJohn Runyon <redacted>
Sun, 30 Jan 2022 08:23:16 +0000 (02:23 -0600)
- make SETNEXTID work even when the question has been asked recently

- try even harder to send long questions

modules/trivia.py

index 1ad319eb0bf42b46f8b88a00fe7ceb214c74ed11..cf67a2a3ca907afad1c226d054b3c2770909828b 100644 (file)
@@ -331,6 +331,7 @@ class TriviaState(object):
                elif self.nextqid is not None:
                        nextqid = self.nextqid
                        nextq = self.questions[nextqid]
+                       if len(nextq) > 2: nextq[2] = 0 # Unset the time it was last asked.
                        self.nextqid = None
                else:
                        nextqid = random.randrange(0, len(self.questions))
@@ -363,9 +364,10 @@ class TriviaState(object):
                        qtext += "\00304,01"+qword+"\00301,01"+chr(spacer) #a-z
                if not self.getbot().fastmsg(self.chan, qtext): #if message is too long:
                        if not self.getbot().fastmsg(self.chan, "\00312,01Next up: " + ("(%5d)" % (random.randint(0,99999))) + "\00304,01" + nextq[0]):
-                               if nextqid is None: nextqid = "manual"
-                               self.getbot().slowmsg(self.chan, "(Unable to ask question #%s: line too long)" % (nextqid))
-                               return self._nextquestion(iteration) #retry; don't increment the iteration
+                               if not self.getbot().fastmsg(self.chan, "Next up: " + nextq[0]):
+                                       if nextqid is None: nextqid = "manual"
+                                       self.getbot().slowmsg(self.chan, "(Unable to ask question #%s: line too long)" % (nextqid))
+                                       return self._nextquestion(iteration) #retry; don't increment the iteration
 
                self.curq = nextq
                self.curqid = nextqid