|
|
@ -16,6 +16,7 @@ import ( |
|
|
|
shellwords "github.com/mattn/go-shellwords" |
|
|
|
log "github.com/sirupsen/logrus" |
|
|
|
"maunium.net/go/mautrix" |
|
|
|
"maunium.net/go/mautrix/event" |
|
|
|
mevt "maunium.net/go/mautrix/event" |
|
|
|
"maunium.net/go/mautrix/id" |
|
|
|
) |
|
|
@ -344,6 +345,15 @@ func (c *Clients) initClient(botClient *BotClient) error { |
|
|
|
botClient.verificationSAS = &sync.Map{} |
|
|
|
|
|
|
|
syncer := client.Syncer.(*mautrix.DefaultSyncer) |
|
|
|
syncer.ParseErrorHandler = func(evt *event.Event, err error) bool { |
|
|
|
// Events of type m.room.bot.options will be flagged as errors as this isn't an event type
|
|
|
|
// recognised by the Syncer, but we need to process them so the bot can accept options
|
|
|
|
// through this event (see onBotOptionsEvent)
|
|
|
|
if evt.Type.Type == "m.room.bot.options" { |
|
|
|
return true |
|
|
|
} |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
nebStore := &matrix.NEBStore{ |
|
|
|
InMemoryStore: *mautrix.NewInMemoryStore(), |
|
|
@ -366,7 +376,7 @@ func (c *Clients) initClient(botClient *BotClient) error { |
|
|
|
c.onMessageEvent(botClient, event) |
|
|
|
}) |
|
|
|
|
|
|
|
syncer.OnEventType(mevt.Type{Type: "m.room.bot.options", Class: mevt.UnknownEventType}, func(_ mautrix.EventSource, event *mevt.Event) { |
|
|
|
syncer.OnEventType(mevt.Type{Type: "m.room.bot.options", Class: mevt.StateEventType}, func(_ mautrix.EventSource, event *mevt.Event) { |
|
|
|
c.onBotOptionsEvent(botClient.Client, event) |
|
|
|
}) |
|
|
|
|
|
|
|