Adapter for matrix push messages Big thanks for creating matrix (https://matrix.org/) for creating a full free communication base
Best: Run your own client on your server!
Create an own user as your BOT with password. Create a room for all members who want the bot messages. Add your BOT to this room (not needed if autojoin is active). Add all members to this room. Put all the data into the config. (BOT name, password, room name)
Add as many instances as you need. Add a value to matrix-org.0.sendMessage on the way you like, with js If you set "image" to matrix.0.sendMessage, it will send the matrix logo to your channel. Or in js use:
sendTo("matrix-org.0", "Hello World!");
Or use the blockly symbol in Sendto.
For images from local file system (Linux):
sendTo("matrix-org.0",{file: "file:///tmp/images/test.png"});
For images from local file system (Windows):
sendTo("matrix-org.0",{file: "file:///C:/tmp/images/test.png"});
For images as reference:
sendTo("matrix-org.0",{file: "https://www.abcd/images/test.png"});
For images in base64:
sendTo("matrix-org.0",{file:{type:"image/png",base64:"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACmSURBVFhH7ZdhCoAgDEZnd9D737T8xJkNNY1Ef+yB2LTcC1qWOT20kCBgjIkh0WwfmeuIxyGYnRzIPElgFSqgAvsKOOdCzeZ1y7EcZzDG16HvwtckihLdA4xxk3HeGGttc17Cc+lN6Ds/dlO6w6/ItQHn7H4GcDK3Em/zNboE5KKjcQstQxVQARVYLlDdC2YzvBfMQgVUYB8BlMWfn2E1ZJ7Fv+dEF0UZoNhXp9NnAAAAAElFTkSuQmCC"}});
Or
sendTo("matrix-org.0",{file:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACmSURBVFhH7ZdhCoAgDEZnd9D737T8xJkNNY1Ef+yB2LTcC1qWOT20kCBgjIkh0WwfmeuIxyGYnRzIPElgFSqgAvsKOOdCzeZ1y7EcZzDG16HvwtckihLdA4xxk3HeGGttc17Cc+lN6Ds/dlO6w6/ItQHn7H4GcDK3Em/zNboE5KKjcQstQxVQARVYLlDdC2YzvBfMQgVUYB8BlMWfn2E1ZJ7Fv+dEF0UZoNhXp9NnAAAAAElFTkSuQmCC"});
For html please follow this spec: https://spec.matrix.org/v1.3/client-server-api/#mroommessage-msgtypes E.g.:
sendTo("matrix-org.0",{html: "<h1>Hello World!</h1>", text: "Hello World!"});
or
sendTo("matrix-org.0",{html: "<table><tr><td>1</td><td>2</td></tr><tr><td>a</td><td>b</td></tr><table>", text: "Your client can not show html!"});
If your client is not able to decode html you will get the text. If your client do not support table it either show the text or simply 12ab.
simply open the objects and change the string of one matrix-org instance Mostly the port is 443, if you have a public system like matrix.org The port is sometimes 8448, when you have a self hosted system without proxy, but then you know it.
If you like to test it: Server: matrix.org Port: 443 room: #test-ioBroker-adapter:matrix.org Join this room and try it out with your own credentials
- upgrade matrix-js-sdk
- auto join added (default false)
- upgrade matrix-js-sdk (node 18 needed)
- last version for node 16
- updated libs according dependabot accept matrix-js-sdk
- downgrade for node 16
- translation for configuration
- update of dependencies
- small readme improvement
- updates of dependencies
- base64 with html format added again
- html messages added
- bugfix local file system was not working
- bugfix base64 was not working
- unit test added
- sending files added
- sending from url and base64 encoded data
- image ans video mime types are send as image and video all others as file
- removed all axios request
- replaced with matrix-js-sdk calls
- no logoff during the whole time
- test with servers with access token expiery need to be done
- sync added
- receive message added (please check on update and not on change to react on the same message)
- repeat false set for stable admin v5.3.8
- Readme with example improved (how to chose port 443 or 8448)
- some more debug output on errors
- sendMessage stay in for fast config testing
- index_m.html and files from admin/build removed
- password encryption and protection enabled
- password field now as type password
- detection of missing config give an error log
- detection of unread room data give an error log
- encodeURI() used where possible
- catching termination during await for avoid errors when writing on ioBroker database
- adding matrix to blockly symbol
- blockly added
- onMessage method added
- Invalid workflow line 54 in test-and-release.yml (leading space removed)
- (oelison) message sending by setting object sendMessage implemented
- (oelison) most "try/catch" done
- (oelison) Readme completed.
- (oelison) initial release
MIT License
Copyright (c) 2023 Christian Oelschlegel iobrokermatrix@sciphy.de
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.