event/botcommand: rename type -> schema
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2026-01-05 21:17:13 +02:00
commit 518b9e9c45
2 changed files with 6 additions and 6 deletions

View file

@ -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 {

View file

@ -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