Files
postmoogle/bot/message.go
2022-08-25 22:31:12 +03:00

23 lines
392 B
Go

package bot
import (
"context"
"strings"
)
func (b *Bot) handle(ctx context.Context) {
evt := eventFromContext(ctx)
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)
}