1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-08 12:10:23 +08:00

add part of handler

This commit is contained in:
源文雨
2023-10-13 00:36:03 +09:00
parent 3e595b0dee
commit 40f743cf46
6 changed files with 79 additions and 5 deletions

View File

@@ -1,5 +1,7 @@
package nano
import "encoding/json"
const (
// StandardAPI 正式环境接口域名
StandardAPI = `https://api.sgroup.qq.com`
@@ -8,7 +10,7 @@ const (
)
var (
OpenAPI = StandardAPI // OpenAPI 实际使用的 API, 可自行配置
OpenAPI = StandardAPI // OpenAPI 实际使用的 API, 默认 StandardAPI, 可自行赋值配置
)
// CodeMessageBase 各种消息都有的 code + message 基类
@@ -16,3 +18,32 @@ type CodeMessageBase struct {
C int `json:"code"`
M string `json:"message"`
}
// OpCode https://bot.q.qq.com/wiki/develop/api/gateway/opcode.html
type OpCode int
const (
OpCodeDispatch OpCode = iota // Receive
OpCodeHeartbeat // Send/Receive
OpCodeIdentify // Send
OpCodeEmpty1
OpCodeEmpty2
OpCodeEmpty3
OpCodeResume // Send
OpCodeReconnect // Receive
OpCodeEmpty4
OpCodeInvalidSession // Receive
OpCodeHello // Receive
OpCodeHeartbeatACK // Receive/Reply
OpCodeHTTPCallbackACK // Reply
)
// WebsocketPayload payload 指的是在 websocket 连接上传输的数据,网关的上下行消息采用的都是同一个结构
//
// https://bot.q.qq.com/wiki/develop/api/gateway/reference.html
type WebsocketPayload struct {
Op OpCode `json:"op"`
D json.RawMessage `json:"d"`
S int `json:"s"`
T string `json:"t"`
}