From 86cd7aed8c2f751860f59460af9beef7210c025b Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Sat, 21 Jul 2012 15:07:43 +0200 Subject: [PATCH] Use the 'admin' converter for the mergescores, mergetimes, rmscore and rmtime commands (instead of checking the capability in the code) --- plugin.py | 113 +++++++++++++++++++++--------------------------------- 1 file changed, 43 insertions(+), 70 deletions(-) diff --git a/plugin.py b/plugin.py index 5eccd16..165c3cc 100644 --- a/plugin.py +++ b/plugin.py @@ -242,98 +242,81 @@ class DuckHunt(callbacks.Plugin): # nickto gets the points of nickfrom and nickfrom is removed from the scorelist def mergescores(self, irc, msg, args, channel, nickto, nickfrom): """[] : nickto gets the points of nickfrom and nickfrom is removed from the scorelist """ - if self._capability(msg, 'owner'): - if irc.isChannel(channel): - try: - self._read_scores(channel) - self.channelscores[channel][nickto] += self.channelscores[channel][nickfrom] - del self.channelscores[channel][nickfrom] - self._write_scores(channel) - #TODO: Reply with the config success message - irc.reply("Okay!") + if irc.isChannel(channel): + try: + self._read_scores(channel) + self.channelscores[channel][nickto] += self.channelscores[channel][nickfrom] + del self.channelscores[channel][nickfrom] + self._write_scores(channel) + #TODO: Reply with the config success message + irc.reply("Okay!") - except: - irc.error("Something went wrong") + except: + irc.error("Something went wrong") - else: - irc.error('You have to be on a channel') - else: - irc.error("Who are you again?") + irc.error('You have to be on a channel') - mergescores = wrap(mergescores, ['channel', 'nick', 'nick']) + + mergescores = wrap(mergescores, ['channel', 'nick', 'nick', 'admin']) # Merge times def mergetimes(self, irc, msg, args, channel, nickto, nickfrom): """[] : nickto gets the best time of nickfrom if nickfrom time is better than nickto time, and nickfrom is removed from the timelist """ - if self._capability(msg, 'owner'): - - if irc.isChannel(channel): - try: - self._read_scores(channel) - if self.channeltimes[channel][nickfrom] < self.channeltimes[channel][nickto]: - self.channeltimes[channel][nickto] = self.channeltimes[channel][nickfrom] - del self.channeltimes[channel][nickfrom] - self._write_scores(channel) + if irc.isChannel(channel): + try: + self._read_scores(channel) + if self.channeltimes[channel][nickfrom] < self.channeltimes[channel][nickto]: + self.channeltimes[channel][nickto] = self.channeltimes[channel][nickfrom] + del self.channeltimes[channel][nickfrom] + self._write_scores(channel) - irc.reply("Okay!") + irc.reply("Okay!") - except: - irc.error("Something went wrong") + except: + irc.error("Something went wrong") - else: - irc.error('You have to be on a channel') - else: - irc.error("Who are you again?") + irc.error('You have to be on a channel') - mergetimes = wrap(mergetimes, ['channel', 'nick', 'nick']) + + mergetimes = wrap(mergetimes, ['channel', 'nick', 'nick', 'admin']) # Remove 's best time def rmtime(self, irc, msg, args, channel, nick): """[] : Remove 's best time """ - if self._capability(msg, 'owner'): - - if irc.isChannel(channel): - self._read_scores(channel) - del self.channeltimes[channel][nick] - self._write_scores(channel) - irc.reply("Okay!") - - else: - irc.error('Are you sure ' + str(channel) + ' is a channel?') + if irc.isChannel(channel): + self._read_scores(channel) + del self.channeltimes[channel][nick] + self._write_scores(channel) + irc.reply("Okay!") else: - irc.error("Who are you again?") + irc.error('Are you sure ' + str(channel) + ' is a channel?') - rmtime = wrap(rmtime, ['channel', 'nick']) + rmtime = wrap(rmtime, ['channel', 'nick', 'admin']) # Remove 's best score def rmscore(self, irc, msg, args, channel, nick): """[] : Remove 's score """ - if self._capability(msg, 'owner'): + if irc.isChannel(channel): + try: + self._read_scores(channel) + del self.channelscores[channel][nick] + self._write_scores(channel) + irc.reply("Okay!") - if irc.isChannel(channel): - try: - self._read_scores(channel) - del self.channelscores[channel][nick] - self._write_scores(channel) - irc.reply("Okay!") - - except: - irc.error("Something went wrong") - - else: - irc.error('Are you sure this is a channel?') + except: + irc.error("Something went wrong") else: - irc.error("Who are you again?") + irc.error('Are you sure this is a channel?') - rmscore = wrap(rmscore, ['channel', 'nick']) + rmscore = wrap(rmscore, ['channel', 'nick', 'admin']) @@ -605,16 +588,6 @@ class DuckHunt(callbacks.Plugin): irc.error('You have to be on a channel') - def _capability(self, msg, c): - try: - u = ircdb.users.getUser(msg.prefix) - if u._checkCapability(c): - return True - except: - return False - - - Class = DuckHunt # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: