From 841dda8f8f2f2ef810e145fc8732bb1600906c11 Mon Sep 17 00:00:00 2001 From: Noah Date: Mon, 11 Mar 2024 17:43:24 -0500 Subject: [PATCH] Fix Matrix bot replying to old commands on program launch (fix #11) --- matrix.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/matrix.go b/matrix.go index ece3fe8..ecccda8 100644 --- a/matrix.go +++ b/matrix.go @@ -64,6 +64,7 @@ func initMatrix() { log.Printf("[Matrix] Logged in as %s", resp.UserID) syncer := client.Syncer.(*mautrix.DefaultSyncer) + client.Syncer.(mautrix.ExtensibleSyncer).OnSync(client.DontProcessOldEvents) syncer.OnEventType(event.StateMember, func(ctx context.Context, evt *event.Event) { if evt.GetStateKey() == client.UserID.String() && evt.Content.AsMember().Membership == event.MembershipInvite { if evt.RoomID.String() == configuration.matrix.room_id { @@ -140,9 +141,11 @@ func initMatrix() { } }() - log.Print("[Matrix] Running!") - err = client.Sync() - if err != nil { - log.Fatal(err) - } + go func() { + log.Print("[Matrix] Running!") + err = client.Sync() + if err != nil { + log.Fatal(err) + } + }() }