From fb9feb8b446df6402dff86e845046745431171ae Mon Sep 17 00:00:00 2001 From: Yizhe Shen Date: Sat, 21 Jun 2014 12:49:43 -0400 Subject: [PATCH] Fixed MVP voicing. - MVP voicing now works for week, month and year --- plugin.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/plugin.py b/plugin.py index 60c6a07..cba5e04 100644 --- a/plugin.py +++ b/plugin.py @@ -198,17 +198,10 @@ class TriviaTime(callbacks.Plugin): irc.sendMsg(ircmsgs.privmsg(channel, '%s: Ping reply: %0.2f seconds' % (username, pingTime))) def voiceUser(self, irc, username, channel): - irc.queueMsg(ircmsgs.voice(channel, username)) usernameCanonical = ircutils.toLower(username) - dbLocation = self.registryValue('admin.sqlitedb') - threadStorage = self.Storage(dbLocation) - if self.registryValue('general.globalStats'): - user = threadStorage.getUser(username, None) - else: - user = threadStorage.getUser(username, channel) if not self.voiceTimeouts.has(usernameCanonical): + irc.queueMsg(ircmsgs.voice(channel, username)) self.voiceTimeouts.append(usernameCanonical) - irc.sendMsg(ircmsgs.privmsg(channel, 'Giving voice to %s for being MVP this WEEK (#%d)' % (username, user[15]))) def handleVoice(self, irc, username, channel): if not self.registryValue('voice.enableVoice'): @@ -223,17 +216,22 @@ class TriviaTime(callbacks.Plugin): user = threadStorage.getUser(username, None) else: user = threadStorage.getUser(username, channel) - numTopToVoice = self.registryValue('voice.numTopToVoice') - minPointsVoiceYear = self.registryValue('voice.minPointsVoiceYear') - minPointsVoiceMonth = self.registryValue('voice.minPointsVoiceMonth') - minPointsVoiceWeek = self.registryValue('voice.minPointsVoiceWeek') + if len(user) >= 1: + numTopToVoice = self.registryValue('voice.numTopToVoice') + minPointsVoiceYear = self.registryValue('voice.minPointsVoiceYear') + minPointsVoiceMonth = self.registryValue('voice.minPointsVoiceMonth') + minPointsVoiceWeek = self.registryValue('voice.minPointsVoiceWeek') + if user[13] <= numTopToVoice and user[4] >= minPointsVoiceYear: self.voiceUser(irc, username, channel) + irc.sendMsg(ircmsgs.privmsg(channel, 'Giving voice to %s for being MVP this YEAR (#%d)' % (username, user[13]))) elif user[14] <= numTopToVoice and user[6] >= minPointsVoiceMonth: self.voiceUser(irc, username, channel) + irc.sendMsg(ircmsgs.privmsg(channel, 'Giving voice to %s for being MVP this MONTH (#%d)' % (username, user[14]))) elif user[15] <= numTopToVoice and user[8] >= minPointsVoiceWeek: self.voiceUser(irc, username, channel) + irc.sendMsg(ircmsgs.privmsg(channel, 'Giving voice to %s for being MVP this WEEK (#%d)' % (username, user[15]))) def addZeroWidthSpace(self, text): if len(text) <= 1: