Implement sorting relay output by custom keys
This commit is contained in:
parent
5eda50af13
commit
f0fff7c958
|
@ -7,6 +7,10 @@ from core.relay import sendRelayNotification
|
|||
from modules import userinfo
|
||||
from utils.dedup import dedup
|
||||
|
||||
order = ["type", "net", "num", "channel", "msg", "nick",
|
||||
"ident", "host", "mtype", "user", "modes", "modeargs"
|
||||
"realname", "server", "status"]
|
||||
|
||||
def testNetTarget(name, target):
|
||||
called = False
|
||||
for i in main.monitor.keys():
|
||||
|
@ -63,29 +67,29 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
|
|||
# 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"])
|
||||
userinfo.editUser(c["net"], c["muser"])
|
||||
elif c["type"] == "nick":
|
||||
userinfo.renameUser(c["name"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
||||
userinfo.renameUser(c["net"], 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["channel"], c["user"])
|
||||
userinfo.editUser(c["net"], c["muser"])
|
||||
userinfo.delUserByNick(c["net"], c["channel"], c["user"])
|
||||
elif c["type"] == "quit":
|
||||
userinfo.delUserByNetwork(c["name"], c["nick"], c["muser"])
|
||||
userinfo.delUserByNetwork(c["net"], c["nick"], c["muser"])
|
||||
elif c["type"] == "join":
|
||||
userinfo.addUser(c["name"], c["channel"], c["nick"], c["muser"])
|
||||
userinfo.addUser(c["net"], c["channel"], c["nick"], c["muser"])
|
||||
elif c["type"] == "part":
|
||||
userinfo.delUser(c["name"], c["channel"], c["nick"], c["muser"])
|
||||
userinfo.delUser(c["net"], c["channel"], c["nick"], c["muser"])
|
||||
|
||||
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"])
|
||||
userinfo.renameUser(c["net"], c["nick"], c["muser"], c["user"], c["user"]+"!"+c["ident"]+"@"+c["host"])
|
||||
|
||||
if "muser" in c.keys():
|
||||
del c["muser"]
|
||||
sendRelayNotification(c)
|
||||
sendRelayNotification({k: c[k] for k in order if k in c}) # Sort dict keys according to order
|
||||
|
||||
# only monitors below
|
||||
monitorGroups = testNetTarget(c["name"], c["channel"])
|
||||
monitorGroups = testNetTarget(c["net"], c["channel"])
|
||||
if monitorGroups == False:
|
||||
return
|
||||
for monitorGroup in monitorGroups:
|
||||
|
@ -95,11 +99,11 @@ def event(numName, c): # yes I'm using a short variable because otherwise it goe
|
|||
if "send" in main.monitor[monitorGroup].keys():
|
||||
for i in main.monitor[monitorGroup]["send"].keys():
|
||||
if isinstance(main.monitor[monitorGroup]["send"][i], bool):
|
||||
sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "errdeliv"})
|
||||
sendRelayNotification({"type": "err", "net": net, "channel": channel, "message": c, "reason": "errdeliv"})
|
||||
continue
|
||||
if not i in main.pool.keys():
|
||||
sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "noname"})
|
||||
sendRelayNotification({"type": "err", "net": net, "channel": channel, "message": c, "reason": "noname"})
|
||||
if not i in main.IRCPool.keys():
|
||||
sendRelayNotification({"type": "err", "name": name, "channel": channel, "message": c, "reason": "noinstance"})
|
||||
sendRelayNotification({"type": "err", "net": net, "channel": channel, "message": c, "reason": "noinstance"})
|
||||
for x in main.monitor[monitorGroup]["send"][i]:
|
||||
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["name"], c))
|
||||
main.IRCPool[i].msg(x, "monitor [%s] (%s) %s" % (monitorGroup, c["net"], c))
|
||||
|
|
Loading…
Reference in New Issue