cmd

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Member       = &Permission{Name: "成员", Level: 0}    // 普通成员
	ChannelAdmin = &Permission{Name: "频道管理员", Level: 1} // 子频道管理员
	Admin        = &Permission{Name: "超级管理员", Level: 2} // 超级管理员
	Owner        = &Permission{Name: "频道主", Level: 3}   // 频道主
)
View Source
var (
	RetryError = errors.New("retry")
)

Functions

func AddBlackChannels added in v0.1.0

func AddBlackChannels(gid string, cid ...string)

func AddBlackUsers added in v0.1.0

func AddBlackUsers(us ...*user)

func AddWhiteChannels added in v0.1.0

func AddWhiteChannels(gid string, cid ...string)

func Process

func Process(data *dto.Message)

func Register

func Register(config *Config, handles ...interface{})

func RemoveBlackChannels added in v0.1.0

func RemoveBlackChannels(gid string, cid ...string)

func RemoveBlackUsers added in v0.1.0

func RemoveBlackUsers(users ...*user)

func RemoveWhiteChannels added in v0.1.0

func RemoveWhiteChannels(gid string, cid ...string)

func Run

func Run(ctx *Context)

func SendReply

func SendReply(ctx *Context, msg *MsgView)

func SendReplyJS added in v0.1.0

func SendReplyJS(ctx *Context, image string, msg string)

func SendReplyS added in v0.1.0

func SendReplyS(ctx *Context, msg string)

func SendRunning added in v0.0.3

func SendRunning(running *RunningCommand)

func SetApi added in v0.0.3

func SetApi(a openapi.OpenAPI)

func SetGlobalAfterHandle added in v0.1.0

func SetGlobalAfterHandle(f ...func(ctx *Context) (bool, error))

func SetGlobalBeforeHandle added in v0.1.0

func SetGlobalBeforeHandle(f ...func(ctx *Context) (bool, error))

func SetGroupAfterHandle added in v0.1.0

func SetGroupAfterHandle(group string, f ...func(ctx *Context) (bool, error))

func SetGroupBeforeHandle added in v0.1.0

func SetGroupBeforeHandle(group string, f ...func(ctx *Context) (bool, error))

func WaitDialog added in v0.0.5

func WaitDialog(dialog Dialog) interface{}

Types

type BaseDialog added in v0.0.4

type BaseDialog struct {
	Ctx         *Context      // 启动此对话框的上下文
	MainMsgView *MsgView      // 主消息视图
	Channel     chan *Context // 通道,用于回复Dialog
}

func (*BaseDialog) GetChannel added in v0.0.5

func (b *BaseDialog) GetChannel() chan *Context

func (*BaseDialog) GetCtx added in v0.1.0

func (b *BaseDialog) GetCtx() *Context

func (*BaseDialog) GetMainMsgView added in v0.0.5

func (b *BaseDialog) GetMainMsgView() *MsgView

func (*BaseDialog) Handle added in v0.0.5

func (b *BaseDialog) Handle(ctx *Context) interface{}

func (*BaseDialog) SendMainMsgView added in v0.0.5

func (b *BaseDialog) SendMainMsgView(ctx *Context)

type Command added in v0.0.4

type Command struct {
	*Config
	Handles []interface{}
}

func GetPrivateCommand added in v0.0.4

func GetPrivateCommand(id string) (*Command, bool)

type Config

type Config struct {
	ID             string      // ID
	Group          []string    // 分组
	Name           string      // 名称
	Alias          []string    // 别名
	Usage          string      // 用法
	Emoji          string      // emoji图标
	Description    string      // 描述
	Permission     *Permission // 权限
	DisableChannel bool        // 是否在子频道禁用
	DisableDirect  bool        // 是否在私信禁用
	Private        bool        // 是否为内部指令
	Async          bool        // 是否可异步执行
}

type Context

type Context struct {
	context.Context
	Api     openapi.OpenAPI // api
	Data    *dto.Message    // 事件数据
	Direct  bool            // 是否是私聊事件
	Msg     string          // 消息内容
	Cmd     *Command        // 指令
	CmdName string          // 指令名
	Args    []interface{}   // 参数
}

type Dialog added in v0.0.4

type Dialog interface {
	SendMainMsgView(ctx *Context)
	Handle(ctx *Context) interface{}

	GetCtx() *Context
	GetMainMsgView() *MsgView
	GetChannel() chan *Context
}

type DialogStack added in v0.0.7

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

func (*DialogStack) Last added in v0.0.7

func (s *DialogStack) Last() Dialog

func (*DialogStack) Pop added in v0.0.7

func (s *DialogStack) Pop() Dialog

func (*DialogStack) Push added in v0.0.7

func (s *DialogStack) Push(d Dialog)

type MsgView added in v0.0.4

type MsgView struct {
	Msg   string
	Image string
	NotAt bool
}

type Permission added in v0.1.0

type Permission struct {
	Name  string // 权限名
	Level int    // 权限等级
}

type RunningCommand added in v0.0.3

type RunningCommand struct {
	Ctx    *Context
	Handle interface{}
	Params []reflect.Value
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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