diff --git a/main.go b/main.go index 3978ad2..a300ed7 100644 --- a/main.go +++ b/main.go @@ -25,11 +25,27 @@ func main() { panic(err) } } - store := mbl.NewLazyMemStore(conf.Statefile) - matrixClient, err := mbl.NewMatrixClient(conf, store) + dataFilter := &mautrix.Filter{ + AccountData: mautrix.FilterPart{ + Limit: 20, + NotTypes: []event.Type{ + event.NewEventType("nun.batch"), + }, + }, + } + + matrixClient, err := mbl.NewMatrixClient(conf, nil) if err != nil { panic(err) } + + store := mautrix.NewAccountDataStore("nun.batch", matrixClient) + _, err = matrixClient.CreateFilter(dataFilter) + if err != nil { + //don't want to continue if we can't keep state + panic(err) + } + matrixClient.Store = store syncer := matrixClient.Syncer.(*mautrix.DefaultSyncer) mbl.AcceptAllRoomInvites(matrixClient) syncer.OnEventType(event.EventMessage, func(source mautrix.EventSource, evt *event.Event) { @@ -43,7 +59,7 @@ func main() { } return } - switch cmd[1] { + switch cmd[0] { case "version": // print version if GitTag != "" {