Implement counting of various IRC events

This commit is contained in:
2018-02-24 12:42:27 +00:00
parent 378c4d9bba
commit 8dec0b6828
8 changed files with 71 additions and 8 deletions

29
modules/counters.py Normal file
View File

@@ -0,0 +1,29 @@
from core.main import *
def event(name, eventType):
if not "local" in counters.keys():
counters["local"] = {}
if not "global" in counters.keys():
counters["global"] = {}
if not name in counters["local"].keys():
counters["local"][name] = {}
if eventType not in counters["local"][name].keys():
counters["local"][name][eventType] = 0
if eventType not in counters["global"]:
counters["global"][eventType] = 0
counters["local"][name][eventType] += 1
counters["global"][eventType] += 1
def getEvents(name=None):
if name == None:
if "global" in counters.keys():
return counters["global"]
else:
return None
else:
if name in counters["local"].keys():
return counters["local"][name]
else:
return None