This commit is contained in:
Aine
2022-08-21 18:41:35 +03:00
commit c4b7a16e21
22 changed files with 1745 additions and 0 deletions

23
bot/message.go Normal file
View File

@@ -0,0 +1,23 @@
package bot
import (
"context"
"strings"
"maunium.net/go/mautrix/event"
)
func (b *Bot) handle(ctx context.Context, evt *event.Event) {
content := evt.Content.AsMessage()
if content == nil {
b.Error(ctx, evt.RoomID, "cannot read message")
return
}
message := strings.TrimSpace(content.Body)
command := b.parseCommand(message)
if command == nil {
return
}
b.handleCommand(ctx, evt, command)
}