summaryrefslogtreecommitdiff
path: root/cannon.py
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2015-02-02 07:36:48 -0800
committerJesse Morgan <jesse@jesterpm.net>2015-02-02 07:36:48 -0800
commit88c849b5b3b3d03591f3aa12c3e6daa1ea744dbf (patch)
tree3f71498d2cc450140f86714d4ad36292b86693b1 /cannon.py
parent92af71570ab35143c8edab7f45520408751bf3c6 (diff)
Basic interface for generic data persistence.data-persistence
Diffstat (limited to 'cannon.py')
-rw-r--r--cannon.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/cannon.py b/cannon.py
index 0911245..f88f54d 100644
--- a/cannon.py
+++ b/cannon.py
@@ -6,20 +6,23 @@ import os
class Cannon(object):
- def __init__(self):
- self.firecount = {}
+ def onAddonAdd(self, context, **kwargs):
+ if not getattr(context.data, "cannon", None):
+ context.data.cannon = dict()
def onChanMsg(self, context, user, channel, targetprefix, msg):
+ firecount = context.data.cannon
+
matches = re.findall("^!fire\\s+(.*)$", msg)
if matches:
nickname = matches[0]
if any([nickname.lower() == usr.nick.lower() for usr in channel.users]):
vic = context.user(nickname)
- if vic in self.firecount.keys():
- count = self.firecount[vic] + 1
+ if vic in firecount.keys():
+ count = firecount[vic] + 1
else:
count = 1
- self.firecount[vic] = count
+ firecount[vic] = count
if 10 <= count % 100 < 20:
ordinal = "th"
elif count % 10 == 1: