Documentation
¶
Index ¶
- Variables
- type EventContent
- func (ec *EventContent) Equals(other *EventContent) bool
- func (ec *EventContent) IsValid() bool
- func (ec *EventContent) ParseArguments(input string) (json.RawMessage, error)
- func (ec *EventContent) ParseInput(owner id.UserID, sigils []string, input string) (content *event.MessageEventContent, err error)
- func (ec *EventContent) StateKey(owner id.UserID) string
- func (ec *EventContent) StringifyArgs(args any) string
- func (ec *EventContent) Validate() error
- type Parameter
- type ParameterSchema
- func (ps *ParameterSchema) AllowsPrimitive(prim PrimitiveType) bool
- func (ps *ParameterSchema) Equals(other *ParameterSchema) bool
- func (ps *ParameterSchema) GetDefaultValue() any
- func (ps *ParameterSchema) IsValid() bool
- func (ps *ParameterSchema) ParseString(value string) (any, error)
- func (ps *ParameterSchema) Validate() error
- type PrimitiveType
- type RoomIDOrString
- type RoomIDValue
- type SchemaType
Constants ¶
This section is empty.
Variables ¶
View Source
var ParameterSchemaJoinableRoom = Union( PrimitiveTypeRoomID.Schema(), PrimitiveTypeRoomAlias.Schema(), )
Functions ¶
This section is empty.
Types ¶
type EventContent ¶
type EventContent struct {
Command string `json:"command"`
Aliases []string `json:"aliases,omitempty"`
Parameters []*Parameter `json:"parameters,omitempty"`
Description *event.ExtensibleTextContainer `json:"description,omitempty"`
TailParam string `json:"fi.mau.tail_parameter,omitempty"`
}
func (*EventContent) Equals ¶
func (ec *EventContent) Equals(other *EventContent) bool
func (*EventContent) IsValid ¶
func (ec *EventContent) IsValid() bool
func (*EventContent) ParseArguments ¶
func (ec *EventContent) ParseArguments(input string) (json.RawMessage, error)
func (*EventContent) ParseInput ¶
func (ec *EventContent) ParseInput(owner id.UserID, sigils []string, input string) (content *event.MessageEventContent, err error)
ParseInput tries to parse the given text into a bot command event matching this command definition.
If the prefix doesn't match, this will return a nil content and nil error. If the prefix does match, some content is always returned, but there may still be an error if parsing failed.
func (*EventContent) StringifyArgs ¶
func (ec *EventContent) StringifyArgs(args any) string
func (*EventContent) Validate ¶
func (ec *EventContent) Validate() error
type Parameter ¶
type Parameter struct {
Key string `json:"key"`
Schema *ParameterSchema `json:"schema"`
Optional bool `json:"optional,omitempty"`
Description *event.ExtensibleTextContainer `json:"description,omitempty"`
DefaultValue any `json:"fi.mau.default_value,omitempty"`
}
func (*Parameter) GetDefaultValue ¶
type ParameterSchema ¶
type ParameterSchema struct {
SchemaType SchemaType `json:"schema_type"`
Type PrimitiveType `json:"type,omitempty"` // Only for primitive
Items *ParameterSchema `json:"items,omitempty"` // Only for array
Variants []*ParameterSchema `json:"variants,omitempty"` // Only for union
Value any `json:"value,omitempty"` // Only for literal
}
func Array ¶
func Array(items *ParameterSchema) *ParameterSchema
func Enum ¶
func Enum(values ...any) *ParameterSchema
func Literal ¶
func Literal(value any) *ParameterSchema
func Union ¶
func Union(variants ...*ParameterSchema) *ParameterSchema
func (*ParameterSchema) AllowsPrimitive ¶
func (ps *ParameterSchema) AllowsPrimitive(prim PrimitiveType) bool
func (*ParameterSchema) Equals ¶
func (ps *ParameterSchema) Equals(other *ParameterSchema) bool
func (*ParameterSchema) GetDefaultValue ¶
func (ps *ParameterSchema) GetDefaultValue() any
func (*ParameterSchema) IsValid ¶
func (ps *ParameterSchema) IsValid() bool
func (*ParameterSchema) ParseString ¶
func (ps *ParameterSchema) ParseString(value string) (any, error)
func (*ParameterSchema) Validate ¶
func (ps *ParameterSchema) Validate() error
type PrimitiveType ¶
type PrimitiveType string
const ( PrimitiveTypeString PrimitiveType = "string" PrimitiveTypeInteger PrimitiveType = "integer" PrimitiveTypeBoolean PrimitiveType = "boolean" PrimitiveTypeServerName PrimitiveType = "server_name" PrimitiveTypeUserID PrimitiveType = "user_id" PrimitiveTypeRoomID PrimitiveType = "room_id" PrimitiveTypeRoomAlias PrimitiveType = "room_alias" PrimitiveTypeEventID PrimitiveType = "event_id" )
func (PrimitiveType) IsValid ¶
func (pt PrimitiveType) IsValid() bool
func (PrimitiveType) NormalizeValue ¶
func (pt PrimitiveType) NormalizeValue(value any) (any, error)
func (PrimitiveType) ParseString ¶
func (pt PrimitiveType) ParseString(value string) (any, error)
func (PrimitiveType) Schema ¶
func (pt PrimitiveType) Schema() *ParameterSchema
func (PrimitiveType) ValidateValue ¶
func (pt PrimitiveType) ValidateValue(value any) bool
type RoomIDOrString ¶
type RoomIDOrString string
func (*RoomIDOrString) UnmarshalJSON ¶
func (ros *RoomIDOrString) UnmarshalJSON(data []byte) error
type RoomIDValue ¶
type RoomIDValue struct {
Type PrimitiveType `json:"type"`
RoomID id.RoomID `json:"id"`
Via []string `json:"via,omitempty"`
EventID id.EventID `json:"event_id,omitempty"`
}
func NormalizeRoomIDValue ¶
func NormalizeRoomIDValue(input any) (riv *RoomIDValue, err error)
func (*RoomIDValue) Equals ¶
func (riv *RoomIDValue) Equals(other *RoomIDValue) bool
func (*RoomIDValue) IsValid ¶
func (riv *RoomIDValue) IsValid() bool
func (*RoomIDValue) String ¶
func (riv *RoomIDValue) String() string
func (*RoomIDValue) URI ¶
func (riv *RoomIDValue) URI() *id.MatrixURI
func (*RoomIDValue) Validate ¶
func (riv *RoomIDValue) Validate() error
type SchemaType ¶
type SchemaType string
const ( SchemaTypePrimitive SchemaType = "primitive" SchemaTypeArray SchemaType = "array" SchemaTypeUnion SchemaType = "union" SchemaTypeLiteral SchemaType = "literal" )
Click to show internal directories.
Click to hide internal directories.