Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
Shamrock: fix markdown parser
Browse files Browse the repository at this point in the history
  • Loading branch information
whitechi73 committed Feb 18, 2024
1 parent 4283651 commit 388c963
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ internal object MessageMaker {
val elem = MsgElement()
elem.elementType = MsgConstant.KELEMTYPEINLINEKEYBOARD
val rows = arrayListOf<InlineKeyboardRow>()
data["rows"].asJsonArray.forEach {

val keyboard = Json.parseToJsonElement(data["data"].asString).asJsonObject
keyboard["rows"].asJsonArray.forEach {
val row = it.asJsonObject
val buttons = arrayListOf<InlineKeyboardButton>()
row["buttons"].asJsonArray.forEach { button ->
Expand All @@ -163,7 +165,7 @@ internal object MessageMaker {
}
rows.add(InlineKeyboardRow(buttons))
}
elem.inlineKeyboardElement = InlineKeyboardElement(rows, data["bot_appid"].asLong)
elem.inlineKeyboardElement = InlineKeyboardElement(rows, keyboard["bot_appid"].asLong)
return Result.success(elem)
}

Expand Down Expand Up @@ -626,10 +628,10 @@ internal object MessageMaker {
}

private suspend fun createMarkdownElem(chatType: Int, msgId: Long, peerId: String, data: JsonObject): Result<MsgElement> {
data.checkAndThrow("text")
data.checkAndThrow("content")
val elem = MsgElement()
elem.elementType = MsgConstant.KELEMTYPEMARKDOWN
val markdown = MarkdownElement(data["text"].asString)
val markdown = MarkdownElement(data["content"].asString)
elem.markdownElement = markdown
return Result.success(elem)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ internal sealed class MessageElemConverter: IMessageConvert {
}
}
put("bot_appid", keyboard.botAppid)
}
}.toString()
)
)
}
Expand Down

0 comments on commit 388c963

Please sign in to comment.