- #100 add documentation for new typing node and update README

- #100 fix typing event causing server error due to number being string
- Mention using pantalaimon as an alternative for E2EE support in README
This commit is contained in:
Skylar Sadlier 2023-10-22 16:56:49 -06:00
parent 785e0cd7be
commit d7c4bc26bb
6 changed files with 147 additions and 2 deletions

View File

@ -11,9 +11,11 @@ The following is supported from this package:
- End-to-end encryption - End-to-end encryption
- [Currently a WIP](#end-to-end-encryption-notes) - [Currently a WIP](#end-to-end-encryption-notes)
- Can also use [pantalaimon](https://github.com/matrix-org/pantalaimon) as an alternative solution to E2EE (if you need multiple sessions synced up with keys)
- Receive events from a room (messages, reactions, images, audio, locations, and files) whether encrypted or not - Receive events from a room (messages, reactions, images, audio, locations, and files) whether encrypted or not
- Send Images/Files (sending files to e2ee room doesn't currently encrypt them yet) - Send Images/Files (sending files to e2ee room doesn't currently encrypt them yet)
- Edit messages - Edit messages
- Send typing events (Bot is typing ...)
- Delete events (messages, reactions, etc) - Delete events (messages, reactions, etc)
- Decrypt files in e2ee rooms - Decrypt files in e2ee rooms
- Send HTML/Plain Text Message/Notice - Send HTML/Plain Text Message/Notice

View File

@ -24,6 +24,7 @@ Build something cool with these nodes? Feel free to submit a pull request to sha
- [Respond to "rooms <user_id>" with user's rooms (list server's rooms if <user_id> is left blank)](#respond-to-rooms-user_id-with-users-rooms-list-servers-rooms-if-user_id-is-left-blank) - [Respond to "rooms <user_id>" with user's rooms (list server's rooms if <user_id> is left blank)](#respond-to-rooms-user_id-with-users-rooms-list-servers-rooms-if-user_id-is-left-blank)
- [Respond to "whois <user_id>" with information about the user's session](#respond-to-whois-user_id-with-information-about-the-users-session) - [Respond to "whois <user_id>" with information about the user's session](#respond-to-whois-user_id-with-information-about-the-users-session)
- [Respond to "room_users" with current room's users](#respond-to-room_users-with-current-rooms-users) - [Respond to "room_users" with current room's users](#respond-to-room_users-with-current-rooms-users)
- [Sending typing events to a room](#sending-typing-events-to-a-room)
- [Download & store all received files/images](#download--store-all-received-filesimages) - [Download & store all received files/images](#download--store-all-received-filesimages)
- [Kick/Ban user from room](#kickban-user-from-room) - [Kick/Ban user from room](#kickban-user-from-room)
- [Deactivate user](#deactivate-user) - [Deactivate user](#deactivate-user)
@ -221,6 +222,15 @@ Note: You may need to edit the storage directory for this to work. Default actio
![store-received-files.png](store-received-files.png) ![store-received-files.png](store-received-files.png)
### Sending typing events to a room
[View JSON](send-typing-events.json)
You can tell a room that Node-RED is writing a message and also cancel the writing event. This can be useful for making bots feel more interactive (show typing while requesting API endpoint for example).
![store-received-files.png](send-typing-events.png)
### Kick/Ban user from room ### Kick/Ban user from room
[View JSON](room-kick-ban.json) [View JSON](room-kick-ban.json)

View File

@ -0,0 +1,127 @@
[
{
"id": "541dbfc3f04220cf",
"type": "matrix-typing",
"z": "f025a8b9fbd1b054",
"name": "",
"server": null,
"roomType": "msg",
"roomValue": "topic",
"typingType": "msg",
"typingValue": "typing",
"timeoutMsType": "num",
"timeoutMsValue": "20000",
"x": 1090,
"y": 220,
"wires": [
[
"febf8236f3683963"
],
[
"9db9819ebb6343c8"
]
]
},
{
"id": "d7c3714c657bfe4f",
"type": "inject",
"z": "f025a8b9fbd1b054",
"name": "Start Typing",
"props": [
{
"p": "topic",
"vt": "str"
},
{
"p": "typing",
"v": "true",
"vt": "bool"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "!mohVKgDFYUubJQHcuX:skylar.tech",
"x": 910,
"y": 200,
"wires": [
[
"541dbfc3f04220cf"
]
]
},
{
"id": "783121ff1a6bd833",
"type": "inject",
"z": "f025a8b9fbd1b054",
"name": "Stop Typing",
"props": [
{
"p": "topic",
"vt": "str"
},
{
"p": "typing",
"v": "false",
"vt": "bool"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "!mohVKgDFYUubJQHcuX:skylar.tech",
"x": 910,
"y": 240,
"wires": [
[
"541dbfc3f04220cf"
]
]
},
{
"id": "9db9819ebb6343c8",
"type": "debug",
"z": "f025a8b9fbd1b054",
"name": "Failure msg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1270,
"y": 240,
"wires": []
},
{
"id": "febf8236f3683963",
"type": "debug",
"z": "f025a8b9fbd1b054",
"name": "Success msg",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"statusVal": "",
"statusType": "auto",
"x": 1270,
"y": 200,
"wires": []
},
{
"id": "01e8c4c6303af390",
"type": "comment",
"z": "f025a8b9fbd1b054",
"name": "Send typing events to a room",
"info": "",
"x": 940,
"y": 160,
"wires": []
}
]

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -12,7 +12,7 @@
roomType: { value: "msg" }, roomType: { value: "msg" },
roomValue: { value: "topic" }, roomValue: { value: "topic" },
typingType: { value: "bool" }, typingType: { value: "bool" },
typingValue: { value: true }, typingValue: { value: "true" },
timeoutMsType: { value: "num" }, timeoutMsType: { value: "num" },
timeoutMsValue: { value: 20000 }, timeoutMsValue: { value: 20000 },
}, },
@ -74,6 +74,10 @@
<label for="node-input-room"><i class="fa fa-clock-o"></i> Timeout Milliseconds</label> <label for="node-input-room"><i class="fa fa-clock-o"></i> Timeout Milliseconds</label>
<input type="text" id="node-input-timeoutMs"> <input type="text" id="node-input-timeoutMs">
</div> </div>
<div class="form-row form-tips">
Timeout MS is how many milliseconds the server should show the user typing for.
</div>
</script> </script>
<script type="text/html" data-help-name="matrix-typing"> <script type="text/html" data-help-name="matrix-typing">

View File

@ -33,6 +33,7 @@ module.exports = function(RED) {
node.on('input', async function(msg) { node.on('input', async function(msg) {
if (! node.server || ! node.server.matrixClient) { if (! node.server || ! node.server.matrixClient) {
node.error("No matrix server selected", msg); node.error("No matrix server selected", msg);
node.send([null, msg]);
return; return;
} }
@ -54,6 +55,8 @@ module.exports = function(RED) {
} }
} else if(type === "bool") { } else if(type === "bool") {
value = (property === 'true'); value = (property === 'true');
} else if(type === "num") {
value = Number(property);
} }
return value; return value;
} }
@ -68,7 +71,6 @@ module.exports = function(RED) {
return; return;
} }
console.log("sending typing",roomId, typing, timeoutMs);
await node.server.matrixClient.sendTyping(roomId, typing, timeoutMs); await node.server.matrixClient.sendTyping(roomId, typing, timeoutMs);
node.send([msg, null]); node.send([msg, null]);
} catch(e) { } catch(e) {