mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
event/botcommand: rename type -> schema
This commit is contained in:
parent
c5979d53d1
commit
518b9e9c45
2 changed files with 6 additions and 6 deletions
|
|
@ -248,14 +248,14 @@ func (ps *MSC4391ParameterSchema) isValid(parent MSC4391SchemaType) bool {
|
|||
|
||||
type MSC4391Parameter struct {
|
||||
Key string `json:"key"`
|
||||
Type *MSC4391ParameterSchema `json:"type"`
|
||||
Schema *MSC4391ParameterSchema `json:"schema"`
|
||||
Optional bool `json:"optional,omitempty"`
|
||||
Description *ExtensibleTextContainer `json:"description,omitempty"`
|
||||
DefaultValue any `json:"default_value,omitempty"`
|
||||
}
|
||||
|
||||
func (p *MSC4391Parameter) IsValid() bool {
|
||||
return p != nil && p.Key != "" && p.Type.IsValid()
|
||||
return p != nil && p.Key != "" && p.Schema.IsValid()
|
||||
}
|
||||
|
||||
func (p *MSC4391Parameter) GetDefaultValue() any {
|
||||
|
|
@ -264,7 +264,7 @@ func (p *MSC4391Parameter) GetDefaultValue() any {
|
|||
} else if p == nil || p.Optional {
|
||||
return nil
|
||||
}
|
||||
return p.Type.GetDefaultValue()
|
||||
return p.Schema.GetDefaultValue()
|
||||
}
|
||||
|
||||
type MSC4391BotCommandEventContent struct {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in
|
|||
origInput := input
|
||||
var nextVal string
|
||||
var wasQuoted bool
|
||||
if param.Type.SchemaType == MSC4391SchemaTypeArray {
|
||||
if param.Schema.SchemaType == MSC4391SchemaTypeArray {
|
||||
hasOpener := strings.HasPrefix(input, botArrayOpener)
|
||||
arrayClosed := false
|
||||
if hasOpener {
|
||||
|
|
@ -135,7 +135,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in
|
|||
// For array arguments in the middle without the <> delimiters, stop after the first item
|
||||
arrayClosed = true
|
||||
}
|
||||
parsedVal, err := param.Type.ParseString(nextVal)
|
||||
parsedVal, err := param.Schema.ParseString(nextVal)
|
||||
if err == nil {
|
||||
collector = append(collector, parsedVal)
|
||||
} else if hasOpener || isLast {
|
||||
|
|
@ -153,7 +153,7 @@ func (bcec *MSC4391BotCommandEventContent) ParseInput(owner id.UserID, sigil, in
|
|||
nextVal += " " + input
|
||||
input = ""
|
||||
}
|
||||
parsedVal, err := param.Type.ParseString(nextVal)
|
||||
parsedVal, err := param.Schema.ParseString(nextVal)
|
||||
if err != nil {
|
||||
args[param.Key] = param.GetDefaultValue()
|
||||
// For optional parameters that fail to parse, restore the input and try passing it as the next parameter
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue