Remove provisioning restrictions, move all user tracking code to monitoring module, fix proper network name not being passed to the relay
This commit is contained in:
@@ -3,6 +3,7 @@ from json import dumps
|
||||
|
||||
import main
|
||||
from core.relay import sendRelayNotification
|
||||
from modules import userinfo
|
||||
|
||||
def testNetTarget(name, target):
|
||||
called = False
|
||||
@@ -50,28 +51,49 @@ 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, numberedName, cast, event=None):
|
||||
if "target" in cast.keys():
|
||||
target = cast["target"]
|
||||
else:
|
||||
target = None
|
||||
def event(c): # yes I'm using a short variable because otherwise it goes off the screen
|
||||
if not "target" in c.keys():
|
||||
c["target"] = None
|
||||
|
||||
sendRelayNotification(name, cast)
|
||||
monitorGroups = testNetTarget(name, target)
|
||||
# metadata scraping
|
||||
# need to check if this was received from a relay
|
||||
# in which case, do not do this
|
||||
if c["type"] in ["msg", "notice", "action", "topic", "mode"]:
|
||||
userinfo.editUser(c["name"], c["muser"])
|
||||
elif c["type"] == "nick":
|
||||
userinfo.renameUser(c["name"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
||||
elif c["type"] == "kick":
|
||||
userinfo.editUser(c["name"], c["muser"])
|
||||
userinfo.delUserByNick(c["name"], c["target"], c["user"])
|
||||
elif c["type"] == "quit":
|
||||
userinfo.delUserByNetwork(c["name"], c["nick"], c["muser"])
|
||||
elif c["type"] == "join":
|
||||
userinfo.addUser(c["name"], c["target"], c["nick"], c["user"])
|
||||
elif c["type"] == "part":
|
||||
userinfo.delUser(c["name"], c["target"], c["nick"], c["user"])
|
||||
|
||||
if "mtype" in c.keys():
|
||||
if c["mtype"] == "nick":
|
||||
userinfo.renameUser(c["name"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
||||
|
||||
if "muser" in c.keys():
|
||||
del c["muser"]
|
||||
sendRelayNotification(c)
|
||||
monitorGroups = testNetTarget(c["name"], c["target"])
|
||||
if monitorGroups == False:
|
||||
return
|
||||
for monitorGroup in monitorGroups:
|
||||
matcher = magicFunction(deepcopy(cast), deepcopy(main.monitor[monitorGroup]))
|
||||
matcher = magicFunction(deepcopy(c), deepcopy(main.monitor[monitorGroup]))
|
||||
if matcher == True:
|
||||
cast["monitor"] = True
|
||||
c["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):
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "errdeliv"})
|
||||
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "errdeliv"})
|
||||
continue
|
||||
if not i in main.pool.keys():
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "noname"})
|
||||
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "noname"})
|
||||
if not i in main.IRCPool.keys():
|
||||
sendRelayNotification(name, {"type": "err", "name": name, "target": target, "message": cast, "reason": "noinstance"})
|
||||
sendRelayNotification({"type": "err", "name": name, "target": target, "message": c, "reason": "noinstance"})
|
||||
for x in main.monitor[monitorGroup]["send"][i]:
|
||||
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, name, cast))
|
||||
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["name"], c))
|
||||
|
||||
Reference in New Issue
Block a user