1
0
mirror of https://github.com/nikoksr/notify.git synced 2025-01-07 23:01:59 +02:00
notify/service/matrix
2022-10-25 11:45:06 +03:00
..
doc.go feat(service): add matrix service (#410) 2022-10-04 18:01:09 +03:00
matrix_test.go feat(service): add matrix service (#410) 2022-10-04 18:01:09 +03:00
matrix.go feat(service): add matrix service (#410) 2022-10-04 18:01:09 +03:00
mock_matrix_client.go feat(service): Add Viber (#415) 2022-10-25 11:45:06 +03:00
README.md feat(service): add matrix service (#410) 2022-10-04 18:01:09 +03:00
types.go feat(service): add matrix service (#410) 2022-10-04 18:01:09 +03:00

Matrix

go.dev reference

Prerequisites

You will need to following information to be able to send messages to Matrix.

  • Home server url
  • User ID
  • AccessToken
  • Room ID

Usage

In the current implementation, using this service requires 2 steps:

  1. Provide the necessary credentials explicitly
  2. 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")
}