TriviaTime: various fixes.

This commit is contained in:
oddluck 2020-02-06 21:54:53 +00:00
parent 64a2b4362c
commit ab0940a95f
6 changed files with 219 additions and 110 deletions

View File

@ -1,3 +1,10 @@
# Questions
storage/
!storage/db/
# Configurations
config.php
*.py[cod] *.py[cod]
# C extensions # C extensions

View File

@ -1,8 +1,4 @@
Forked from https://github.com/tannn/TriviaTime # Configuration
#Configuration
See Jeopardy plugin for using jservice.io (156,800+ Jeopardy! questions) as trivia question source
Requires Limnoria and Python 3 Requires Limnoria and Python 3
@ -30,7 +26,33 @@ Requires Limnoria and Python 3
## Question editing tools ## Question editing tools
TriviaTime was designed to make editing, deleting, and adding questions a breeze, for both administrators and players. However, due to the amount of tools available, it can be complicated to new players. Instructions on these tools are available [here][]. TriviaTime was designed to make editing, deleting, and adding questions a breeze, for both administrators and players. However, due to the amount of tools available, it can be complicated to new players. Instructions on these tools are available [here][].
#How to set up the website ## How to modify configuration
Do not touch `config.py` or any other configuration file. Instead, use the Config plugin on IRC:
```
.config plugins.pluginName.parameterGroup.parameterName value
```
Examples:
```
# Modify duration of time in between hints to 15 seconds:
.config plugins.triviatime.questions.hinttime 15
# Modify duration of time in between KAOS hints to 20 seconds:
.config plugins.triviatime.kaos.hintkaos 20
# Modify command to show additional hint to ~:
.config plugins.triviatime.commands.extraHint ~
```
For a full list of general Limnoria configuration parameters, see the `.conf` file in the bot base directory.
For a full list of TriviaTime configuration parameters, refer to `config.py` in the `TriviaTime/` directory.
---
# How to set up the website
## Download and Install ## Download and Install
1. Install PHP (for PDO) and PHP-SQLite. 1. Install PHP (for PDO) and PHP-SQLite.

View File

@ -42,7 +42,7 @@ conf.registerChannelValue(TriviaTime.admin, 'file',
# timeout, number of hints, values # timeout, number of hints, values
conf.registerChannelValue(TriviaTime.commands, 'extraHint', conf.registerChannelValue(TriviaTime.commands, 'extraHint',
registry.NormalizedString(""".""", registry.NormalizedString("""~""",
"""The command to show extra hints and remaining KAOS""") """The command to show extra hints and remaining KAOS""")
) )
@ -57,7 +57,7 @@ conf.registerChannelValue(TriviaTime.general, 'globalStats',
) )
conf.registerChannelValue(TriviaTime.hints, 'extraHintTime', conf.registerChannelValue(TriviaTime.hints, 'extraHintTime',
registry.Integer(90, registry.Integer(10,
"""Number of seconds a user must wait between uses of the extra hint command.""") """Number of seconds a user must wait between uses of the extra hint command.""")
) )
@ -72,12 +72,12 @@ conf.registerChannelValue(TriviaTime.general, 'showStats',
) )
conf.registerChannelValue(TriviaTime.skip, 'skipThreshold', conf.registerChannelValue(TriviaTime.skip, 'skipThreshold',
registry.Float(.5, registry.Float(.50,
"""Percentage of active players who need to vote for a question to be skipped""") """Percentage of active players who need to vote for a question to be skipped""")
) )
conf.registerChannelValue(TriviaTime.skip, 'skipActiveTime', conf.registerChannelValue(TriviaTime.skip, 'skipActiveTime',
registry.Integer((10*60), registry.Integer((30*60),
"""Amount of seconds a user is considered active after answering a question""") """Amount of seconds a user is considered active after answering a question""")
) )
@ -87,22 +87,22 @@ conf.registerChannelValue(TriviaTime.skip, 'skipTime',
) )
conf.registerChannelValue(TriviaTime.questions, 'hintTime', conf.registerChannelValue(TriviaTime.questions, 'hintTime',
registry.Integer(10, registry.Integer(15,
"""Seconds between hints""") """Seconds between hints""")
) )
conf.registerChannelValue(TriviaTime.kaos, 'hintKAOS', conf.registerChannelValue(TriviaTime.kaos, 'hintKAOS',
registry.Integer(15, registry.Integer(20,
"""Seconds between KAOS hints""") """Seconds between KAOS hints""")
) )
conf.registerChannelValue(TriviaTime.general, 'waitTime', conf.registerChannelValue(TriviaTime.general, 'waitTime',
registry.Integer(15, registry.Integer(20,
"""Seconds between the end of one question and the start of another""") """Seconds between the end of one question and the start of another""")
) )
conf.registerChannelValue(TriviaTime.voice, 'enableVoice', conf.registerChannelValue(TriviaTime.voice, 'enableVoice',
registry.Boolean(True, registry.Boolean(False,
"""Voice top players for week, month, and year""") """Voice top players for week, month, and year""")
) )
@ -117,42 +117,42 @@ conf.registerChannelValue(TriviaTime.voice, 'timeoutVoice',
) )
conf.registerChannelValue(TriviaTime.voice, 'numTopToVoice', conf.registerChannelValue(TriviaTime.voice, 'numTopToVoice',
registry.Integer(10, registry.Integer(25,
"""The number of top players who are elligible for voice""") """The number of top players who are elligible for voice""")
) )
conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceWeek', conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceWeek',
registry.Integer(30000, registry.Integer(750,
"""Points required to be voiced for being top player in the week""") """Points required to be voiced for being top player in the week""")
) )
conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceMonth', conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceMonth',
registry.Integer(100000, registry.Integer(5000,
"""Points required to be voiced for being top player in the month""") """Points required to be voiced for being top player in the month""")
) )
conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceYear', conf.registerChannelValue(TriviaTime.voice, 'minPointsVoiceYear',
registry.Integer(5000000, registry.Integer(25000,
"""Points required to be voiced for being top player in the year""") """Points required to be voiced for being top player in the year""")
) )
conf.registerChannelValue(TriviaTime.kaos, 'payoutKAOS', conf.registerChannelValue(TriviaTime.kaos, 'payoutKAOS',
registry.Integer(1000, registry.Integer(10,
"""Extra points for teamwork on KAOS""") """Extra points for teamwork on KAOS""")
) )
conf.registerChannelValue(TriviaTime.general, 'timeout', conf.registerChannelValue(TriviaTime.general, 'timeout',
registry.Integer(600, registry.Integer(604800,
"""Time before game shuts off in seconds""") """Time before game shuts off in seconds""")
) )
conf.registerChannelValue(TriviaTime.questions, 'defaultPoints', conf.registerChannelValue(TriviaTime.questions, 'defaultPoints',
registry.Integer(500, registry.Integer(10,
"""Default points for a correct answer to a normal question""") """Default points for a correct answer to a normal question""")
) )
conf.registerChannelValue(TriviaTime.kaos, 'defaultKAOS', conf.registerChannelValue(TriviaTime.kaos, 'defaultKAOS',
registry.Integer(300, registry.Integer(15,
"""Default points for a correct KAOS answer""") """Default points for a correct KAOS answer""")
) )

View File

@ -1,6 +1,6 @@
<div class="hero-unit"> <div class="hero-unit">
<h1>About TriviaTime</h1> <h1>About TriviaTime</h1>
<p>We are <a href="irc://irc.freenode.net/#trivialand">#trivialand</a> on Freenode. Come join us!</p> <p>We are <a href="irc://irc.snoonet.org/#trivia">#trivia</a> on Snoonet. Come join us!</p>
</div> </div>
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
@ -11,7 +11,7 @@
<div class="row"> <div class="row">
<div class="span12"> <div class="span12">
<h2>Source</h2> <h2>Source</h2>
<p>The source code is available on <a target="_blank" href="https://github.com/tannn/TriviaTime">GitHub</a>, be sure to check it out. <p>The source code is available on <a target="_blank" href="https://github.com/oddluck/limnoria-plugins">GitHub</a>, be sure to check it out.
Fork us and contribute!</p> Fork us and contribute!</p>
</div> </div>
</div> </div>

View File

@ -1,5 +1,5 @@
<div class="footer"> <div class="footer">
<p>&copy; Trivialand 2013 - <a target="_blank" href="https://github.com/tannn/TriviaTime">GitHub</a></p> <p><a target="_blank" href="https://github.com/oddluck/limnoria-plugins">GitHub</a></p>
</div> </div>
</div> <!-- /container --> </div> <!-- /container -->

View File

@ -194,14 +194,14 @@ class Game:
if ircutils.toLower(self.lastWinner) != usernameCanonical: if ircutils.toLower(self.lastWinner) != usernameCanonical:
#streakbreak #streakbreak
if self.streak > minStreak: if self.streak > minStreak:
streakBonus = points * .05 streakBonus = int(points * .25)
self.sendMessage('\x02%s\x02 broke \x02%s\x02\'s streak of \x02%d\x02!' % (username, self.lastWinner, self.streak)) self.sendMessage('\x02%s\x02 broke \x02%s\x02\'s streak of \x02%d\x02!' % (username, self.lastWinner, self.streak))
self.lastWinner = username self.lastWinner = username
self.streak = 1 self.streak = 1
else: else:
self.streak += 1 self.streak += 1
streakBonus = points * .01 * (self.streak-1) streakBonus = points * .25 * (self.streak-1)
streakBonus = min(streakBonus, points * .5) streakBonus = int(min(streakBonus, points * .25))
# Update database # Update database
threadStorage.updateGameStreak(self.channel, self.lastWinner, self.streak) threadStorage.updateGameStreak(self.channel, self.lastWinner, self.streak)
@ -212,7 +212,7 @@ class Game:
# Show congratulatory message # Show congratulatory message
self.lastAnswer = time.time() self.lastAnswer = time.time()
self.sendMessage('DING DING DING, \x02%s\x02 got the correct answer, \x02%s\x02, in \x02%0.4f\x02 seconds for \x02%d(+%d)\x02 points!' % (username, correctAnswer, timeElapsed, points, streakBonus)) self.sendMessage('YES, \x02%s\x02 got the correct answer, \x02%s\x02, in \x02%0.4f\x02 seconds for \x02%d(+%d)\x02 points!' % (username, correctAnswer, timeElapsed, points, streakBonus))
if self.registryValue('general.showStats', self.channel): if self.registryValue('general.showStats', self.channel):
if self.registryValue('general.globalStats'): if self.registryValue('general.globalStats'):
@ -224,16 +224,19 @@ class Game:
todaysScore = stat['points_day'] todaysScore = stat['points_day']
weekScore = stat['points_week'] weekScore = stat['points_week']
monthScore = stat['points_month'] monthScore = stat['points_month']
yearScore = stat['points_year']
totalScore = stat['points_total']
recapMessageList = ['\x02%s\x02 has won \x02%d\x02 in a row!' % (username, self.streak)] recapMessageList = ['\x02%s\x02 has won \x02%d\x02 in a row!' % (username, self.streak)]
recapMessageList.append(' Total Points') recapMessageList.append(' Total Points')
recapMessageList.append(' TODAY: \x02%d\x02' % (todaysScore)) recapMessageList.append(' TODAY: \x02%d\x02' % (todaysScore))
if weekScore > points: if weekScore > points:
recapMessageList.append(' this WEEK \x02%d\x02' % (weekScore)) recapMessageList.append(' this WEEK: \x02%d\x02' % (weekScore))
if weekScore > points or todaysScore > points:
if monthScore > points:
recapMessageList.append(' &')
if monthScore > points: if monthScore > points:
recapMessageList.append(' this MONTH: \x02%d\x02' % (monthScore)) recapMessageList.append(' this MONTH: \x02%d\x02' % (monthScore))
if yearScore > points:
recapMessageList.append(' this YEAR: \x02%d\x02' % (yearScore))
if totalScore > points:
recapMessageList.append(' & ALL TIME: \x02%d\x02' % (totalScore))
recapMessage = ''.join(recapMessageList) recapMessage = ''.join(recapMessageList)
self.sendMessage(recapMessage) self.sendMessage(recapMessage)
@ -587,12 +590,13 @@ class Game:
if len(questionParts) > 1: if len(questionParts) > 1:
question = questionParts[0].strip() question = questionParts[0].strip()
answers = [] answers = []
# Parse question and answers # Parse question for KAOS
if ircutils.toLower(question[:4]) == 'kaos': if ircutils.toLower(question[:4]) == 'kaos':
questionType = 'kaos' questionType = 'kaos'
for ans in questionParts[1:]: for ans in questionParts[1:]:
if answers.count(ans) == 0: # Filter out duplicate answers if answers.count(ans) == 0: # Filter out duplicate answers
answers.append(str(ans).strip()) answers.append(str(ans).strip())
# Parse question for Unscramble
elif ircutils.toLower(question[:5]) == 'uword': elif ircutils.toLower(question[:5]) == 'uword':
questionType = 'uword' questionType = 'uword'
ans = questionParts[1] ans = questionParts[1]
@ -600,11 +604,13 @@ class Game:
shuffledLetters = list(str(ans)) shuffledLetters = list(str(ans))
random.shuffle(shuffledLetters) random.shuffle(shuffledLetters)
question = 'Unscramble the letters: {0}'.format(' '.join(shuffledLetters)) question = 'Unscramble the letters: {0}'.format(' '.join(shuffledLetters))
# Parse standard question
else: else:
questionType = 'regular' questionType = 'regular'
for ans in questionParts[1:]: for ans in questionParts[1:]:
answers.append(str(ans).strip()) answers.append(str(ans).strip())
# Calculate base points
if questionType == 'kaos': if questionType == 'kaos':
points = self.registryValue('kaos.defaultKAOS', self.channel) * len(answers) points = self.registryValue('kaos.defaultKAOS', self.channel) * len(answers)
else: else:
@ -628,9 +634,9 @@ class Game:
# default question, everything went wrong with grabbing question # default question, everything went wrong with grabbing question
return {'id': rawData['id'], return {'id': rawData['id'],
'type': 'kaos', 'type': 'kaos',
'points': 10050, 'points': 10,
'question': 'KAOS: The 10 Worst U.S. Presidents (Last Name Only)? (This is a panic question, if you see this report this question. it is malformed.)', 'question': 'KAOS: The most awesome users in this channel? (This is a panic question, if you see this report this question. it is malformed. Please report immediately.)',
'answers': ['Bush', 'Nixon', 'Hoover', 'Grant', 'Johnson', 'Ford', 'Reagan', 'Coolidge', 'Pierce'] 'answers': ['cars', 'some_weirdo', 'kessa', 'paimun']
} }
def sendMessage(self, msg, color=None, bgcolor=None): def sendMessage(self, msg, color=None, bgcolor=None):
@ -1452,11 +1458,11 @@ class Storage:
c.close() c.close()
return row return row
def getDeleteTop3(self, page=1, amount=3, channel=None): def getDeleteTop5(self, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page=1 page=1
if amount < 1: if amount < 1:
amount=3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -1493,11 +1499,11 @@ class Storage:
c.close() c.close()
return row return row
def getReportTop3(self, page=1, amount=3, channel=None): def getReportTop5(self, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page=1 page=1
if amount < 1: if amount < 1:
amount=3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -1516,11 +1522,11 @@ class Storage:
c.close() c.close()
return rows return rows
def getTemporaryQuestionTop3(self, page=1, amount=3, channel=None): def getTemporaryQuestionTop5(self, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page=1 page=1
if amount < 1: if amount < 1:
amount=3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -1558,11 +1564,11 @@ class Storage:
c.close() c.close()
return row return row
def getEditTop3(self, page=1, amount=3, channel=None): def getEditTop5(self, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page = 1 page = 1
if amount < 1: if amount < 1:
amount = 3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -1581,11 +1587,11 @@ class Storage:
c.close() c.close()
return rows return rows
def getNotMyEditTop3(self, username, page=1, amount=3, channel=None): def getNotMyEditTop5(self, username, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page = 1 page = 1
if amount < 1: if amount < 1:
amount = 3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -1606,11 +1612,11 @@ class Storage:
c.close() c.close()
return rows return rows
def getMyEditTop3(self, username, page=1, amount=3, channel=None): def getMyEditTop5(self, username, page=1, amount=5, channel=None):
if page < 1: if page < 1:
page = 1 page = 1
if amount < 1: if amount < 1:
amount = 3 amount = 5
page -= 1 page -= 1
start = page * amount start = page * amount
c = self.conn.cursor() c = self.conn.cursor()
@ -3110,7 +3116,7 @@ class TriviaTime(callbacks.Plugin):
delete = threadStorage.getDeleteById(num, channel) delete = threadStorage.getDeleteById(num, channel)
if delete: if delete:
if username == delete['username']: if username == delete['username'] and self.isTriviaMod(hostmask, channel) == False:
irc.reply('You cannot accept your own deletion request.') irc.reply('You cannot accept your own deletion request.')
else: else:
questionNumber = delete['line_num'] questionNumber = delete['line_num']
@ -3304,7 +3310,10 @@ class TriviaTime(callbacks.Plugin):
Parameter is optional, display up to that number. (eg 20 - display 11-20) Parameter is optional, display up to that number. (eg 20 - display 11-20)
Channel is only required when using the command outside of a channel. Channel is only required when using the command outside of a channel.
""" """
num = max(num, 10) if num is not None:
num = max(num, 10)
else:
num = 10
offset = num-9 offset = num-9
dbLocation = self.registryValue('admin.db') dbLocation = self.registryValue('admin.db')
threadStorage = Storage(dbLocation) threadStorage = Storage(dbLocation)
@ -3433,12 +3442,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countDeletes() count = threadStorage.countDeletes()
else: else:
count = threadStorage.countDeletes(channel) count = threadStorage.countDeletes(channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
deletes = threadStorage.getDeleteTop3(page)
else: else:
deletes = threadStorage.getDeleteTop3(page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
deletes = threadStorage.getDeleteTop5(page)
else:
deletes = threadStorage.getDeleteTop5(page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3472,12 +3484,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countEdits() count = threadStorage.countEdits()
else: else:
count = threadStorage.countEdits(channel) count = threadStorage.countEdits(channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
edits = threadStorage.getEditTop3(page)
else: else:
edits = threadStorage.getEditTop3(page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
edits = threadStorage.getEditTop5(page)
else:
edits = threadStorage.getEditTop5(page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3510,12 +3525,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countMyEdits(username) count = threadStorage.countMyEdits(username)
else: else:
count = threadStorage.countMyEdits(username, channel) count = threadStorage.countMyEdits(username, channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
edits = threadStorage.getMyEditTop3(username, page)
else: else:
edits = threadStorage.getMyEditTop3(username, page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
edits = threadStorage.getMyEditTop5(username, page)
else:
edits = threadStorage.getMyEditTop5(username, page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3548,12 +3566,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countNotMyEdits(username) count = threadStorage.countNotMyEdits(username)
else: else:
count = threadStorage.countNotMyEdits(username, channel) count = threadStorage.countNotMyEdits(username, channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
edits = threadStorage.getNotMyEditTop3(username, page)
else: else:
edits = threadStorage.getNotMyEditTop3(username, page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
edits = threadStorage.getNotMyEditTop5(username, page)
else:
edits = threadStorage.getNotMyEditTop5(username, page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3580,12 +3601,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countReports() count = threadStorage.countReports()
else: else:
count = threadStorage.countReports(channel) count = threadStorage.countReports(channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
reports = threadStorage.getReportTop3(page)
else: else:
reports = threadStorage.getReportTop3(page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
reports = threadStorage.getReportTop5(page)
else:
reports = threadStorage.getReportTop5(page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3617,12 +3641,15 @@ class TriviaTime(callbacks.Plugin):
count = threadStorage.countTemporaryQuestions() count = threadStorage.countTemporaryQuestions()
else: else:
count = threadStorage.countTemporaryQuestions(channel) count = threadStorage.countTemporaryQuestions(channel)
pages = int(count / 3) + int(count % 3 > 0) pages = int(count / 5) + int(count % 5 > 0)
page = max(1, min(page, pages)) if page is not None:
if self.registryValue('general.globalstats'): page = max(1, min(page, pages))
q = threadStorage.getTemporaryQuestionTop3(page)
else: else:
q = threadStorage.getTemporaryQuestionTop3(page, channel=channel) page = 1
if self.registryValue('general.globalstats'):
q = threadStorage.getTemporaryQuestionTop5(page)
else:
q = threadStorage.getTemporaryQuestionTop5(page, channel=channel)
# Output list # Output list
if count < 1: if count < 1:
@ -3646,7 +3673,7 @@ class TriviaTime(callbacks.Plugin):
threadStorage = Storage(dbLocation) threadStorage = Storage(dbLocation)
totalUsersEver = threadStorage.getNumUser(channel) totalUsersEver = threadStorage.getNumUser(channel)
numActiveThisWeek = threadStorage.getNumActiveThisWeek(channel) numActiveThisWeek = threadStorage.getNumActiveThisWeek(channel)
infoText = ' TriviaTime v1.3.2 by Trivialand on Freenode: https://github.com/tannn/TriviaTime ' infoText = ' TriviaTime fork for #trivia on Snoonet: https://github.com/oddluck/limnoria-plugins'
self.reply(irc, msg, infoText, prefixNick=False) self.reply(irc, msg, infoText, prefixNick=False)
infoText = '\x02 %d Users\x02 on scoreboard with \x02%d Active This Week\x02' % (totalUsersEver, numActiveThisWeek) infoText = '\x02 %d Users\x02 on scoreboard with \x02%d Active This Week\x02' % (totalUsersEver, numActiveThisWeek)
self.reply(irc, msg, infoText, prefixNick=False) self.reply(irc, msg, infoText, prefixNick=False)
@ -3692,18 +3719,26 @@ class TriviaTime(callbacks.Plugin):
else: else:
hasPoints = False hasPoints = False
infoList = ['%s\'s Stats: Points (answers)' % (self.addZeroWidthSpace(stat['username']))] infoList = ['%s\'s Stats: Points (answers)' % (self.addZeroWidthSpace(stat['username']))]
if rank['day'] > 0 or stat['points_day'] > 0 or stat['answer_day'] > 0: if rank['day'] is not None and stat['points_day'] is not None and stat['answer_day'] is not None:
hasPoints = True if rank['day'] > 0 or stat['points_day'] > 0 or stat['answer_day'] > 0:
infoList.append(' \x02Today:\x02 #%d %d (%d)' % (rank['day'], stat['points_day'], stat['answer_day'])) hasPoints = True
if rank['week'] > 0 or stat['points_week'] > 0 or stat['answer_week'] > 0: infoList.append(' \x02Today:\x02 #%d %d (%d)' % (rank['day'], stat['points_day'], stat['answer_day']))
hasPoints = True if rank['week'] is not None and stat['points_week'] is not None and stat['answer_week'] is not None:
infoList.append(' \x02This Week:\x02 #%d %d (%d)' % (rank['week'], stat['points_week'], stat['answer_week'])) if rank['week'] > 0 or stat['points_week'] > 0 or stat['answer_week'] > 0:
if rank['month'] > 0 or stat['points_month'] > 0 or stat['answer_week'] > 0: hasPoints = True
hasPoints = True infoList.append(' \x02This Week:\x02 #%d %d (%d)' % (rank['week'], stat['points_week'], stat['answer_week']))
infoList.append(' \x02This Month:\x02 #%d %d (%d)' % (rank['month'], stat['points_month'], stat['answer_month'])) if rank['month'] is not None and stat['points_month'] is not None and stat['answer_month'] is not None:
if rank['year'] > 0 or stat['points_year'] > 0 or stat['answer_year'] > 0: if rank['month'] > 0 or stat['points_month'] > 0 or stat['answer_week'] > 0:
hasPoints = True hasPoints = True
infoList.append(' \x02This Year:\x02 #%d %d (%d)' % (rank['year'], stat['points_year'], stat['answer_year'])) infoList.append(' \x02This Month:\x02 #%d %d (%d)' % (rank['month'], stat['points_month'], stat['answer_month']))
if rank['year'] is not None and stat['points_year'] is not None and stat['answer_year'] is not None:
if rank['year'] > 0 or stat['points_year'] > 0 or stat['answer_year'] > 0:
hasPoints = True
infoList.append(' \x02This Year:\x02 #%d %d (%d)' % (rank['year'], stat['points_year'], stat['answer_year']))
if rank['total'] is not None and stat['points_total'] is not None and stat['answer_total'] is not None:
if rank['total'] > 0 or stat['points_total'] > 0 or stat['answer_total'] > 0:
hasPoints = True
infoList.append(' \x02All Time:\x02 #%d %d (%d)' % (rank['total'], stat['points_total'], stat['answer_total']))
if not hasPoints: if not hasPoints:
infoList = ['%s: You do not have any points.' % (username)] infoList = ['%s: You do not have any points.' % (username)]
if not identified: if not identified:
@ -3718,7 +3753,10 @@ class TriviaTime(callbacks.Plugin):
Parameter is optional, display up to that number. (eg 20 - display 11-20) Parameter is optional, display up to that number. (eg 20 - display 11-20)
Channel is only required when using the command outside of a channel. Channel is only required when using the command outside of a channel.
""" """
num = max(num, 10) if num is not None:
num = max(num, 10)
else:
num = 10
offset = num-9 offset = num-9
dbLocation = self.registryValue('admin.db') dbLocation = self.registryValue('admin.db')
threadStorage = Storage(dbLocation) threadStorage = Storage(dbLocation)
@ -4016,7 +4054,7 @@ class TriviaTime(callbacks.Plugin):
# Update skip count # Update skip count
game.skipList.append(usernameCanonical) game.skipList.append(usernameCanonical)
game.skipTimeoutList.append(usernameCanonical) game.skipTimeoutList.append(usernameCanonical)
self.reply(irc, msg, '%s voted to skip this question.' % username, prefixNick=False) self.reply(irc, msg, '%s voted to skip this question.' % username, (len(game.skipList), totalActive), prefixNick=False)
skipPercent = len(game.skipList)/(totalActive*1.0) skipPercent = len(game.skipList)/(totalActive*1.0)
# Check if skip threshold has been reached # Check if skip threshold has been reached
@ -4045,18 +4083,26 @@ class TriviaTime(callbacks.Plugin):
else: else:
hasPoints = False hasPoints = False
infoList = ['%s\'s Stats: Points (answers)' % (self.addZeroWidthSpace(stat['username']))] infoList = ['%s\'s Stats: Points (answers)' % (self.addZeroWidthSpace(stat['username']))]
if rank['day'] > 0 or stat['points_day'] > 0 or stat['answer_day'] > 0: if rank['day'] is not None and stat['points_day'] is not None and stat['answer_day'] is not None:
hasPoints = True if rank['day'] > 0 or stat['points_day'] > 0 or stat['answer_day'] > 0:
infoList.append(' \x02Today:\x02 #%d %d (%d)' % (rank['day'], stat['points_day'], stat['answer_day'])) hasPoints = True
if rank['week'] > 0 or stat['points_week'] > 0 or stat['answer_week'] > 0: infoList.append(' \x02Today:\x02 #%d %d (%d)' % (rank['day'], stat['points_day'], stat['answer_day']))
hasPoints = True if rank['week'] is not None and stat['points_week'] is not None and stat['answer_week'] is not None:
infoList.append(' \x02This Week:\x02 #%d %d (%d)' % (rank['week'], stat['points_week'], stat['answer_week'])) if rank['week'] > 0 or stat['points_week'] > 0 or stat['answer_week'] > 0:
if rank['month'] > 0 or stat['points_month'] > 0 or stat['answer_month'] > 0: hasPoints = True
hasPoints = True infoList.append(' \x02This Week:\x02 #%d %d (%d)' % (rank['week'], stat['points_week'], stat['answer_week']))
infoList.append(' \x02This Month:\x02 #%d %d (%d)' % (rank['month'], stat['points_month'], stat['answer_month'])) if rank['month'] is not None and stat['points_month'] is not None and stat['answer_month'] is not None:
if rank['year'] > 0 or stat['points_year'] > 0 or stat['answer_year'] > 0: if rank['month'] > 0 or stat['points_month'] > 0 or stat['answer_month'] > 0:
hasPoints = True hasPoints = True
infoList.append(' \x02This Year:\x02 #%d %d (%d)' % (rank['year'], stat['points_year'], stat['answer_year'])) infoList.append(' \x02This Month:\x02 #%d %d (%d)' % (rank['month'], stat['points_month'], stat['answer_month']))
if rank['year'] is not None and stat['points_year'] is not None and stat['answer_year'] is not None:
if rank['year'] > 0 or stat['points_year'] > 0 or stat['answer_year'] > 0:
hasPoints = True
infoList.append(' \x02This Year:\x02 #%d %d (%d)' % (rank['year'], stat['points_year'], stat['answer_year']))
if rank['total'] is not None and stat['points_total'] is not None and stat['answer_total'] is not None:
if rank['total'] > 0 or stat['points_total'] > 0 or stat['answer_total'] > 0:
hasPoints = True
infoList.append(' \x02All Time:\x02 #%d %d (%d)' % (rank['total'], stat['points_total'], stat['answer_total']))
if not hasPoints: if not hasPoints:
infoList = ['%s: %s does not have any points.' % (msg.nick, username)] infoList = ['%s: %s does not have any points.' % (msg.nick, username)]
infoText = ''.join(infoList) infoText = ''.join(infoList)
@ -4275,6 +4321,34 @@ class TriviaTime(callbacks.Plugin):
self.reply(irc, msg, 'The current server time appears to be {0}'.format(timeStr), prefixNick=False) self.reply(irc, msg, 'The current server time appears to be {0}'.format(timeStr), prefixNick=False)
time = wrap(time) time = wrap(time)
def top(self, irc, msg, arg, channel, num):
"""[<channel>] [<number>]
Displays the top scores of all time.
Parameter is optional, display up to that number. (eg 20 - display 11-20)
Channel is only required when using the command outside of a channel.
"""
if num is not None:
num = max(num, 10)
else:
num = 10
offset = num-9
dbLocation = self.registryValue('admin.db')
threadStorage = Storage(dbLocation)
if self.registryValue('general.globalStats'):
tops = threadStorage.viewAllTimeTop10(None, num)
else:
tops = threadStorage.viewAllTimeTop10(channel, num)
topsList = ['All Time Top {0}-{1} Players: '.format(offset, num)]
if tops:
for i in range(len(tops)):
topsList.append('\x02 #%d:\x02 %s %d ' % ((i+offset) , self.addZeroWidthSpace(tops[i]['username']), tops[i]['points']))
else:
topsList.append('No players')
topsText = ''.join(topsList)
self.reply(irc, msg, topsText, prefixNick=False)
top = wrap(top, ['channel', optional('int')])
def transferpoints(self, irc, msg, arg, channel, userfrom, userto): def transferpoints(self, irc, msg, arg, channel, userfrom, userto):
"""[<channel>] <userfrom> <userto> """[<channel>] <userfrom> <userto>
Transfers all points and records from one user to another. Transfers all points and records from one user to another.
@ -4300,7 +4374,10 @@ class TriviaTime(callbacks.Plugin):
Parameter is optional, display up to that number. (eg 20 - display 11-20) Parameter is optional, display up to that number. (eg 20 - display 11-20)
Channel is only required when using the command outside of a channel. Channel is only required when using the command outside of a channel.
""" """
num = max(num, 10) if num is not None:
num = max(num, 10)
else:
num = 10
offset = num-9 offset = num-9
dbLocation = self.registryValue('admin.db') dbLocation = self.registryValue('admin.db')
threadStorage = Storage(dbLocation) threadStorage = Storage(dbLocation)
@ -4325,7 +4402,10 @@ class TriviaTime(callbacks.Plugin):
Parameter is optional, display up to that number. (eg 20 - display 11-20) Parameter is optional, display up to that number. (eg 20 - display 11-20)
Channel is only required when using the command outside of a channel. Channel is only required when using the command outside of a channel.
""" """
num = max(num, 10) if num is not None:
num = max(num, 10)
else:
num = 10
offset = num-9 offset = num-9
dbLocation = self.registryValue('admin.db') dbLocation = self.registryValue('admin.db')
threadStorage = Storage(dbLocation) threadStorage = Storage(dbLocation)