You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
node-red-contrib-matrix-cha.../examples/custom-redact-function-node...

113 lines
2.6 KiB

[
{
"id": "89eed7ddf7a96070",
"type": "function",
"z": "f025a8b9fbd1b054",
"name": "Redact Message",
"func": "let matrixClient = global.get(\"matrixClient['@bot:example.com']\"),\n matrixOnline = global.get(\"matrixClientOnline['@bot:example.com']\");\n\nif(!matrixOnline) {\n msg.error = 'Matrix client not connected.';\n return [null, msg];\n}\n \nmatrixClient.redactEvent(msg.topic, msg.eventId, undefined, {\n reason: 'Redacted, muhahaha!'\n})\n .then(function(e) {\n msg.eventId = e.eventId;\n node.send([msg, null]);\n })\n .catch(function(e){\n node.warn(\"Error sending message \" + e);\n msg.error = e;\n node.send([null, msg]);\n });",
"outputs": 2,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 730,
"y": 1580,
"wires": [
[
"5decd492e2da79d9"
],
[
"fadcf8c32bdfd8be"
]
]
},
{
"id": "5decd492e2da79d9",
"type": "debug",
"z": "f025a8b9fbd1b054",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 890,
"y": 1560,
"wires": []
},
{
"id": "f3636f4221511a81",
"type": "comment",
"z": "f025a8b9fbd1b054",
"name": "If message is \"redact\" then redact the message.",
"info": "",
"x": 420,
"y": 1540,
"wires": []
},
{
"id": "9f777828840bb9a2",
"type": "matrix-receive",
"z": "f025a8b9fbd1b054",
"name": "",
"roomId": "",
"acceptText": true,
"acceptEmotes": false,
"acceptStickers": false,
"acceptReactions": false,
"acceptFiles": false,
"acceptImages": false,
"x": 320,
"y": 1580,
"wires": [
[
"21a00b09f8c85399"
]
]
},
{
"id": "21a00b09f8c85399",
"type": "switch",
"z": "f025a8b9fbd1b054",
"name": "filter on msg.payload",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "redact",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 520,
"y": 1580,
"wires": [
[
"89eed7ddf7a96070"
]
]
},
{
"id": "fadcf8c32bdfd8be",
"type": "debug",
"z": "f025a8b9fbd1b054",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 890,
"y": 1600,
"wires": []
}
]