mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Update Karma for the utils restructuring.
This commit is contained in:
parent
dd1c287655
commit
1e5332ff97
@ -282,26 +282,25 @@ class Karma(callbacks.Plugin):
|
|||||||
name = things[0]
|
name = things[0]
|
||||||
t = self.db.get(channel, name)
|
t = self.db.get(channel, name)
|
||||||
if t is None:
|
if t is None:
|
||||||
irc.reply('%s has neutral karma.' % name)
|
irc.reply(format('%s has neutral karma.', name))
|
||||||
else:
|
else:
|
||||||
(added, subtracted) = t
|
(added, subtracted) = t
|
||||||
total = added - subtracted
|
total = added - subtracted
|
||||||
if self.registryValue('simpleOutput', channel):
|
if self.registryValue('simpleOutput', channel):
|
||||||
s = '%s: %s' % (name, total)
|
s = format('%s: %i', name, total)
|
||||||
else:
|
else:
|
||||||
s = 'Karma for %s has been increased %s ' \
|
s = format('Karma for %q has been increased %n and '
|
||||||
'and decreased %s for a total karma of %s.' % \
|
'decreased %n for a total karma of %s.',
|
||||||
(utils.quoted(name), utils.nItems('time', added),
|
name, (added, 'time'), (subtracted, 'time'),
|
||||||
utils.nItems('time', subtracted), total)
|
total)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
elif len(things) > 1:
|
elif len(things) > 1:
|
||||||
(L, neutrals) = self.db.gets(channel, things)
|
(L, neutrals) = self.db.gets(channel, things)
|
||||||
if L:
|
if L:
|
||||||
s = utils.commaAndify(['%s: %s' % t for t in L])
|
s = format('%L', [format('%s: %i', *t) for t in L])
|
||||||
if neutrals:
|
if neutrals:
|
||||||
neutral = '. %s %s neutral karma' % \
|
neutral = format('. %L %h neutral karma',
|
||||||
(utils.commaAndify(neutrals),
|
neutrals, len(neutrals))
|
||||||
utils.has(len(neutrals)))
|
|
||||||
s += neutral
|
s += neutral
|
||||||
irc.reply(s + '.')
|
irc.reply(s + '.')
|
||||||
else:
|
else:
|
||||||
@ -309,9 +308,9 @@ class Karma(callbacks.Plugin):
|
|||||||
else: # No name was given. Return the top/bottom N karmas.
|
else: # No name was given. Return the top/bottom N karmas.
|
||||||
limit = self.registryValue('rankingDisplay', channel)
|
limit = self.registryValue('rankingDisplay', channel)
|
||||||
top = self.db.top(channel, limit)
|
top = self.db.top(channel, limit)
|
||||||
highest = ['%s (%s)' % (utils.quoted(s), t)
|
highest = [format('%q (%s)', s, t)
|
||||||
for (s, t) in self.db.top(channel, limit)]
|
for (s, t) in self.db.top(channel, limit)]
|
||||||
lowest = ['%s (%s)' % (utils.quoted(s), t)
|
lowest = [format('%q (%s)', s, t)
|
||||||
for (s, t) in self.db.bottom(channel, limit)]
|
for (s, t) in self.db.bottom(channel, limit)]
|
||||||
if not (highest and lowest):
|
if not (highest and lowest):
|
||||||
irc.error('I have no karma for this channel.')
|
irc.error('I have no karma for this channel.')
|
||||||
@ -319,16 +318,16 @@ class Karma(callbacks.Plugin):
|
|||||||
rank = self.db.rank(channel, msg.nick)
|
rank = self.db.rank(channel, msg.nick)
|
||||||
if rank is not None:
|
if rank is not None:
|
||||||
total = self.db.size(channel)
|
total = self.db.size(channel)
|
||||||
rankS = ' You (%s) are ranked %s out of %s.' % \
|
rankS = format(' You (%s) are ranked %i out of %i.',
|
||||||
(msg.nick, rank, total)
|
msg.nick, rank, total)
|
||||||
else:
|
else:
|
||||||
rankS = ''
|
rankS = ''
|
||||||
s = 'Highest karma: %s. Lowest karma: %s.%s' % \
|
s = format('Highest karma: %L. Lowest karma: %L.%s',
|
||||||
(utils.commaAndify(highest), utils.commaAndify(lowest), rankS)
|
highest, lowest, rankS)
|
||||||
irc.reply(s)
|
irc.reply(s)
|
||||||
karma = wrap(karma, ['channel', any('something')])
|
karma = wrap(karma, ['channel', any('something')])
|
||||||
|
|
||||||
_mostAbbrev = utils.abbrev(['increased', 'decreased', 'active'])
|
_mostAbbrev = utils.gen.abbrev(['increased', 'decreased', 'active'])
|
||||||
def most(self, irc, msg, args, channel, kind):
|
def most(self, irc, msg, args, channel, kind):
|
||||||
"""[<channel>] {increased,decreased,active}
|
"""[<channel>] {increased,decreased,active}
|
||||||
|
|
||||||
@ -339,8 +338,8 @@ class Karma(callbacks.Plugin):
|
|||||||
L = self.db.most(channel, kind,
|
L = self.db.most(channel, kind,
|
||||||
self.registryValue('mostDisplay', channel))
|
self.registryValue('mostDisplay', channel))
|
||||||
if L:
|
if L:
|
||||||
L = ['%s: %s' % (utils.quoted(name), i) for (name, i) in L]
|
L = [format('%q: %i', name, i) for (name, i) in L]
|
||||||
irc.reply(utils.commaAndify(L))
|
irc.reply(format('%L', L))
|
||||||
else:
|
else:
|
||||||
irc.error('I have no karma for this channel.')
|
irc.error('I have no karma for this channel.')
|
||||||
most = wrap(most, ['channel',
|
most = wrap(most, ['channel',
|
||||||
|
Loading…
Reference in New Issue
Block a user