Fix Matrix bot replying to old commands on program launch (fix #11)
This commit is contained in:
parent
818e95c33f
commit
841dda8f8f
13
matrix.go
13
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)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user