Skip to content
Snippets Groups Projects
Commit 0d1a9427 authored by Bruce Cowan's avatar Bruce Cowan
Browse files

Initial karma plugin

parents
No related branches found
No related tags found
No related merge requests found
[Core]
name = Karma
module = karma
[Documentation]
description = Karma service
[Python]
version = 3
[Errbot]
karma.py 0 → 100644
from collections import defaultdict
from errbot import BotPlugin, botcmd
class Karma(BotPlugin):
"""Karma service"""
def activate(self):
super().activate()
try:
self.karma = self['karma']
except KeyError:
self.karma = self['karma'] = defaultdict(int)
@botcmd
def karma_add(self, message, args):
"""Adds karma"""
self.karma[args] += 1
return "Karma for {} is now {}".format(args, self.karma[args])
@botcmd
def karma_remove(self, message, args):
"""Removes karma"""
self.karma[args] -= 1
return "Karma for {} is now {}".format(args, self.karma[args])
@botcmd
def karma(self, message, args):
"""Gets karma"""
return "Karma for {} is {}".format(args, self.karma[args])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment