mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-07-27 06:03:48 +00:00
Compare commits
6 Commits
v1.2.0
...
75635739ba
Author | SHA1 | Date | |
---|---|---|---|
75635739ba | |||
d25e320238 | |||
b8d622bb90 | |||
9cccd0e39b | |||
e1a4293ee6 | |||
fcf79ded58 |
@ -255,8 +255,14 @@ func LoginInteract() {
|
||||
versionFile := path.Join(global.VersionsPath, fmt.Sprint(int(cli.Device().Protocol))+".json")
|
||||
if global.PathExists(versionFile) {
|
||||
b, err := os.ReadFile(versionFile)
|
||||
if err == nil {
|
||||
_ = cli.Device().Protocol.Version().UpdateFromJson(b)
|
||||
if err != nil {
|
||||
log.Warnf("从文件 %s 读取本地版本信息文件出错.", versionFile)
|
||||
os.Exit(0)
|
||||
}
|
||||
err = cli.Device().Protocol.Version().UpdateFromJson(b)
|
||||
if err != nil {
|
||||
log.Warnf("从文件 %s 解析本地版本信息出错: %v", versionFile, err)
|
||||
os.Exit(0)
|
||||
}
|
||||
log.Infof("从文件 %s 读取协议版本 %v.", versionFile, cli.Device().Protocol.Version())
|
||||
}
|
||||
@ -315,7 +321,11 @@ func LoginInteract() {
|
||||
log.Infof("如果登录时出现版本过低错误, 可尝试使用 -update-protocol 参数启动")
|
||||
case !isTokenLogin:
|
||||
_ = device.Protocol.Version().UpdateFromJson(remoteVersion)
|
||||
err := os.WriteFile(versionFile, remoteVersion, 0644)
|
||||
log.Infof("协议版本已更新: %s -> %s", currentVersionName, remoteVersionName)
|
||||
if err != nil {
|
||||
log.Warnln("更新协议版本缓存文件", versionFile, "失败:", err)
|
||||
}
|
||||
default:
|
||||
log.Infof("检测到协议更新: %s -> %s", currentVersionName, remoteVersionName)
|
||||
log.Infof("由于使用了会话缓存, 无法自动更新协议, 请删除缓存后重试")
|
||||
@ -483,7 +493,7 @@ func getRemoteLatestProtocolVersion(protocolType int) ([]byte, error) {
|
||||
}
|
||||
response, err := download.Request{URL: url}.Bytes()
|
||||
if err != nil {
|
||||
return download.Request{URL: "https://ghproxy.com/" + url}.Bytes()
|
||||
return download.Request{URL: "https://mirror.ghproxy.com/" + url}.Bytes()
|
||||
}
|
||||
return response, nil
|
||||
}
|
||||
|
@ -404,7 +404,7 @@ func ToMessageContent(e []message.IMessageElement, source message.Source) (r []g
|
||||
// ConvertStringMessage 将消息字符串转为消息元素数组
|
||||
func (bot *CQBot) ConvertStringMessage(spec *onebot.Spec, raw string, sourceType message.SourceType) (r []message.IMessageElement) {
|
||||
elems := msg.ParseString(raw)
|
||||
return bot.ConvertElements(spec, elems, sourceType, true)
|
||||
return bot.ConvertElements(spec, elems, sourceType, false)
|
||||
}
|
||||
|
||||
// ConvertObjectMessage 将消息JSON对象转为消息元素数组
|
||||
|
Reference in New Issue
Block a user