Documentation
¶
Overview ¶
Package onebot 实现 OneBot v11 正向 WebSocket 客户端。
Index ¶
- func RenderMessage(message msg.Message, limit int) string
- type Action
- type Client
- func (c *Client) Call(ctx context.Context, action string, params any) (json.RawMessage, error)
- func (c *Client) Connected() bool
- func (c *Client) Run(ctx context.Context)
- func (c *Client) SendGroup(groupID int64, message msg.Message) error
- func (c *Client) SendPrivate(userID int64, message msg.Message) error
- type Config
- type Event
- type EventHandler
- type Response
- type Sender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client 会持续重连,直到上下文被取消;写入会串行化。
func NewClient ¶
func NewClient(cfg Config, handler EventHandler) *Client
type Event ¶
type Event struct {
PostType string `json:"post_type"`
MessageType string `json:"message_type"`
NoticeType string `json:"notice_type"`
RequestType string `json:"request_type"`
MetaEventType string `json:"meta_event_type"`
SubType string `json:"sub_type"`
MessageID int64 `json:"message_id"`
GroupID int64 `json:"group_id"`
UserID int64 `json:"user_id"`
OperatorID int64 `json:"operator_id"`
RawMessage string `json:"raw_message"`
Comment string `json:"comment"`
Flag string `json:"flag"`
Sender Sender `json:"sender"`
}
Event 是框架使用的 OneBot 事件子集。这里使用 RawMessage 而非 message, 因为不同适配器对字符串和消息段数组编码的处理不同。
type EventHandler ¶
EventHandler 在读取协程中处理已解码的 OneBot 事件。ctx 在客户端关闭时取消。
Click to show internal directories.
Click to hide internal directories.