def endPointVote(self):
self.getchan().msg("Voting has ended!")
- votelist = sorted(self.voteamounts.items(), key=lambda item: item[1]) #sort into list of tuples: [(option, number_of_votes), ...]
+ votelist = sorted(self.voteamounts.items(), key=lambda item: (item[1], -item[0])) #sort into list of tuples: [(option, number_of_votes), ...]
for i in range(len(votelist)-1):
item = votelist[i]
self.getchan().msg("%s place: %s (%s votes)" % (len(votelist)-i, item[0], item[1]))
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))
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
# "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen",
# "sixteen", "seventeen", "eighteen", "nineteen", "twenty"
# ][num]
+
+
+def topa():
+ answers=__import__('collections').defaultdict(int)
+ for a in (x[1] for x in state.db['questions']['general']):
+ answers[a]+=1;
+ a2=[]
+ for a, num in answers.items():
+ a2.append((a, num))
+ a2.sort(key=lambda v: v[1], reverse=True)
+ return a2