Skip to content

Commit

Permalink
修复Lagrange中群聊合并转发信息中图片的发送 (#39)
Browse files Browse the repository at this point in the history
* Fix group forward msg in Lagrange

* Fix annotation
  • Loading branch information
EvolvedGhost committed Apr 23, 2024
1 parent 4029f15 commit 49d2f29
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions onebot/src/main/kotlin/cn/evolvefield/onebot/client/core/Bot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Map<String, Any>>): ActionData<String?> {
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()
}
/**
* 获取群根目录文件列表
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 49d2f29

Please sign in to comment.