Created
June 8, 2022 21:22
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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