spam:add using emoji

This commit is contained in:
Aine
2023-09-22 22:15:53 +03:00
parent 3bb1f3ecba
commit 74defa85e4
4 changed files with 67 additions and 3 deletions

View File

@@ -21,7 +21,14 @@ func (b *Bot) initSync() {
event.EventMessage,
func(_ mautrix.EventSource, evt *event.Event) {
go b.onMessage(evt)
})
},
)
b.lp.OnEventType(
event.EventReaction,
func(_ mautrix.EventSource, evt *event.Event) {
go b.onReaction(evt)
},
)
}
// joinPermit is called by linkpearl when processing "invite" events and deciding if rooms should be auto-joined or not
@@ -69,6 +76,20 @@ func (b *Bot) onMessage(evt *event.Event) {
b.handle(ctx)
}
func (b *Bot) onReaction(evt *event.Event) {
// ignore own messages
if evt.Sender == b.lp.GetClient().UserID {
return
}
// mautrix 0.15.x migration
if b.ignoreBefore >= evt.Timestamp {
return
}
ctx := newContext(evt)
b.handleReaction(ctx)
}
// onBotJoin handles the "bot joined the room" event
func (b *Bot) onBotJoin(ctx context.Context) {
evt := eventFromContext(ctx)