Implement counting of various IRC events
This commit is contained in:
29
modules/counters.py
Normal file
29
modules/counters.py
Normal 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
|
||||
Reference in New Issue
Block a user