Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(service): Add matrix service #410

Merged
merged 9 commits into from
Oct 4, 2022
Prev Previous commit
Next Next commit
docs(readme): updated readme and added doc
  • Loading branch information
arnocornette committed Oct 4, 2022
commit a406a1ffbf67b92e09f42360dfa19afbe359c3e3
48 changes: 48 additions & 0 deletions service/matrix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Matrix

[![go.dev reference](https://img.shields.io/badge/go.dev-reference-007d9c?logo=go&logoColor=white&style=flat)](https://pkg.go.dev/github.com/nikoksr/notify/service/whatsapp)

## 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.

```go
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")
}
```
34 changes: 34 additions & 0 deletions service/matrix/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Package matrix provides message notification integration for Matrix.

Usage:

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")
}
*/
package matrix