1
0
mirror of https://github.com/fumiama/NanoBot.git synced 2026-06-11 05:30:24 +08:00
This commit is contained in:
源文雨
2023-10-15 01:17:41 +09:00
parent dd054c168c
commit c5a11b858f

19
bot.go
View File

@@ -1,6 +1,7 @@
package nano package nano
import ( import (
"crypto/tls"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"net" "net"
@@ -28,15 +29,15 @@ type Bot struct {
Intents uint32 // Intents 欲接收的事件 Intents uint32 // Intents 欲接收的事件
Properties json.RawMessage // Properties 一些环境变量, 目前没用 Properties json.RawMessage // Properties 一些环境变量, 目前没用
gateway string // gateway 获得的网关 gateway string // gateway 获得的网关
shard [2]byte // shard 分片 shard [2]byte // shard 分片
seq uint32 seq uint32 // seq 最新的 s
handlers map[string]GeneralHandleType // handlers 方便调用的 handler handlers map[string]GeneralHandleType // handlers 方便调用的 handler
mu sync.Mutex // 写锁 mu sync.Mutex // 写锁
conn *websocket.Conn conn *websocket.Conn // conn 目前的 wss 连接
heartbeat uint32 // heartbeat 心跳周期, 单位毫秒
ready EventReady ready EventReady //
heartbeat uint32 // heartbeat 心跳周期, 单位毫秒
} }
// Init 初始化, 只需执行一次 // Init 初始化, 只需执行一次
@@ -90,7 +91,7 @@ func (bot *Bot) Connect() {
addr = BytesToString(filepath) addr = BytesToString(filepath)
} }
} }
return net.Dial(network, addr) // support unix socket transport return tls.Dial(network, addr, websocket.DefaultDialer.TLSClientConfig) // support unix socket transport
}, },
} }
for { for {