command

package
v0.0.0-...-d38fdcd Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Arg

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

type Cmd

type Cmd struct {
	Commands Commands
	// contains filtered or unexported fields
}

func New

func New(bot *cqhttp_bot.Bot) (c *Cmd)

func (*Cmd) AddCommand

func (c *Cmd) AddCommand(Commands ...*Command)

func (*Cmd) GetCommand

func (c *Cmd) GetCommand(name string) *Command

func (*Cmd) Help

func (c *Cmd) Help() string

func (*Cmd) Trigger

func (c *Cmd) Trigger(t string)

Trigger 触发解析命令的字段,默认:/

type Command

type Command struct {
	Name  string
	Usage string

	Run RunFunc
	// contains filtered or unexported fields
}

func DefaultCommandHelp

func DefaultCommandHelp(c *Cmd) *Command

func (*Command) AddSubCommand

func (c *Command) AddSubCommand(Commands ...*Command)

func (*Command) Flag

func (c *Command) Flag() *Flag

func (*Command) Help

func (c *Command) Help() string

type Commands

type Commands map[string]*Command

func (Commands) Parse

func (c Commands) Parse(str string) (co *Command, f Flag, p string)

type Flag

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

func (Flag) Get

func (f Flag) Get(name string) (string, bool)

func (Flag) GetInt

func (f Flag) GetInt(name string) (int, bool)

func (Flag) Range

func (f Flag) Range(fun func(name, value, usage string))

func (*Flag) Var

func (f *Flag) Var(name, defaultValue, usage string)

type RunFunc

type RunFunc func(paramete string, flag Flag, bot *cqhttp_bot.Bot, ctx *cqhttp_bot.EventMessageContext)

Jump to

Keyboard shortcuts

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