status/proto/matrix/main.go
Locria Cyber b765ac8a8c
comment
2023-09-30 16:05:49 +00:00

41 lines
987 B
Go

package main
import (
"fmt"
"os"
"time"
m "maunium.net/go/mautrix"
)
const user_id = "@exozymebot76397:matrix.org"
// const room_id = "@status-page-hackathon:exozy.me"
const room_id = "!fXEYZcqHcbjztwNhhD:exozy.me" // very unfortunate name for a child
func main() {
// the API key can be got by logging in with any Matrix client, and get it
// in element.io, find it under Settings -> About & Help -> Advanced
access_token, success := os.LookupEnv("MAUTRIX_ACCESS_TOKEN")
if !success {
panic("no access token")
}
client, err := m.NewClient("matrix.org", user_id, access_token)
if err != nil {
panic(err)
}
time := time.Now().UTC().Format(time.DateTime)
resp , err:= client.SendText(room_id, fmt.Sprintf("Hello from Go. Now it is now %s", time))
if err != nil {
panic(err)
}
fmt.Printf("%v", resp)
resp, err = client.RedactEvent(room_id, resp.EventID, m.ReqRedact{Reason: "Do I need a reason?"})
if err != nil {
panic(err)
}
fmt.Printf("%v", resp)
}