From 49d2f29ec1de3946ffe6434c75000b431d75a5d1 Mon Sep 17 00:00:00 2001 From: EvolvedGhost <92856393+EvolvedGhost@users.noreply.github.com> Date: Tue, 23 Apr 2024 23:31:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DLagrange=E4=B8=AD=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E5=90=88=E5=B9=B6=E8=BD=AC=E5=8F=91=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E4=B8=AD=E5=9B=BE=E7=89=87=E7=9A=84=E5=8F=91=E9=80=81=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix group forward msg in Lagrange * Fix annotation --- .../cn/evolvefield/onebot/client/core/Bot.kt | 17 +++++++++++++++++ .../overflow/internal/message/OnebotMessages.kt | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt b/onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt index 87434f6f..9b74a1ba 100644 --- a/onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt +++ b/onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt @@ -920,6 +920,23 @@ class Bot( val result = actionHandler.action(this, action, params) return result.withToken() } + /** + * 发送合并转发 (群) + * + * @param groupId 群号 + * @param msg 自定义转发消息 + * [参考文档](https://lagrangedev.github.io/Lagrange.Doc/Lagrange.OneBot/API/Extend/#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-%E7%BE%A4%E8%81%8A) + * @return [ActionData] resId + */ + suspend fun sendGroupForwardMsgLagrange(groupId: Long, msg: List>): ActionData { + val action = ActionPathEnum.SEND_GROUP_FORWARD_MSG + val params = JsonObject() + params.addProperty("group_id", groupId) + params.add("messages", msg.toJsonArray()) + + val result = actionHandler.action(this, action, params) + return result.withToken() + } /** * 获取群根目录文件列表 * diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/message/OnebotMessages.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/message/OnebotMessages.kt index f79045f7..9845e802 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/message/OnebotMessages.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/message/OnebotMessages.kt @@ -176,7 +176,10 @@ internal object OnebotMessages { val nodes = serializeForwardNodes(bot, forward.nodeList) when (bot.appName.lowercase()) { "lagrange.onebot" -> { - val resId = bot.impl.sendForwardMsgLagrange(nodes).data + val resId = when (contact) { + is Group -> bot.impl.sendGroupForwardMsgLagrange(contact.id, nodes).data + else -> bot.impl.sendForwardMsgLagrange(nodes).data + } if (resId != null) { val forwardMsg = Json.encodeToString(buildJsonArray { addJsonObject {