mirror of
https://github.com/maubot/maubot
synced 2025-08-29 19:00:39 +00:00
Add command spec parsing/handler execution
This commit is contained in:
parent
307a32e0c0
commit
4536fcfe62
9 changed files with 282 additions and 37 deletions
17
matrix.go
17
matrix.go
|
@ -54,11 +54,13 @@ const (
|
|||
const FormatHTML = "org.matrix.custom.html"
|
||||
|
||||
type EventHandler func(*Event) EventHandlerResult
|
||||
type EventHandlerResult bool
|
||||
type EventHandlerResult int
|
||||
type CommandHandlerResult = EventHandlerResult
|
||||
|
||||
const (
|
||||
Continue EventHandlerResult = false
|
||||
StopPropagation EventHandlerResult = true
|
||||
Continue EventHandlerResult = iota
|
||||
StopEventPropagation
|
||||
StopCommandPropagation CommandHandlerResult = iota
|
||||
)
|
||||
|
||||
type MatrixClient interface {
|
||||
|
@ -130,7 +132,8 @@ type Content struct {
|
|||
|
||||
Membership string `json:"membership,omitempty"`
|
||||
|
||||
RelatesTo RelatesTo `json:"m.relates_to,omitempty"`
|
||||
Command MatchedCommand `json:"m.command,omitempty"`
|
||||
RelatesTo RelatesTo `json:"m.relates_to,omitempty"`
|
||||
}
|
||||
|
||||
func (content Content) Equals(otherContent *Content) bool {
|
||||
|
@ -162,6 +165,12 @@ func (fi *FileInfo) Equals(otherFI *FileInfo) bool {
|
|||
((fi.ThumbnailInfo != nil && fi.ThumbnailInfo.Equals(otherFI.ThumbnailInfo)) || otherFI.ThumbnailInfo == nil)
|
||||
}
|
||||
|
||||
type MatchedCommand struct {
|
||||
Target string `json:"target"`
|
||||
Matched string `json:"matched"`
|
||||
Arguments map[string]string `json:"arguments"`
|
||||
}
|
||||
|
||||
type RelatesTo struct {
|
||||
InReplyTo InReplyTo `json:"m.in_reply_to,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue