Skip to content

Commit

Permalink
refactor: ♻️ 对合并转发消息适配器的键进行强判断 (#102)
Browse files Browse the repository at this point in the history
fix: 🐛 修复linux上napcat无法下载合并转发消息的问题
  • Loading branch information
kagg886 authored Sep 29, 2024
1 parent b165a7a commit a969e9b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions onebot/src/main/kotlin/sdk/util/json/ForwardMsgAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ class ForwardMsgAdapter : JsonDeserializerKt<ForwardMsgResp> {
): ForwardMsgResp {
val nodes = mutableListOf<ForwardMsgResp.Node>()
val jsonObj = json.asJsonObject
var msgArray = jsonObj.get("messages")
if (msgArray == null) {
msgArray = jsonObj.get("message") // Lagrange
val msgArray = when {
jsonObj.has("messages") -> jsonObj.get("messages") //Lagrange
jsonObj.has("message") -> jsonObj.get("message") // go-cqhttp
jsonObj.has("content") -> jsonObj.get("content") //old nap-cat
else -> throw IllegalArgumentException("不受支持的合并转发消息格式!请携带日志前往对应实现反馈。")
}
for (element in msgArray.asJsonArray) {
val obj = element.asJsonObject.run {
Expand Down

0 comments on commit a969e9b

Please sign in to comment.