Remove keyword system, implement ZNC notifications to relay, remove exact from cast fields and fix security bug in relay
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import main
|
||||
import modules.keyword as keyword
|
||||
from copy import deepcopy
|
||||
from json import dumps
|
||||
|
||||
import main
|
||||
from core.relay import sendRelayNotification
|
||||
|
||||
def testNetTarget(name, target):
|
||||
called = False
|
||||
for i in main.monitor.keys():
|
||||
@@ -49,32 +50,33 @@ def magicFunction(A, B):
|
||||
else:
|
||||
return all(A[k] in B[k] for k in set(A) & set(B)) and set(B) <= set(A)
|
||||
|
||||
def event(name, target, cast):
|
||||
for i in main.relayConnections.keys():
|
||||
if main.relayConnections[i].authed and cast["type"] in main.relayConnections[i].subscriptions:
|
||||
newCast = deepcopy(cast)
|
||||
if not target == None:
|
||||
newCast["target"] = target
|
||||
if "exact" in newCast.keys():
|
||||
del newCast["exact"]
|
||||
newCast["name"] = name
|
||||
main.relayConnections[i].send(dumps(newCast))
|
||||
def event(name, cast, event=None):
|
||||
if "target" in cast.keys():
|
||||
target = cast["target"]
|
||||
else:
|
||||
target = None
|
||||
if set(["nick", "ident", "host", "message"]).issubset(set(cast)):
|
||||
if main.config["Compat"]["ZNC"] and "message" in cast.keys():
|
||||
if cast["nick"][0] == main.config["Tweaks"]["ZNC"]["Prefix"] and cast["ident"] == "znc" and cast["host"] == "znc.in":
|
||||
sendRelayNotification(name, {"type": "znc", "message": cast["message"]})
|
||||
return
|
||||
|
||||
sendRelayNotification(name, cast)
|
||||
monitorGroups = testNetTarget(name, target)
|
||||
if monitorGroups == False:
|
||||
return
|
||||
for monitorGroup in monitorGroups:
|
||||
matcher = magicFunction(deepcopy(cast), deepcopy(main.monitor[monitorGroup]))
|
||||
if matcher == True:
|
||||
cast["monitor"] = True
|
||||
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, cast))
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "errdeliv"})
|
||||
continue
|
||||
if not i in main.pool.keys():
|
||||
keyword.sendMaster("ERROR on monitor %s: No such name: %s" % (monitorGroup, i))
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "noname"})
|
||||
if not i in main.IRCPool.keys():
|
||||
keyword.sendMaster("ERROR on monitor %s: No such instance: %s" % (monitorGroup, i))
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "noinstance"})
|
||||
for x in main.monitor[monitorGroup]["send"][i]:
|
||||
main.IRCPool[i].msg(x, "MONITOR [%s] (%s/%s) %s" % (monitorGroup, name, target, cast))
|
||||
else:
|
||||
keyword.sendMaster("MONITOR [%s] (%s/%s) %s " % (monitorGroup, name, target, cast))
|
||||
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, name, cast))
|
||||
|
||||
Reference in New Issue
Block a user