diff --git a/main.go b/main.go index 34fa03f..43c004a 100644 --- a/main.go +++ b/main.go @@ -5,11 +5,13 @@ import ( "os" "os/signal" "strconv" + "strings" "sync" mbl "git.saintnet.tech/stryan/matrixbotlib" "maunium.net/go/mautrix" "maunium.net/go/mautrix/event" + "maunium.net/go/mautrix/id" ) //GitTag is current git tag @@ -42,12 +44,15 @@ func main() { } store := mautrix.NewAccountDataStore("nun.batch", matrixClient) - _, err = matrixClient.CreateFilter(dataFilter) + fID, err := matrixClient.CreateFilter(dataFilter) if err != nil { //don't want to continue if we can't keep state panic(err) } var nun *nunWatch + uid := id.NewUserID(strings.ToLower(conf.Username), strings.ToLower(conf.Domain)) + log.Println(uid) + store.SaveFilterID(uid, fID.FilterID) matrixClient.Store = store syncer := matrixClient.Syncer.(*mautrix.DefaultSyncer) mbl.AcceptAllRoomInvites(matrixClient) diff --git a/nun.go b/nun.go index 20f21dd..80e0b19 100644 --- a/nun.go +++ b/nun.go @@ -39,14 +39,14 @@ func (n *nunWatch) Main() { if n.fail > 3 { log.Println("over three failures, increasing tick time by 5x") ticker.Reset(5 * time.Duration(n.timer) * time.Minute) - continue + break } newPost, err := getNewestPost("LittleNuns") if err != nil { log.Printf("error getting newest post: %v", err) log.Println("skipping this cycle, incrementing fail count") n.fail++ - continue + break } if n.fail != 0 { n.fail = 0 @@ -68,7 +68,7 @@ func (n *nunWatch) Main() { roomResp, err := n.client.JoinedRooms() if err != nil { log.Printf("error getting joined rooms: %v", err) - continue + break } rooms := roomResp.JoinedRooms for _, room := range rooms {