You will need to following information to be able to send messages to Matrix.
- Home server url
- User ID
- AccessToken
- Room ID
In the current implementation, using this service requires 2 steps:
- Provide the necessary credentials explicitly
- Use the Send message to send a message to the specified room.
package main
import (
"context"
"log"
"github.com/nikoksr/notify"
"github.com/nikoksr/notify/service/matrix"
)
func main() {
matrixSvc, err := matrix.New("user-id", "room-id", "home-server", "access-token")
if err != nil {
log.Fatalf("matrix.New() failed: %s", err.Error())
}
notifier := notify.New()
notifier.UseServices(matrixSvc)
err = notifier.Send(context.Background(), "", "message")
if err != nil {
log.Fatalf("notifier.Send() failed: %s", err.Error())
}
log.Println("notification sent")
}