1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

update MiraiGo

This commit is contained in:
wdvxdr 2023-02-14 23:27:15 +08:00
parent 59ed726c6a
commit 6b3aabd9af
6 changed files with 15 additions and 9 deletions

View File

@ -136,14 +136,16 @@ func Main() {
log.SetLevel(log.DebugLevel)
log.Warnf("已开启Debug模式.")
}
var device *client.DeviceInfo
if !global.PathExists("device.json") {
log.Warn("虚拟设备信息不存在, 将自动生成随机设备.")
client.GenRandomDevice()
_ = os.WriteFile("device.json", client.SystemDeviceInfo.ToJson(), 0o644)
device = client.GenRandomDevice()
_ = os.WriteFile("device.json", device.ToJson(), 0o644)
log.Info("已生成设备信息并保存到 device.json 文件.")
} else {
log.Info("将使用 device.json 内的设备信息运行Bot.")
if err := client.SystemDeviceInfo.ReadJson([]byte(global.ReadAllText("device.json"))); err != nil {
device = new(client.DeviceInfo)
if err := device.ReadJson([]byte(global.ReadAllText("device.json"))); err != nil {
log.Fatalf("加载设备信息失败: %v", err)
}
}
@ -205,8 +207,9 @@ func Main() {
time.Sleep(time.Second * 5)
}
log.Info("开始尝试登录并同步消息...")
log.Infof("使用协议: %s", client.SystemDeviceInfo.Protocol)
log.Infof("使用协议: %s", device.Protocol)
cli = newClient()
cli.UseDevice(device)
isQRCodeLogin := (base.Account.Uin == 0 || len(base.Account.Password) == 0) && !base.Account.Encrypt
isTokenLogin := false
saveToken := func() {

View File

@ -2012,7 +2012,7 @@ func (bot *CQBot) CQGetVersionInfo() global.MSG {
"runtime_version": runtime.Version(),
"runtime_os": runtime.GOOS,
"version": base.Version,
"protocol_name": client.SystemDeviceInfo.Protocol,
"protocol_name": bot.Client.Device().Protocol,
})
}

View File

@ -3,9 +3,10 @@ package coolq
import (
"runtime"
"github.com/tidwall/gjson"
"github.com/Mrs4s/go-cqhttp/global"
"github.com/Mrs4s/go-cqhttp/internal/base"
"github.com/tidwall/gjson"
)
// CQGetVersion 获取版本信息 OneBotV12

View File

@ -13,6 +13,7 @@ import (
"github.com/Mrs4s/go-cqhttp/global"
)
// IDConverter id 转换
type IDConverter func(id any) any
func convertGroupMemberInfo(groupID int64, m *client.GroupMemberInfo) global.MSG {
@ -224,6 +225,7 @@ func fU64(v uint64) string {
return strconv.FormatUint(v, 10)
}
// ConvertIDWithVersion id 转换
func ConvertIDWithVersion(v any, version uint16) any {
if version == 12 {
return fmt.Sprint(v)

2
go.mod
View File

@ -5,7 +5,7 @@ go 1.20
require (
github.com/FloatTech/sqlite v1.5.7
github.com/Microsoft/go-winio v0.6.0
github.com/Mrs4s/MiraiGo v0.0.0-20230213132655-3ff1fee1b645
github.com/Mrs4s/MiraiGo v0.0.0-20230214152309-cfd7d92d1f67
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e
github.com/RomiChan/websocket v1.4.3-0.20220123145318-307a86b127bc
github.com/fumiama/go-base16384 v1.6.1

4
go.sum
View File

@ -4,8 +4,8 @@ github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b h1:tvciXWq2nuvTbFeJG
github.com/FloatTech/ttl v0.0.0-20220715042055-15612be72f5b/go.mod h1:fHZFWGquNXuHttu9dUYoKuNbm3dzLETnIOnm1muSfDs=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
github.com/Mrs4s/MiraiGo v0.0.0-20230213132655-3ff1fee1b645 h1:KHWuWmhF2nacb2mKqA3OJorerCEo9n6BNizMuBACa38=
github.com/Mrs4s/MiraiGo v0.0.0-20230213132655-3ff1fee1b645/go.mod h1:mU3fBFU+7eO0kaGes7YRKtzIDtwIU84nSSwTV7NK2b0=
github.com/Mrs4s/MiraiGo v0.0.0-20230214152309-cfd7d92d1f67 h1:KUNf7psf+/2ms6ci9W2ouH+eeAzVpjZv/IW5KIDR8Mg=
github.com/Mrs4s/MiraiGo v0.0.0-20230214152309-cfd7d92d1f67/go.mod h1:mU3fBFU+7eO0kaGes7YRKtzIDtwIU84nSSwTV7NK2b0=
github.com/RomiChan/protobuf v0.1.1-0.20230204044148-2ed269a2e54d h1:/Xuj3fIiMY2ls1TwvPKmaqQrtJsPY+c9s+0lOScVHd8=
github.com/RomiChan/protobuf v0.1.1-0.20230204044148-2ed269a2e54d/go.mod h1:2Ie+hdBFQpQFDHfeklgxoFmQRCE7O+KwFpISeXq7OwA=
github.com/RomiChan/syncx v0.0.0-20221202055724-5f842c53020e h1:wR3MXQ3VbUlPKOOUwLOYgh/QaJThBTYtsl673O3lqSA=