diff --git a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/InlineKeyboardButton.java b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/InlineKeyboardButton.java index a26a5cba..9fe2222c 100644 --- a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/InlineKeyboardButton.java +++ b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/InlineKeyboardButton.java @@ -79,6 +79,10 @@ public String toString() { return "InlineKeyboardButton{id=" + this.id + ",label=" + this.label + ",visitedLabel=" + this.visitedLabel + ",style=" + this.style + ",type=" + this.type + ",clickLimit=" + this.clickLimit + ",unsupportTips=" + this.unsupportTips + ",data=" + this.data + ",atBotShowChannelList=" + this.atBotShowChannelList + ",permissionType=" + this.permissionType + ",specifyRoleIds=" + this.specifyRoleIds + ",specifyTinyids=" + this.specifyTinyids + ",}"; } + public InlineKeyboardButton(String str, String str2, String str3, int i, int i2, int i3, String str4, String str5, boolean z, int i4, ArrayList arrayList, ArrayList arrayList2, boolean z2, int i5, boolean z3, ArrayList arrayList3) { + + } + public InlineKeyboardButton(String str, String str2, String str3, int i2, int i3, int i4, String str4, String str5, boolean z, int i5, ArrayList arrayList, ArrayList arrayList2) { this.id = ""; this.label = ""; diff --git a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/SubscribeMsgTemplateID.java b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/SubscribeMsgTemplateID.java new file mode 100644 index 00000000..d7183345 --- /dev/null +++ b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/SubscribeMsgTemplateID.java @@ -0,0 +1,4 @@ +package com.tencent.qqnt.kernel.nativeinterface; + +public class SubscribeMsgTemplateID { +} diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/MessageMaker.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/MessageMaker.kt index 35cb5c18..d6aabcca 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/MessageMaker.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/MessageMaker.kt @@ -11,6 +11,9 @@ import com.tencent.qqnt.aio.adapter.api.IAIOPttApi import com.tencent.qqnt.kernel.nativeinterface.ArkElement import com.tencent.qqnt.kernel.nativeinterface.FaceBubbleElement import com.tencent.qqnt.kernel.nativeinterface.FaceElement +import com.tencent.qqnt.kernel.nativeinterface.InlineKeyboardButton +import com.tencent.qqnt.kernel.nativeinterface.InlineKeyboardElement +import com.tencent.qqnt.kernel.nativeinterface.InlineKeyboardRow import com.tencent.qqnt.kernel.nativeinterface.MarkdownElement import com.tencent.qqnt.kernel.nativeinterface.MarketFaceElement import com.tencent.qqnt.kernel.nativeinterface.MarketFaceSupportSize @@ -53,9 +56,11 @@ import moe.fuqiuluo.shamrock.helper.LogicException import moe.fuqiuluo.shamrock.helper.MessageHelper import moe.fuqiuluo.shamrock.helper.MusicHelper import moe.fuqiuluo.shamrock.helper.ParamsException +import moe.fuqiuluo.shamrock.tools.asBoolean import moe.fuqiuluo.shamrock.tools.asBooleanOrNull import moe.fuqiuluo.shamrock.tools.asInt import moe.fuqiuluo.shamrock.tools.asIntOrNull +import moe.fuqiuluo.shamrock.tools.asJsonArray import moe.fuqiuluo.shamrock.tools.asJsonObject import moe.fuqiuluo.shamrock.tools.asLong import moe.fuqiuluo.shamrock.tools.asString @@ -108,8 +113,60 @@ internal object MessageMaker { //"node" to MessageMaker::createNodeElem, //"multi_msg" to MessageMaker::createLongMsgStruct, "bubble_face" to MessageMaker::createBubbleFaceElem, + "inline_keyboard" to MessageMaker::createInlineKeywordElem ) + private suspend fun createInlineKeywordElem(chatType: Int, msgId: Long, peerId: String, data: JsonObject): Result { + fun tryNewKeyboardButton(btn: JsonObject): InlineKeyboardButton { + return runCatching { + InlineKeyboardButton( + btn["id"].asString, + btn["label"].asString, + btn["visited_label"].asString, + btn["style"].asInt, + btn["type"].asInt, + btn["click_limit"].asInt, + btn["unsupport_tips"].asString, + btn["data"].asString, + btn["at_bot_show_channel_list"].asBoolean, + btn["permission_type"].asInt, + ArrayList(btn["specify_role_ids"].asJsonArray.map { it.asString }), + ArrayList(btn["specify_tinyids"].asJsonArray.map { it.asString }), + false, 0, false, arrayListOf() + ) + }.getOrElse { + InlineKeyboardButton( + btn["id"].asString, + btn["label"].asString, + btn["visited_label"].asString, + btn["style"].asInt, + btn["type"].asInt, + btn["click_limit"].asInt, + btn["unsupport_tips"].asString, + btn["data"].asString, + btn["at_bot_show_channel_list"].asBoolean, + btn["permission_type"].asInt, + ArrayList(btn["specify_role_ids"].asJsonArray.map { it.asString }), + ArrayList(btn["specify_tinyids"].asJsonArray.map { it.asString }), + ) + } + } + val elem = MsgElement() + elem.elementType = MsgConstant.KELEMTYPEINLINEKEYBOARD + val rows = arrayListOf() + data["rows"].asJsonArray.forEach { + val row = it.asJsonObject + val buttons = arrayListOf() + row["buttons"].asJsonArray.forEach { button -> + val btn = button.asJsonObject + buttons.add(tryNewKeyboardButton(btn)) + } + rows.add(InlineKeyboardRow(buttons)) + } + elem.inlineKeyboardElement = InlineKeyboardElement(rows, data["bot_appid"].asLong) + return Result.success(elem) + } + private suspend fun createBubbleFaceElem(chatType: Int, msgId: Long, peerId: String, data: JsonObject): Result { data.checkAndThrow("id", "count") val faceId = data["id"].asInt diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageConvert.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageConvert.kt index e02dac59..3c15ebe8 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageConvert.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageConvert.kt @@ -58,6 +58,7 @@ internal object MessageConvert { //MsgConstant.KELEMTYPEMULTIFORWARD to XmlMultiMsgConverter, //MsgConstant.KELEMTYPESTRUCTLONGMSG to XmlLongMsgConverter, MsgConstant.KELEMTYPEFACEBUBBLE to BubbleFaceConverter, + MsgConstant.KELEMTYPEINLINEKEYBOARD to InlineKeyboardConverter, ) } diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageElemConverter.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageElemConverter.kt index 0858964b..c0daea04 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageElemConverter.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/msg/convert/MessageElemConverter.kt @@ -3,6 +3,10 @@ package moe.fuqiuluo.qqinterface.servlet.msg.convert import com.tencent.mobileqq.qmmkv.QMMKV import com.tencent.qqnt.kernel.nativeinterface.MsgConstant import com.tencent.qqnt.kernel.nativeinterface.MsgElement +import kotlinx.serialization.json.add +import kotlinx.serialization.json.buildJsonObject +import kotlinx.serialization.json.put +import kotlinx.serialization.json.putJsonArray import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc import moe.fuqiuluo.shamrock.helper.ContactHelper import moe.fuqiuluo.shamrock.helper.Level @@ -495,6 +499,53 @@ internal sealed class MessageElemConverter: IMessageConvert { } } + data object InlineKeyboardConverter: MessageElemConverter() { + override suspend fun convert( + chatType: Int, + peerId: String, + subPeer: String, + element: MsgElement + ): MessageSegment { + val keyboard = element.inlineKeyboardElement + return MessageSegment( + type = "inline_keyboard", + data = mapOf( + "data" to buildJsonObject { + putJsonArray("rows") { + keyboard.rows.forEach { row -> + add(buildJsonObject row@{ + putJsonArray("buttons") { + row.buttons.forEach { button -> + add(buildJsonObject { + put("id", button.id ?: "") + put("label", button.label ?: "") + put("visited_label", button.visitedLabel ?: "") + put("style", button.style) + put("type", button.type) + put("click_limit", button.clickLimit) + put("unsupport_tips", button.unsupportTips ?: "") + put("data", button.data) + put("at_bot_show_channel_list", button.atBotShowChannelList) + put("permission_type", button.permissionType) + putJsonArray("specify_role_ids") { + button.specifyRoleIds?.forEach { add(it) } + } + putJsonArray("specify_tinyids") { + button.specifyTinyids?.forEach { add(it) } + } + }) + } + } + }) + } + } + put("bot_appid", keyboard.botAppid) + } + ) + ) + } + } + protected fun unknownChatType(chatType: Int) { throw UnsupportedOperationException("Not supported chat type: $chatType") }