Net::Matrix::Webhook - A http->matrix webhook
version 0.900
Net::Matrix::Webhook->new({ matrix_home_server => 'matrix.example.com', matrix_user => 'your-bot', matrix_password => '12345', http_port => '8765', # = default })->run; # or use the wrapper script http2matix.pl included in this distribution http2matrix.pl --matrix_home_server matrix.example.com --matrix_user your-bot --matrix_password 12345 # Then send your requests curl http://localhost:8765/?message=hello%2C%20world%21
L[matrix|https://matrix.org/] is an open network for secure, decentralized communication. A bit like IRC, but less 90ies.
Net::Matrix::Webhook implements a webhook, so you can easily post messages to your matrix chat rooms via HTTP requests. It uses IO::Async to start a web server and connect as a client to matrix. It will then forward your messages.
Net::Matrix::Webhook
Per default, everybody can now post to this endpoint. If you want to add a tiny bit of "security", you can pass a secret to Net::Matrix::Webhook. If you do this, you will also have to send a token consisting of a sha1_hex of the message and the secret:
secret
token
sha1_hex
my $token = sha1_hex( encode_utf8($msg), $secret ); request('http://localhost:8765/?message=hello%2C%20world%21&token='.$token);
If you use http2matrix, you can pass the options either via the commandline as --option or via ENV as OPTION, for example --matrix_home_server matrix.example.com or MATRIX_HOME_SERVER=matrix.example.com
--option
OPTION
--matrix_home_server matrix.example.com
MATRIX_HOME_SERVER=matrix.example.com
Required.
The hostname of your matrix home server. Without the protocol!
Required. Example: #dev:example.net
#dev:example.net
The room you want the bot to join. The bot-user has to be invited to this room.
To get the room address, use riot, go to the "room settings" and find the "main address" in "published addresses". You might need to set it first via "local address" - "add".
The user name of your bot. You will have to set up an account for this user on your matrix home server.
The password of your bot.
Optional. Default: 8765
The HTTP port the webserver will use.
Optional.
A shared secret to calculate / validate the optional token parameter, for a little bit of "security".
Output happens via Log::Any.
Log::Any
If you use http2matrix.pl, you can use environment vars LOGADAPTER and LOGLEVEL to finetune the output.
LOGADAPTER
LOGLEVEL
https://matrix.org/
Net::Async::Matrix
Thanks to
validad.com for supporting Open Source.
Thomas Klausner <domm@cpan.org>
This software is copyright (c) 2020 by Thomas Klausner.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::Matrix::Webhook, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Matrix::Webhook
CPAN shell
perl -MCPAN -e shell install Net::Matrix::Webhook
For more information on module installation, please visit the detailed CPAN module installation guide.