diff --git a/examples/README.md b/examples/README.md index 8739d65..f9ee29c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -209,4 +209,14 @@ Note: This requires the bot to be a server admin. WARNING: Accounts that are deleted cannot be restored. If you want to temp-disable edit the user instead. +![room-kick-ban.png](deactivate-user.png) + +### Force user to join room + +[View JSON](deactivate-user.json) + +If you say "force_join @test:example.com !320j90mf0394f:example.com" the bot will force the user `@test:example.com` into room `!320j90mf0394f:example.com` + +Note: This requires the bot to be a server admin. This also only works for rooms on the same server. + ![room-kick-ban.png](deactivate-user.png) \ No newline at end of file diff --git a/examples/deactivate-user.json b/examples/deactivate-user.json index e69de29..e0fd5a1 100644 --- a/examples/deactivate-user.json +++ b/examples/deactivate-user.json @@ -0,0 +1,116 @@ +[ + { + "id": "843c48978ab1b0a0", + "type": "switch", + "z": "f025a8b9fbd1b054", + "name": "is from me", + "property": "userId", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "@skylord123:skylar.tech", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 590, + "y": 3260, + "wires": [ + [ + "b77d071077487ddc" + ] + ] + }, + { + "id": "93ea76ce5e65a250", + "type": "matrix-receive", + "z": "f025a8b9fbd1b054", + "name": "", + "server": null, + "roomId": "", + "acceptText": true, + "acceptEmotes": false, + "acceptStickers": false, + "acceptReactions": false, + "acceptFiles": false, + "acceptImages": false, + "x": 420, + "y": 3260, + "wires": [ + [ + "843c48978ab1b0a0" + ] + ] + }, + { + "id": "d6795b522954bccd", + "type": "comment", + "z": "f025a8b9fbd1b054", + "name": "Respond to \"deactivate_user \" by deactivating the user on the server", + "info": "", + "x": 590, + "y": 3220, + "wires": [] + }, + { + "id": "b77d071077487ddc", + "type": "switch", + "z": "f025a8b9fbd1b054", + "name": "msg.payload filter", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "regex", + "v": "^deactivate_user", + "vt": "str", + "case": false + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 770, + "y": 3260, + "wires": [ + [ + "3c0e1e130e91206e" + ] + ] + }, + { + "id": "3c0e1e130e91206e", + "type": "function", + "z": "f025a8b9fbd1b054", + "name": "", + "func": "let matches = msg.payload.match(/^deactivate_user ?(\\@.*)?/);\nmsg.userId = matches[1].trim() ? matches[1].trim() : null;\nif(!msg.userId) {\n return null;\n}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 420, + "y": 3320, + "wires": [ + [ + "1f4870b7171cc70f" + ] + ] + }, + { + "id": "1f4870b7171cc70f", + "type": "matrix-synapse-deactivate-user", + "z": "f025a8b9fbd1b054", + "name": "", + "server": null, + "x": 610, + "y": 3320, + "wires": [ + [], + [] + ] + } +] \ No newline at end of file diff --git a/examples/force-join-room.json b/examples/force-join-room.json new file mode 100644 index 0000000..f1bcb16 --- /dev/null +++ b/examples/force-join-room.json @@ -0,0 +1,117 @@ +[ + { + "id": "897b8de477d7d0df", + "type": "switch", + "z": "f025a8b9fbd1b054", + "name": "is from me", + "property": "userId", + "propertyType": "msg", + "rules": [ + { + "t": "eq", + "v": "@skylord123:skylar.tech", + "vt": "str" + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 470, + "y": 3460, + "wires": [ + [ + "1f73f36092a9536b" + ] + ] + }, + { + "id": "973b2caeb68f3a60", + "type": "matrix-receive", + "z": "f025a8b9fbd1b054", + "name": "", + "server": null, + "roomId": "", + "acceptText": true, + "acceptEmotes": false, + "acceptStickers": false, + "acceptReactions": false, + "acceptFiles": false, + "acceptImages": false, + "x": 300, + "y": 3460, + "wires": [ + [ + "897b8de477d7d0df" + ] + ] + }, + { + "id": "be5c7290e6223b7b", + "type": "comment", + "z": "f025a8b9fbd1b054", + "name": "Say \"force_join \" to force a user into a room", + "info": "", + "x": 460, + "y": 3420, + "wires": [] + }, + { + "id": "1f73f36092a9536b", + "type": "switch", + "z": "f025a8b9fbd1b054", + "name": "msg.payload filter", + "property": "payload", + "propertyType": "msg", + "rules": [ + { + "t": "regex", + "v": "^deactivate_user", + "vt": "str", + "case": false + } + ], + "checkall": "true", + "repair": false, + "outputs": 1, + "x": 650, + "y": 3460, + "wires": [ + [ + "6a2a73bc9dfdaece" + ] + ] + }, + { + "id": "6a2a73bc9dfdaece", + "type": "function", + "z": "f025a8b9fbd1b054", + "name": "", + "func": "let matches = msg.payload.match(/^force_join (\\@.*) (.*)/);\nmsg.userId = matches[1].trim() ? matches[1].trim() : null;\nif(!msg.userId) {\n return null;\n}\nmsg.topic = matches[2].trim() ? matches[2].trim() : null;\nif(!msg.topic) {\n return null;\n}\nreturn msg;", + "outputs": 1, + "noerr": 0, + "initialize": "", + "finalize": "", + "libs": [], + "x": 300, + "y": 3520, + "wires": [ + [ + "212e060e320918d3" + ] + ] + }, + { + "id": "212e060e320918d3", + "type": "matrix-synapse-join-room", + "z": "f025a8b9fbd1b054", + "name": "", + "server": null, + "roomId": "", + "x": 490, + "y": 3520, + "wires": [ + [], + [] + ] + } +] \ No newline at end of file diff --git a/examples/force-join-room.png b/examples/force-join-room.png new file mode 100644 index 0000000..ccaea6e Binary files /dev/null and b/examples/force-join-room.png differ diff --git a/package.json b/package.json index af01878..4d84251 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-contrib-matrix-chat", - "version": "0.4.5", + "version": "0.4.6", "description": "Matrix chat server client for Node-RED", "dependencies": { "fs-extra": "^10.0.0",