mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
fix buttons
This commit is contained in:
parent
352aa5f737
commit
12d594697d
@ -10,8 +10,8 @@ import kotlinx.serialization.protobuf.ProtoNumber
|
||||
data class RichText(
|
||||
@ProtoNumber(1) val attr: Attr? = null,
|
||||
@ProtoNumber(2) var elements: List<Elem>? = null,
|
||||
@ProtoNumber(3) val not_online_file: NotOnlineFile? = null,
|
||||
@ProtoNumber(4) val ptt: Ptt? = null,
|
||||
@ProtoNumber(3) var not_online_file: NotOnlineFile? = null,
|
||||
@ProtoNumber(4) var ptt: Ptt? = null,
|
||||
@ProtoNumber(5) val tmp_ptt: TmpPtt? = null,
|
||||
@ProtoNumber(6) val trans_211_tmp_msg: Trans211TmpMsg? = null,
|
||||
)
|
||||
|
@ -206,53 +206,6 @@ internal object ElemConverter {
|
||||
throw UnknownError("no segment")
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * 语音消息转换消息段
|
||||
// */
|
||||
// private suspend fun convertVoiceElem(
|
||||
// chatType: Int,
|
||||
// peerId: String,
|
||||
// subPeer: String,
|
||||
// element: Elem
|
||||
// ): MessageSegment {
|
||||
// val record = element.pttElement
|
||||
//
|
||||
// val md5 = if (record.fileName.startsWith("silk"))
|
||||
// record.fileName.substring(5)
|
||||
// else record.md5HexStr
|
||||
//
|
||||
// return MessageSegment(
|
||||
// type = "record",
|
||||
// data = mapOf(
|
||||
// "file" to md5,
|
||||
// "url" to when (chatType) {
|
||||
// MsgConstant.KCHATTYPEGROUP -> RichProtoSvc.getGroupPttDownUrl(
|
||||
// "0",
|
||||
// record.md5HexStr,
|
||||
// record.fileUuid
|
||||
// )
|
||||
//
|
||||
// MsgConstant.KCHATTYPEC2C -> RichProtoSvc.getC2CPttDownUrl("0", record.fileUuid)
|
||||
// MsgConstant.KCHATTYPEGUILD -> RichProtoSvc.getGroupPttDownUrl(
|
||||
// "0",
|
||||
// record.md5HexStr,
|
||||
// record.fileUuid
|
||||
// )
|
||||
//
|
||||
// else -> throw UnsupportedOperationException("Not supported chat type: $chatType")
|
||||
// }
|
||||
// ).also {
|
||||
// if (record.voiceChangeType != MsgConstant.KPTTVOICECHANGETYPENONE) {
|
||||
// it["magic"] = "1"
|
||||
// }
|
||||
// if ((it["url"] as String).isBlank()) {
|
||||
// it.remove("url")
|
||||
// }
|
||||
// }
|
||||
// )
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 视频消息转换消息段
|
||||
// */
|
||||
@ -354,7 +307,6 @@ internal object ElemConverter {
|
||||
): MessageSegment {
|
||||
val data = element.lightApp!!.data!!
|
||||
val jsonStr = String(if (data[0].toInt() == 1) DeflateTools.uncompress(data.slice(1)) else data.slice(1))
|
||||
LogCenter.log(jsonStr, Level.DEBUG)
|
||||
val json = jsonStr.asJsonObject
|
||||
return when (json["app"].asString) {
|
||||
"com.tencent.multimsg" -> {
|
||||
|
@ -20,6 +20,7 @@ import moe.fuqiuluo.shamrock.utils.DeflateTools
|
||||
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||
import protobuf.auto.toByteArray
|
||||
import protobuf.message.Elem
|
||||
import protobuf.message.Ptt
|
||||
import protobuf.message.RichText
|
||||
import protobuf.message.element.*
|
||||
import protobuf.message.element.commelem.*
|
||||
@ -40,10 +41,9 @@ internal class ElemMaker {
|
||||
"face" to ElemMaker::createFaceElem,
|
||||
"pic" to ElemMaker::createImageElem,
|
||||
"image" to ElemMaker::createImageElem,
|
||||
// "voice" to ElemMaker::createRecordElem,
|
||||
// "record" to ElemMaker::createRecordElem,
|
||||
// "video" to ElemMaker::createVideoElem,
|
||||
"reply" to ElemMaker::createReplyElem,
|
||||
"forward" to ElemMaker::createForwardStruct,
|
||||
"weather" to ElemMaker::createWeatherElem,
|
||||
"json" to ElemMaker::createJsonElem,
|
||||
"poke" to ElemMaker::createPokeElem,
|
||||
"dice" to ElemMaker::createNewDiceElem,
|
||||
@ -55,12 +55,12 @@ internal class ElemMaker {
|
||||
// "contact" to ElemMaker::createContactElem,
|
||||
// "location" to ElemMaker::createLocationElem,
|
||||
// "music" to ElemMaker::createMusicElem,
|
||||
"reply" to ElemMaker::createReplyElem,
|
||||
// "touch" to ElemMaker::createTouchElem,
|
||||
"weather" to ElemMaker::createWeatherElem,
|
||||
//"forward" to MessageMaker::createForwardElem,
|
||||
//"multi_msg" to MessageMaker::createLongMsgStruct,
|
||||
//"bubble_face" to ElemMaker::createBubbleFaceElem,
|
||||
// "multi_msg" to MessageMaker::createLongMsgStruct,
|
||||
// "bubble_face" to ElemMaker::createBubbleFaceElem,
|
||||
"voice" to ElemMaker::createRecordElem,
|
||||
"record" to ElemMaker::createRecordElem,
|
||||
// "video" to ElemMaker::createVideoElem,
|
||||
)
|
||||
|
||||
operator fun get(type: String): IElemMaker? = makerArray[type]
|
||||
@ -627,8 +627,8 @@ internal class ElemMaker {
|
||||
serviceType = 46,
|
||||
elem = ButtonExtra(
|
||||
field1 = Object1(
|
||||
rows = data["buttons"].asJsonArray.map { row ->
|
||||
Row(buttons = row.asJsonArray.map {
|
||||
rows = data["rows"].asJsonArray.map { row ->
|
||||
Row(buttons = row.asJsonObject["buttons"].asJsonArray.map {
|
||||
val button = it.asJsonObject
|
||||
val renderData = button["render_data"].asJsonObject
|
||||
val action = button["action"].asJsonObject
|
||||
@ -665,6 +665,19 @@ internal class ElemMaker {
|
||||
desc += "[Button消息]"
|
||||
}
|
||||
|
||||
private suspend fun createRecordElem(
|
||||
chatType: Int,
|
||||
msgId: Long,
|
||||
peerId: String,
|
||||
data: JsonObject
|
||||
) {
|
||||
data.checkAndThrow("content")
|
||||
rich.ptt= Ptt(
|
||||
|
||||
)
|
||||
desc += "[语音消息]"
|
||||
}
|
||||
|
||||
private fun JsonObject.checkAndThrow(vararg key: String) {
|
||||
key.forEach {
|
||||
if (!containsKey(it)) throw ParamsException(it)
|
||||
|
@ -221,7 +221,7 @@ internal object NtMsgElementMaker {
|
||||
}
|
||||
rows.add(InlineKeyboardRow(buttons))
|
||||
}
|
||||
elem.inlineKeyboardElement = InlineKeyboardElement(rows, keyboard["bot_appid"].asLong)
|
||||
elem.inlineKeyboardElement = InlineKeyboardElement(rows, keyboard["appid"].asLong)
|
||||
return Result.success(elem)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user