Skip to content

Instantly share code, notes, and snippets.

@pja237
Created June 8, 2022 21:22
Show Gist options
  • Save pja237/6d97895bc606e5d4e2d0ad1fb2e58840 to your computer and use it in GitHub Desktop.
Save pja237/6d97895bc606e5d4e2d0ad1fb2e58840 to your computer and use it in GitHub Desktop.
PoC continuation for matrixslurmbot, this code then sends to the received roomID a job message
package main
import (
"flag"
"fmt"
"log"
"maunium.net/go/mautrix"
"maunium.net/go/mautrix/id"
)
const (
matrixServer = "https://matrix-client.matrix.org"
matrixBotUser = "@SlurmBotNameHere:matrix.org"
matrixBotToken = "botTokenHere"
)
func main() {
roomID := flag.String("s", "", "roomID to send the message to")
flag.Parse()
fmt.Printf("Target room: %q\n", *roomID)
client, err := mautrix.NewClient(matrixServer, matrixBotUser, matrixBotToken)
if err != nil {
log.Fatalf("ERROR: %q\n", err)
}
log.Printf("SUCCESS: %#v\n", client)
resp, err := client.SendText(id.RoomID(*roomID), "Your slurm job is absolutely fabulous!\n")
if err != nil {
log.Fatalf("ERROR SEND: %q\n", err)
}
fmt.Printf("RESPONSE: %#v\n", resp)
fmt.Printf("Msg sent.\n")
//client.Sync()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment