diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-17 19:52:50 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-17 19:52:50 +0100 |
commit | 5ab2608ee8bd36b7c7b0d670d24b5851250e3887 (patch) | |
tree | 991da5f05ab7f1370d3d959fe1d0ada9c1ac18b3 /appservice/matrix.go | |
parent | a4dd3b310d68f5c6147bdeaf8ecd3556c2cf7859 (diff) | |
download | easybridge-5ab2608ee8bd36b7c7b0d670d24b5851250e3887.tar.gz easybridge-5ab2608ee8bd36b7c7b0d670d24b5851250e3887.zip |
Send error messages in a system room. (next: error messages the other way around)
Diffstat (limited to 'appservice/matrix.go')
-rw-r--r-- | appservice/matrix.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/appservice/matrix.go b/appservice/matrix.go index 550e5a5..a212d85 100644 --- a/appservice/matrix.go +++ b/appservice/matrix.go @@ -11,12 +11,27 @@ import ( log "github.com/sirupsen/logrus" . "git.deuxfleurs.fr/Deuxfleurs/easybridge/mxlib" + "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" ) func ezbrMxId() string { return fmt.Sprintf("@%s:%s", registration.SenderLocalpart, config.MatrixDomain) } +func ezbrSystemRoom(user_mx_id string) (string, error) { + return dbGetMxPmRoom("system", connector.UserID("Easybridge"), ezbrMxId(), user_mx_id, "easybridge") +} + +func ezbrSystemSend(user_mx_id string, msg string) { + mx_room_id, err := ezbrSystemRoom(user_mx_id) + if err == nil { + err = mxSendMessageAs(mx_room_id, "m.text", msg, ezbrMxId()) + } + if err != nil { + log.Warnf("(%s) %s", user_mx_id, msg) + } +} + // ---- var httpClient *http.Client |