def handle_karmagood(bot, event): """ arguments: none - show top karma items of a channel. """ collection = PlugPersistCollection() stats = StatDict() objs = collection.objects(event.channel.lower()) for name, obj in objs.iteritems(): if not obj.data: logging.warn("%s is empty" % name) ; continue item = stripname(name).split("-")[-1] stats.upitem(item, obj.data.count) res = [] for item in stats.top(): res.append("%s - %s" % item) event.reply("top karma items of %s: " % event.channel, res)
def handle_karmagood(bot, event): """ arguments: none - show top karma items of a channel. """ collection = PlugPersistCollection() # event.reply('Processing karma list.') stats = StatDict() objs = collection.objects() for name, obj in objs.iteritems(): if not obj.data: logging.warn("%s is empty" % name) ; continue item = stripname(name).split("-",2)[-1] if stripname(name).split("-",2)[1] == event.channel.lower()[1:]: stats.upitem(item, obj.data.count) ktop = stats.top(limit=20) # event.reply(str(ktop)) res = "" for item in ktop: res += (str(item[0])+':'+str(item[1])+' ') event.reply('Top 20 Karma for '+event.channel+': '+ res)
def handle_karmagood(bot, event): """ arguments: none - show top karma items of a channel. """ collection = PlugPersistCollection() # event.reply('Processing karma list.') stats = StatDict() objs = collection.objects() for name, obj in objs.iteritems(): if not obj.data: logging.warn("%s is empty" % name) continue item = stripname(name).split("-", 2)[-1] if stripname(name).split("-", 2)[1] == event.channel.lower()[1:]: stats.upitem(item, obj.data.count) ktop = stats.top(limit=20) # event.reply(str(ktop)) res = "" for item in ktop: res += (str(item[0]) + ':' + str(item[1]) + ' ') event.reply('Top 20 Karma for ' + event.channel + ': ' + res)