Documentation ¶
Index ¶
- Constants
- func GetAs[T any](e any) *T
- func GetAsOrError[T any](e any) (*T, error)
- func GetAsUnsafe[T any](e any) *T
- type BaseEvent
- type CmdNameMode
- type CommandCenter
- type Dispatcher
- func (d *Dispatcher) Dispatch(event IEvent)
- func (d *Dispatcher) RegisterCommand(command ICommand)
- func (d *Dispatcher) RegisterHandlerAllTypes(handler Handler)
- func (d *Dispatcher) RegisterHandlerGroupMessage(handler Handler)
- func (d *Dispatcher) RegisterHandlerMeta(handler Handler)
- func (d *Dispatcher) RegisterHandlerNotice(handler Handler)
- func (d *Dispatcher) RegisterHandlerPrivateMessage(handler Handler)
- func (d *Dispatcher) RegisterHandlerRequest(handler Handler)
- func (d *Dispatcher) SetGlobalCommandPrefix(prefix string)
- type EventType
- type FriendRequestEvent
- type GroupMessageEvent
- type GroupNoticeEvent
- type GroupRequestEvent
- type GroupRequestSubtype
- type Handler
- type HonorType
- type ICommand
- type ICommandStopPropagation
- type ICommandWithPreprocess
- type IEvent
- type IMessageEvent
- type MessageEvent
- type MessageEventSubtype
- type MessageEventType
- type MetaEvent
- type MetaEventSubtype
- type MetaEventType
- type NoticeEvent
- type NoticeEventFriendAdd
- type NoticeEventFriendRecall
- type NoticeEventGroupBan
- type NoticeEventGroupHonor
- type NoticeEventGroupNotify
- type NoticeEventGroupOperation
- type NoticeEventGroupRecall
- type NoticeEventGroupUpload
- type NoticeEventSubtype
- type NoticeEventType
- type ParseResult
- type PrivateMessageEvent
- type RequestEvent
- type RequestEventType
Constants ¶
View Source
const ( EventTypeMessageSent EventType = "message_sent" EventTypeMessage EventType = "message" EventTypeNotice EventType = "notice" EventTypeRequest EventType = "request" EventTypeMeta EventType = "meta_event" MetaEventTypeLifecycle MetaEventType = "lifecycle" MetaEventTypeHeartbeat MetaEventType = "heartbeat" MetaEventSubtypeConnect MetaEventSubtype = "connect" MetaEventSubtypeDisable MetaEventSubtype = "disable" MetaEventSubtypeEnable MetaEventSubtype = "enable" MetaEventSubtypeNone MetaEventSubtype = "" MessageEventTypePrivate MessageEventType = MessageEventType(api.MessageTypePrivate) MessageEventTypeGroup MessageEventType = MessageEventType(api.MessageTypeGroup) MessageEventSubtypeFriend MessageEventSubtype = "friend" MessageEventSubtypeGroup MessageEventSubtype = "group" MessageEventSubtypeOther MessageEventSubtype = "other" MessageEventSubtypeNormal MessageEventSubtype = "normal" MessageEventSubtypeAnonymous MessageEventSubtype = "anonymous" MessageEventSubtypeNotice MessageEventSubtype = "notice" NoticeEventTypeGroupUpload NoticeEventType = "group_upload" NoticeEventTypeGroupAdmin NoticeEventType = "group_admin" NoticeEventTypeGroupDecrease NoticeEventType = "group_decrease" NoticeEventTypeGroupIncrease NoticeEventType = "group_increase" NoticeEventTypeGroupBan NoticeEventType = "group_ban" NoticeEventTypeGroupRecall NoticeEventType = "group_recall" NoticeEventTypeFriendAdd NoticeEventType = "friend_add" NoticeEventTypeFriendRecall NoticeEventType = "friend_recall" NoticeEventTypeNotify NoticeEventType = "notify" NoticeEventSubtypeApprove NoticeEventSubtype = "approve" NoticeEventSubtypeInvite NoticeEventSubtype = "invite" NoticeEventSubtypeKick NoticeEventSubtype = "kick" NoticeEventSubtypeLeave NoticeEventSubtype = "leave" NoticeEventSubtypeKickMe NoticeEventSubtype = "kick_me" NoticeEventSubtypeSet NoticeEventSubtype = "set" NoticeEventSubtypeUnset NoticeEventSubtype = "unset" NoticeEventSubtypePoke NoticeEventSubtype = "poke" NoticeEventSubtypeLuckyKing NoticeEventSubtype = "lucky_king" NoticeEventSubtypeHonor NoticeEventSubtype = "honor" NoticeEventSubtypeBan NoticeEventSubtype = "ban" NoticeEventSubtypeLiftBan NoticeEventSubtype = "lift_ban" RequestEventTypeFriend RequestEventType = "friend" RequestEventTypeGroup RequestEventType = "group" GroupRequestSubtypeAdd GroupRequestSubtype = "add" GroupRequestSubtypeInvite GroupRequestSubtype = "invite" HonorTypeTalkative HonorType = "talkative" HonorTypePerformer HonorType = "performer" HonorTypeEmotion HonorType = "emotion" )
Variables ¶
This section is empty.
Functions ¶
func GetAsOrError ¶
func GetAsUnsafe ¶
Types ¶
type BaseEvent ¶
type BaseEvent struct { Time int64 `json:"time"` SelfId qq.UserId `json:"self_id"` EventType EventType `json:"post_type"` // contains filtered or unexported fields }
func (*BaseEvent) GetEventType ¶
func (*BaseEvent) PreventDefault ¶
func (e *BaseEvent) PreventDefault()
func (*BaseEvent) SetContext ¶
type CmdNameMode ¶
type CmdNameMode string
const ( CmdNameModePrefix CmdNameMode = "prefix" CmdNameModeNormal CmdNameMode = "normal" )
type CommandCenter ¶
type CommandCenter struct { Commands map[string]ICommand PrefixCommands []ICommand // contains filtered or unexported fields }
func NewCommandCenter ¶
func NewCommandCenter(logger *zap.Logger) *CommandCenter
func (*CommandCenter) RegisterCommand ¶
func (c *CommandCenter) RegisterCommand(command ICommand)
func (*CommandCenter) SetGlobalCommandPrefix ¶
func (c *CommandCenter) SetGlobalCommandPrefix(prefix string)
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(logger *zap.Logger, isGoroutineMode bool) *Dispatcher
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(event IEvent)
func (*Dispatcher) RegisterCommand ¶
func (d *Dispatcher) RegisterCommand(command ICommand)
func (*Dispatcher) RegisterHandlerAllTypes ¶
func (d *Dispatcher) RegisterHandlerAllTypes(handler Handler)
func (*Dispatcher) RegisterHandlerGroupMessage ¶
func (d *Dispatcher) RegisterHandlerGroupMessage(handler Handler)
func (*Dispatcher) RegisterHandlerMeta ¶
func (d *Dispatcher) RegisterHandlerMeta(handler Handler)
func (*Dispatcher) RegisterHandlerNotice ¶
func (d *Dispatcher) RegisterHandlerNotice(handler Handler)
func (*Dispatcher) RegisterHandlerPrivateMessage ¶
func (d *Dispatcher) RegisterHandlerPrivateMessage(handler Handler)
func (*Dispatcher) RegisterHandlerRequest ¶
func (d *Dispatcher) RegisterHandlerRequest(handler Handler)
func (*Dispatcher) SetGlobalCommandPrefix ¶
func (d *Dispatcher) SetGlobalCommandPrefix(prefix string)
type FriendRequestEvent ¶
type FriendRequestEvent RequestEvent
func (*FriendRequestEvent) Approve ¶
func (e *FriendRequestEvent) Approve(remark string) error
Approve 同意好友请求
func (*FriendRequestEvent) Reject ¶
func (e *FriendRequestEvent) Reject(reason string) error
Reject 拒绝好友请求,reason 为拒绝理由
type GroupMessageEvent ¶
type GroupMessageEvent struct { MessageEvent GroupId qq.GroupId `json:"group_id"` Anonymous qq.AnonymousData `json:"anonymous"` Sender qq.GroupUser `json:"sender"` }
func (*GroupMessageEvent) ReplyString ¶
type GroupNoticeEvent ¶
type GroupNoticeEvent struct { NoticeEvent GroupId qq.GroupId `json:"group_id"` }
type GroupRequestEvent ¶
type GroupRequestEvent struct { RequestEvent SubType GroupRequestSubtype `json:"sub_type"` GroupId qq.GroupId `json:"group_id"` }
func (*GroupRequestEvent) Reject ¶
func (e *GroupRequestEvent) Reject(reason string) error
Reject 拒绝加群请求,reason 为拒绝理由
type GroupRequestSubtype ¶
type GroupRequestSubtype string
type ICommand ¶
type ICommand interface { GetName() (string, CmdNameMode) // GetNew 用于获取一个新的命令行参数定义结构体。 // 它将被传入回调函数。具体请参考 kong 的文档。 GetNew() any GetOptions() []kong.Option SplitBySpaceOnly() bool OnCommand(parseResult *ParseResult) }
type ICommandStopPropagation ¶
type ICommandStopPropagation interface { // StopPropagation 返回 true 时,事件将在指令处理完成后停止继续处理其它处理器。 StopPropagation() bool }
type ICommandWithPreprocess ¶
type IEvent ¶
type IMessageEvent ¶
type MessageEvent ¶
type MessageEvent struct { BaseEvent MessageType MessageEventType `json:"message_type"` SubType MessageEventSubtype `json:"sub_type"` MessageId qq.MessageId `json:"message_id"` UserId qq.UserId `json:"user_id"` Message *message.Chain `json:"message"` RawMessage string `json:"raw_message"` Font int32 `json:"font"` }
func (*MessageEvent) GetMessage ¶
func (e *MessageEvent) GetMessage() *message.Chain
func (*MessageEvent) GetMessageEventType ¶
func (e *MessageEvent) GetMessageEventType() MessageEventType
func (*MessageEvent) GetMessageId ¶
func (e *MessageEvent) GetMessageId() qq.MessageId
func (*MessageEvent) GetRawMessage ¶
func (e *MessageEvent) GetRawMessage() string
type MessageEventSubtype ¶
type MessageEventSubtype string
type MessageEventType ¶
type MessageEventType api.MessageType
type MetaEvent ¶
type MetaEvent struct { BaseEvent MetaEventType MetaEventType `json:"meta_event_type"` SubType MetaEventSubtype `json:"sub_type"` Status *api.ServerStatus `json:"status"` Interval int64 `json:"interval"` }
type MetaEventSubtype ¶
type MetaEventSubtype string
type MetaEventType ¶
type MetaEventType string
type NoticeEvent ¶
type NoticeEvent struct { BaseEvent NoticeType NoticeEventType `json:"notice_type"` SubType NoticeEventSubtype `json:"sub_type"` UserId qq.UserId `json:"user_id"` }
type NoticeEventFriendAdd ¶
type NoticeEventFriendAdd NoticeEvent
type NoticeEventFriendRecall ¶
type NoticeEventFriendRecall struct { NoticeEvent MessageId qq.MessageId `json:"message_id"` }
type NoticeEventGroupBan ¶
type NoticeEventGroupBan struct { NoticeEventGroupOperation Duration int64 `json:"duration"` }
type NoticeEventGroupHonor ¶
type NoticeEventGroupHonor struct { GroupNoticeEvent HonorType HonorType `json:"honor_type"` }
type NoticeEventGroupNotify ¶
type NoticeEventGroupNotify struct { GroupNoticeEvent TargetId qq.UserId `json:"target_id"` }
type NoticeEventGroupOperation ¶
type NoticeEventGroupOperation struct { GroupNoticeEvent OperatorId qq.UserId `json:"operator_id"` }
type NoticeEventGroupRecall ¶
type NoticeEventGroupRecall struct { GroupNoticeEvent MessageId qq.MessageId `json:"message_id"` }
type NoticeEventGroupUpload ¶
type NoticeEventGroupUpload struct { GroupNoticeEvent File struct { Id string `json:"id"` Name string `json:"name"` Size int64 `json:"size"` Busid int64 `json:"busid"` } `json:"file"` }
type NoticeEventSubtype ¶
type NoticeEventSubtype string
type NoticeEventType ¶
type NoticeEventType string
type ParseResult ¶
type ParseResult struct { Ctx *kong.Context Event IMessageEvent ParsedArgs any Error error ExitCode int StdOut string StdErr string }
func NewParseResult ¶
func NewParseResult() *ParseResult
type PrivateMessageEvent ¶
type PrivateMessageEvent struct { MessageEvent Sender qq.User `json:"sender"` }
func (*PrivateMessageEvent) ReplyString ¶
type RequestEvent ¶
type RequestEventType ¶
type RequestEventType string
Click to show internal directories.
Click to hide internal directories.