vega/testbot/main.go
2020-04-11 14:39:19 -04:00

46 lines
1.1 KiB
Go

package main
import (
"log"
"time"
"git.saintnet.tech/botlib"
"maunium.net/go/mautrix"
)
func main() {
c := &botlib.Config{
Userid: "@testbot:saintnet.tech",
Server: "matrix.saintnet.tech",
Token: "MDAxYmxvY2F0aW9uIHNhaW50bmV0LnRlY2gKMDAxM2lkZW50aWZpZXIga2V5CjAwMTBjaWQgZ2VuID0gMQowMDI5Y2lkIHVzZXJfaWQgPSBAdGVzdGJvdDpzYWludG5ldC50ZWNoCjAwMTZjaWQgdHlwZSA9IGFjY2VzcwowMDIxY2lkIG5vbmNlID0gemlKZGs9bmJhcjp1eThIXgowMDJmc2lnbmF0dXJlIE4x0sbUS9lN-fi0KjJmEmpx6_wpYzgvk4k2Eugtkva7Cg",
Name: "TestBot",
Owner: "@stryan:saintnet.tech",
}
b := botlib.NewBot(c)
syncer := botlib.NewCustomSyncer("@testbot:saintnet.tech", b.Client.Store)
syncer.OnEventType(mautrix.EventMessage, b.handleMessage)
syncer.OnEventType(mautrix.StateMember, b.handleMember)
b.Client.Syncer = syncer
go func() {
err := b.Client.Sync()
if err != nil {
log.Fatal(err)
}
}()
log.Println("Syncing enabled")
err := b.LeaveEmptyRooms()
if err != nil {
log.Fatal(err)
}
err = b.createManagementRoom()
if err != nil {
log.Fatal(err)
}
log.Println("Begining main loop")
for {
time.Sleep(2 * time.Second)
}
}