From 2f00ffdb9c21a66b86a1a444e4b6347ca9dae4c0 Mon Sep 17 00:00:00 2001 From: cosmo Date: Mon, 8 Jan 2024 13:47:06 +0800 Subject: [PATCH 1/5] beta122 --- readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/readme.md b/readme.md index d8f7a8ee..90341e90 100644 --- a/readme.md +++ b/readme.md @@ -40,6 +40,9 @@ _✨ 基于 [OneBot](https://github.com/howmanybots/onebot/blob/master/README.md · 参与贡献

+

+ 项目主页:gensokyo.bot +

## 引用 - [`tencent-connect/botgo`](https://github.com/tencent-connect/botgo): 本项目引用了此项目,并做了一点改动. From 2158740465a2f59dd5ae7727c71b8b63158088a1 Mon Sep 17 00:00:00 2001 From: cosmo Date: Thu, 11 Jan 2024 17:13:42 +0800 Subject: [PATCH 2/5] beta123 --- handlers/send_msg.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/handlers/send_msg.go b/handlers/send_msg.go index 1982ae06..b06dc2b5 100644 --- a/handlers/send_msg.go +++ b/handlers/send_msg.go @@ -33,13 +33,15 @@ func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope if msgType == "" { msgType = GetMessageTypeByUserid(config.GetAppIDStr(), message.Params.UserID) } - //新增 内存获取不到从数据库获取 + //顺序有讲究 if msgType == "" { - msgType = GetMessageTypeByUseridV2(message.Params.UserID) + msgType = GetMessageTypeByGroupidV2(message.Params.GroupID) } + //新增 内存获取不到从数据库获取 if msgType == "" { - msgType = GetMessageTypeByGroupidV2(message.Params.GroupID) + msgType = GetMessageTypeByUseridV2(message.Params.UserID) } + var idInt64 int64 var err error From ea41561628f1d01fd60b334592e65bb3cef4c156 Mon Sep 17 00:00:00 2001 From: cosmo Date: Thu, 11 Jan 2024 19:38:41 +0800 Subject: [PATCH 3/5] beta124 --- handlers/send_msg.go | 5 ++++- handlers/send_private_msg.go | 12 ++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/handlers/send_msg.go b/handlers/send_msg.go index b06dc2b5..fa6562f8 100644 --- a/handlers/send_msg.go +++ b/handlers/send_msg.go @@ -42,13 +42,15 @@ func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope msgType = GetMessageTypeByUseridV2(message.Params.UserID) } - var idInt64 int64 + var idInt64, idInt642 int64 var err error if message.Params.GroupID != "" { idInt64, err = ConvertToInt64(message.Params.GroupID) + idInt642, err = ConvertToInt64(message.Params.UserID) } else if message.Params.UserID != "" { idInt64, err = ConvertToInt64(message.Params.UserID) + idInt642, err = ConvertToInt64(message.Params.GroupID) } //设置递归 对直接向gsk发送action时有效果 @@ -101,6 +103,7 @@ func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope //重置递归类型 if echo.GetMapping(idInt64) <= 0 { echo.AddMsgType(config.GetAppIDStr(), idInt64, "") + echo.AddMsgType(config.GetAppIDStr(), idInt642, "") } echo.AddMapping(idInt64, echo.GetMapping(idInt64)-1) diff --git a/handlers/send_private_msg.go b/handlers/send_private_msg.go index 43bcba67..6dcefe7d 100644 --- a/handlers/send_private_msg.go +++ b/handlers/send_private_msg.go @@ -29,14 +29,14 @@ func HandleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 open msgType = echo.GetMsgTypeByKey(echoStr) } - //如果获取不到 就用group_id获取信息类型 - if msgType == "" { - msgType = GetMessageTypeByGroupid(config.GetAppIDStr(), message.Params.GroupID) - } //如果获取不到 就用user_id获取信息类型 if msgType == "" { msgType = GetMessageTypeByUserid(config.GetAppIDStr(), message.Params.UserID) } + //顺序,私聊优先从UserID推断类型会更准确 + if msgType == "" { + msgType = GetMessageTypeByGroupid(config.GetAppIDStr(), message.Params.GroupID) + } //新增 内存获取不到从数据库获取 if msgType == "" { msgType = GetMessageTypeByUseridV2(message.Params.UserID) @@ -68,7 +68,7 @@ func HandleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 open } switch msgType { - case "group_private","group": + case "group_private", "group": //私聊信息 var UserID string if config.GetIdmapPro() { @@ -266,7 +266,7 @@ func HandleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 open retmsg, _ = SendResponse(client, err, &message) } } - case "guild_private","guild": + case "guild_private", "guild": //当收到发私信调用 并且来源是频道 retmsg, _ = HandleSendGuildChannelPrivateMsg(client, api, apiv2, message, nil, nil) default: From c8561ec14daf76e5daa679773968a9f78465a7d1 Mon Sep 17 00:00:00 2001 From: cosmo Date: Thu, 11 Jan 2024 19:41:19 +0800 Subject: [PATCH 4/5] beta124 --- handlers/send_msg.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/handlers/send_msg.go b/handlers/send_msg.go index fa6562f8..843e744e 100644 --- a/handlers/send_msg.go +++ b/handlers/send_msg.go @@ -46,11 +46,11 @@ func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope var err error if message.Params.GroupID != "" { - idInt64, err = ConvertToInt64(message.Params.GroupID) - idInt642, err = ConvertToInt64(message.Params.UserID) + idInt64, _ = ConvertToInt64(message.Params.GroupID) + idInt642, _ = ConvertToInt64(message.Params.UserID) } else if message.Params.UserID != "" { - idInt64, err = ConvertToInt64(message.Params.UserID) - idInt642, err = ConvertToInt64(message.Params.GroupID) + idInt64, _ = ConvertToInt64(message.Params.UserID) + idInt642, _ = ConvertToInt64(message.Params.GroupID) } //设置递归 对直接向gsk发送action时有效果 From 22865d4b69358b20317304ca685d340b81f03896 Mon Sep 17 00:00:00 2001 From: cosmo Date: Thu, 11 Jan 2024 20:07:19 +0800 Subject: [PATCH 5/5] beta124 --- handlers/send_msg.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/handlers/send_msg.go b/handlers/send_msg.go index 843e744e..00960811 100644 --- a/handlers/send_msg.go +++ b/handlers/send_msg.go @@ -29,18 +29,22 @@ func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.Ope if msgType == "" { msgType = GetMessageTypeByGroupid(config.GetAppIDStr(), message.Params.GroupID) } + mylog.Printf("测试1:%v", msgType) //如果获取不到 就用user_id获取信息类型 if msgType == "" { msgType = GetMessageTypeByUserid(config.GetAppIDStr(), message.Params.UserID) } + mylog.Printf("测试2:%v", msgType) //顺序有讲究 if msgType == "" { msgType = GetMessageTypeByGroupidV2(message.Params.GroupID) } + mylog.Printf("测试3:%v", msgType) //新增 内存获取不到从数据库获取 if msgType == "" { msgType = GetMessageTypeByUseridV2(message.Params.UserID) } + mylog.Printf("测试4:%v", msgType) var idInt64, idInt642 int64 var err error