processor

package
v0.0.0-...-fa0c35c Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NotMatchedCommandMessageTemplate        = "很抱歉,没有找到这个命令,这个命令可能不存在或者仍在测试中,命令:%s,参数:%s"
	IncorrectCommandArgumentMessageTemplate = "很抱歉,您的命令输入有误,您使用的命令可能是:\n%s"
	CommandHelpArgumentMessageTemplate      = "功能%s,参数%s的命令使用提示如下:\n%s"
	CommandArgumentInfoTemplate             = "%d. %s: %s\n描述:%s\n\n使用示例:\n%s\n"
	ListHelpInfoMessageTemplate             = "功能%s的命令如下:\n%s"
	HelpInfoTemplate                        = "%d. %s: %s"
	ListAllServiceInfoTemplate              = "所有功能如下:\n%s"
	ServiceInfoTemplate                     = "%d. %s"
)

Functions

func AtMessageEventHandler

func AtMessageEventHandler(api openapi.OpenAPI) event.ATMessageEventHandler

func FormatCommandArgumentInfo

func FormatCommandArgumentInfo(index int, info HandlerInfo) string

func FormatCommandHelpArgumentMessage

func FormatCommandHelpArgumentMessage(command, content string, commandInfos []HandlerInfo) string

func FormatHelpInfo

func FormatHelpInfo(index int, info HandlerInfo) string

func FormatIncorrectCommandArgumentMessage

func FormatIncorrectCommandArgumentMessage(commandInfos []HandlerInfo) string

func FormatListAllServiceInfoMessage

func FormatListAllServiceInfoMessage() string

func FormatListHelpInfoMessage

func FormatListHelpInfoMessage(command string, commandInfos []HandlerInfo) string

func FormatNotMatchedCommandMessage

func FormatNotMatchedCommandMessage(command, content string) string

func FormatServiceInfo

func FormatServiceInfo(index int, service string) string

func Serve

func Serve()

Types

type Client

type Client interface {
	ReplyMessage(ctx Context, reply message.Message)
	SendMessage(ctx Context, content message.Message)
}

func NewClient

func NewClient(api openapi.OpenAPI) Client

type Context

type Context interface {
	GetContext() context.Context
	SetContext(ctx context.Context)
	GetApi() Client
	GetPayload() Payload
	Next()
	Abort()
	IsAborted() bool
}

func NewContext

func NewContext(ctx context.Context, api openapi.OpenAPI, payload Payload, functions []MustHandleFunction, handlers []OptionalHandleFunction) Context

type HandlerInfo

type HandlerInfo struct {
	CommandKey         string
	CommandName        string
	CommandDescription string
	CommandExample     string
}

type HandlerMatcher

type HandlerMatcher interface {
	MatchHandlers(command string, content string) (mustHandlers []MustHandleFunction, optionalHandlers []OptionalHandleFunction)
	SetDefaultHandlerFunctions(mustHandlers []MustHandleFunction, optionalHandlers []OptionalHandleFunction)
	RegisterCommand(commandKey, commandName, commandDescription, commandExample string, contentFilter func(string) bool, mustHandlers []MustHandleFunction, optionalHandlers []OptionalHandleFunction)
	ListCommands(commandKey string) (commandInfoMap map[string]HandlerInfo)
	ListAllCommands() (commands []string)
	GetHelpInfo(commandKey, commandContent string) (commandInfo []HandlerInfo)
}

func DefaultMatcher

func DefaultMatcher() HandlerMatcher

func NewHandlerMatcher

func NewHandlerMatcher() HandlerMatcher

type MessageHandleFunction

type MessageHandleFunction func(ctx Context)

MessageHandleFunction 消息处理函数

type MustHandleFunction

type MustHandleFunction MessageHandleFunction

MustHandleFunction 必须被处理的消息处理函数

type OptionalHandleFunction

type OptionalHandleFunction MessageHandleFunction

OptionalHandleFunction 可以不被处理的消息处理函数

func HelpCommandReplyHandler

func HelpCommandReplyHandler() OptionalHandleFunction

func IncorrectCommandReplyHandler

func IncorrectCommandReplyHandler() OptionalHandleFunction

func ListAllCommandReplyHandler

func ListAllCommandReplyHandler() OptionalHandleFunction

func ListCommandReplyHandler

func ListCommandReplyHandler() OptionalHandleFunction

func NotFoundCommandAfterIncorrectCommandCheckReplyHandler

func NotFoundCommandAfterIncorrectCommandCheckReplyHandler() OptionalHandleFunction

func NotMatchedCommandReplyHandler

func NotMatchedCommandReplyHandler() OptionalHandleFunction

type Payload

type Payload struct {
	Message    *dto.WSATMessageData
	Event      *dto.WSPayload
	Command    string
	Content    string
	RawContent string
}

type SystemConfig

type SystemConfig struct {
	AppID          uint64 `yaml:"app_id"`
	AppSecret      string `yaml:"app_secret"`
	AppToken       string `yaml:"app_token"`
	TimeoutSecond  int    `yaml:"timeout_second"`
	TestMode       bool   `yaml:"test_mode"`
	UndefinedReply string `yaml:"undefined_reply"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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