command

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Answer answer

Functions

This section is empty.

Types

type Command

type Command struct {
	// contains filtered or unexported fields
}

Command is a bot command.

func New

func New(text string, handler Handler, options ...Options) (command Command, _ error)

New creates a new Command with the given text, non-nil handler, and optional Options.

func (*Command) Description

func (c *Command) Description() string

func (*Command) Handler

func (c *Command) Handler() Handler

func (*Command) SetHandler

func (c *Command) SetHandler(h Handler)

func (*Command) Text

func (c *Command) Text() string

type Handler

type Handler func(ctx context.Context, req *Request) (Responser, error)

func AddReactionAndSendThreadMessage

func AddReactionAndSendThreadMessage(
	client *core.Client,
	reaction, message string,
) Handler

AddReactionAndSendThreadMessage return a new Handler that adds the given reaction to the user message with the incoming command and sends the given message to a new thread for the user message.

func NewInvalidUserCommandHandler

func NewInvalidUserCommandHandler(client *core.Client, err error) Handler

NewInvalidUserCommandHandler returns a new Handler in case the command is invalid.

func NewNotFoundCommandHandler

func NewNotFoundCommandHandler(client *core.Client) Handler

NewNotFoundCommandHandler returns a new Handler in case the command is not found.

func (Handler) CommandPost

func (h Handler) CommandPost(ctx context.Context, req *Request) (Responser, error)

type List

type List []Command

func (List) Commands

func (ls List) Commands() []api.Command

Commands returns the slice of the underlying core.Command's.

func (List) HandlerLookup

func (ls List) HandlerLookup(
	ctx context.Context,
	client *core.Client,
	userCommandText api.Command,
) (context.Context, Handler)

HandlerLookup is looking for Handler corresponding the given core.Command. It returns:

type NoContentResponse

type NoContentResponse = api.CommandPostNoContent

type Options

type Options struct {
	Description           string
	AllowLongCommand      bool
	AllowUnsupportedChars bool
}

type Request

type Request = api.WebhookRequest

type Responser

type Responser = api.CommandPostRes

type Variables

type Variables map[string]string

func VariablesFromContext

func VariablesFromContext(ctx context.Context) (vars Variables, found bool)

VariablesFromContext gets Variables from the given context.Context, if any.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL