Implement support for more attributes and handle data type collisions when merging monitor group definitions
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import main
|
||||
import modules.keyword as keyword
|
||||
from pprint import pformat
|
||||
from copy import deepcopy
|
||||
|
||||
def testNetTarget(name, target):
|
||||
for i in main.monitor.keys():
|
||||
@@ -15,22 +16,28 @@ def testNetTarget(name, target):
|
||||
return False
|
||||
|
||||
def magicFunction(A, B):
|
||||
if "send" in B.keys():
|
||||
del B["send"]
|
||||
if "sources" in B.keys():
|
||||
del B["sources"]
|
||||
return all(A[k] in B[k] for k in set(A) & set(B)) and set(B) <= set(A)
|
||||
|
||||
def event(name, target, cast):
|
||||
monitorGroup = testNetTarget(name, target)
|
||||
if monitorGroup == False:
|
||||
return
|
||||
matcher = magicFunction(cast, main.monitor[monitorGroup])
|
||||
|
||||
matcher = magicFunction(deepcopy(cast), deepcopy(main.monitor[monitorGroup]))
|
||||
if matcher == True:
|
||||
if "send" in main.monitor[monitorGroup]:
|
||||
if "send" in main.monitor[monitorGroup].keys():
|
||||
for i in main.monitor[monitorGroup]["send"].keys():
|
||||
if isinstance(main.monitor[monitorGroup]["send"][i], bool):
|
||||
keyword.sendMaster("ERRDELIV MONITOR [%s] (%s/%s) %s " % (monitorGroup, name, target, pformat(cast)))
|
||||
continue
|
||||
if not i in main.pool.keys():
|
||||
keyword.sendMaster("ERROR on monitor %s: No such name: %s" % (monitorGroup, i))
|
||||
if not i in main.IRCPool.keys():
|
||||
keyword.sendMaster("ERROR on monitor %s: No such instance: %s" % (monitorGroup, i))
|
||||
for x in main.monitor[monitorGroup]["send"][i]:
|
||||
main.IRCPool[i].msg(x, "MONITOR [%s] %s" % (monitorGroup, pformat(cast)))
|
||||
main.IRCPool[i].msg(x, "MONITOR [%s] (%s/%s) %s" % (monitorGroup, name, target, pformat(cast)))
|
||||
else:
|
||||
keyword.sendMaster("MONITOR [%s] %s " % (monitorGroup, pformat(cast)))
|
||||
keyword.sendMaster("MONITOR [%s] (%s/%s) %s " % (monitorGroup, name, target, pformat(cast)))
|
||||
|
||||
Reference in New Issue
Block a user