Support more poke messages

This commit is contained in:
Him188 2020-04-28 14:59:57 +08:00
parent 3c98151f87
commit 128125eec7
3 changed files with 111 additions and 49 deletions

View File

@ -120,7 +120,9 @@ internal fun MessageChain.toRichTextElems(forGroup: Boolean, withGeneralFlags: B
businessType = it.type, businessType = it.type,
pbElem = HummerCommelem.MsgElemInfoServtype2( pbElem = HummerCommelem.MsgElemInfoServtype2(
pokeType = it.type, pokeType = it.type,
vaspokeId = it.id vaspokeId = it.id,
vaspokeMinver = "7.2.0",
vaspokeName = it.name
).toByteArray(HummerCommelem.MsgElemInfoServtype2.serializer()) ).toByteArray(HummerCommelem.MsgElemInfoServtype2.serializer())
) )
) )
@ -383,7 +385,13 @@ internal fun List<ImMsgBody.Elem>.joinToMessageChain(groupIdOrZero: Long, bot: B
when (element.commonElem.serviceType) { when (element.commonElem.serviceType) {
2 -> { 2 -> {
val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype2.serializer()) val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype2.serializer())
list.add(PokeMessage(proto.pokeType, proto.vaspokeId)) list.add(PokeMessage(
proto.vaspokeName.takeIf { it.isNotEmpty() }
?: PokeMessage.values.firstOrNull { it.id == proto.vaspokeId && it.type == proto.pokeType }?.name
.orEmpty(),
proto.pokeType,
proto.vaspokeId
))
} }
3 -> { 3 -> {
val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype3.serializer()) val proto = element.commonElem.pbElem.loadAs(HummerCommelem.MsgElemInfoServtype3.serializer())

View File

@ -101,11 +101,11 @@ internal class MsgElemInfoServtype19(
@Serializable @Serializable
internal class MsgElemInfoServtype2( internal class MsgElemInfoServtype2(
@ProtoId(1) @JvmField val pokeType: Int = 0, @ProtoId(1) @JvmField val pokeType: Int = 0,
@ProtoId(2) @JvmField val pokeSummary: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(2) @JvmField val pokeSummary: String = "",
@ProtoId(3) @JvmField val doubleHit: Int = 0, @ProtoId(3) @JvmField val doubleHit: Int = 0,
@ProtoId(4) @JvmField val vaspokeId: Int = 0, @ProtoId(4) @JvmField val vaspokeId: Int = 0,
@ProtoId(5) @JvmField val vaspokeName: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(5) @JvmField val vaspokeName: String = "",
@ProtoId(6) @JvmField val vaspokeMinver: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(6) @JvmField val vaspokeMinver: String = "",
@ProtoId(7) @JvmField val pokeStrength: Int = 0, @ProtoId(7) @JvmField val pokeStrength: Int = 0,
@ProtoId(8) @JvmField val msgType: Int = 0, @ProtoId(8) @JvmField val msgType: Int = 0,
@ProtoId(9) @JvmField val faceBubbleCount: Int = 0, @ProtoId(9) @JvmField val faceBubbleCount: Int = 0,
@ -124,11 +124,11 @@ internal class MsgElemInfoServtype21(
@ProtoId(3) @JvmField val confessorNick: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(3) @JvmField val confessorNick: ByteArray = EMPTY_BYTE_ARRAY,
@ProtoId(4) @JvmField val confessorSex: Int = 0, @ProtoId(4) @JvmField val confessorSex: Int = 0,
@ProtoId(5) @JvmField val sysmsgFlag: Int = 0, @ProtoId(5) @JvmField val sysmsgFlag: Int = 0,
@ProtoId(6) @JvmField val c2cConfessCtx: HummerCommelem.MsgElemInfoServtype21.C2CConfessContext? = null, @ProtoId(6) @JvmField val c2cConfessCtx: C2CConfessContext? = null,
@ProtoId(7) @JvmField val topic: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(7) @JvmField val topic: ByteArray = EMPTY_BYTE_ARRAY,
@ProtoId(8) @JvmField val confessTime: Long = 0L, @ProtoId(8) @JvmField val confessTime: Long = 0L,
@ProtoId(9) @JvmField val groupConfessMsg: HummerCommelem.MsgElemInfoServtype21.GroupConfessMsg? = null, @ProtoId(9) @JvmField val groupConfessMsg: GroupConfessMsg? = null,
@ProtoId(10) @JvmField val groupConfessCtx: HummerCommelem.MsgElemInfoServtype21.GroupConfessContext? = null @ProtoId(10) @JvmField val groupConfessCtx: GroupConfessContext? = null
) : ProtoBuf { ) : ProtoBuf {
@Serializable @Serializable
internal class C2CConfessContext( internal class C2CConfessContext(
@ -175,7 +175,7 @@ internal class GroupConfessMsg(
@ProtoId(2) @JvmField val confessorUin: Long = 0L, @ProtoId(2) @JvmField val confessorUin: Long = 0L,
@ProtoId(3) @JvmField val confessorSex: Int = 0, @ProtoId(3) @JvmField val confessorSex: Int = 0,
@ProtoId(4) @JvmField val sysmsgFlag: Int = 0, @ProtoId(4) @JvmField val sysmsgFlag: Int = 0,
@ProtoId(5) @JvmField val confessItems: List<HummerCommelem.MsgElemInfoServtype21.GroupConfessItem>? = null, @ProtoId(5) @JvmField val confessItems: List<GroupConfessItem>? = null,
@ProtoId(6) @JvmField val totalTopicCount: Int = 0 @ProtoId(6) @JvmField val totalTopicCount: Int = 0
) : ProtoBuf ) : ProtoBuf
} }
@ -184,15 +184,15 @@ internal class GroupConfessMsg(
internal class MsgElemInfoServtype23( internal class MsgElemInfoServtype23(
@ProtoId(1) @JvmField val faceType: Int = 0, @ProtoId(1) @JvmField val faceType: Int = 0,
@ProtoId(2) @JvmField val faceBubbleCount: Int = 0, @ProtoId(2) @JvmField val faceBubbleCount: Int = 0,
@ProtoId(3) @JvmField val faceSummary: ByteArray = EMPTY_BYTE_ARRAY, @ProtoId(3) @JvmField val faceSummary: String = "",
@ProtoId(4) @JvmField val flag: Int = 0, @ProtoId(4) @JvmField val flag: Int = 0,
@ProtoId(5) @JvmField val others: ByteArray = EMPTY_BYTE_ARRAY @ProtoId(5) @JvmField val others: ByteArray = EMPTY_BYTE_ARRAY
) : ProtoBuf ) : ProtoBuf
@Serializable @Serializable
internal class MsgElemInfoServtype24( internal class MsgElemInfoServtype24(
@ProtoId(1) @JvmField val limitChatEnter: HummerCommelem.MsgElemInfoServtype24.LimitChatEnter? = null, @ProtoId(1) @JvmField val limitChatEnter: LimitChatEnter? = null,
@ProtoId(2) @JvmField val limitChatExit: HummerCommelem.MsgElemInfoServtype24.LimitChatExit? = null @ProtoId(2) @JvmField val limitChatExit: LimitChatExit? = null
) : ProtoBuf { ) : ProtoBuf {
@Serializable @Serializable
internal class LimitChatEnter( internal class LimitChatEnter(
@ -237,7 +237,7 @@ internal class MsgElemInfoServtype31(
@Serializable @Serializable
internal class MsgElemInfoServtype4( internal class MsgElemInfoServtype4(
@ProtoId(1) @JvmField val imsgType: Int = 0, @ProtoId(1) @JvmField val imsgType: Int = 0,
@ProtoId(4) @JvmField val stStoryAioObjMsg: HummerCommelem.StoryAioObjMsg? = null @ProtoId(4) @JvmField val stStoryAioObjMsg: StoryAioObjMsg? = null
) : ProtoBuf ) : ProtoBuf
@Serializable @Serializable

View File

@ -46,9 +46,12 @@ sealed class HummerMessage : MessageContent {
@SinceMirai("0.31.0") @SinceMirai("0.31.0")
@OptIn(MiraiInternalAPI::class) @OptIn(MiraiInternalAPI::class)
data class PokeMessage internal constructor( data class PokeMessage internal constructor(
@MiraiExperimentalAPI("may change in future") /**
* mirai, 显示的名称
*/
val name: String,
val type: Int, val type: Int,
@MiraiExperimentalAPI("may change in future")
val id: Int val id: Int
) : HummerMessage() { ) : HummerMessage() {
@Suppress("DEPRECATION_ERROR", "DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") @Suppress("DEPRECATION_ERROR", "DEPRECATION", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@ -58,27 +61,78 @@ data class PokeMessage internal constructor(
/** 戳一戳 */ /** 戳一戳 */
@JvmField @JvmField
val Poke = PokeMessage(1, -1) val Poke = PokeMessage("戳一戳", 1, -1)
/** 比心 */ /** 比心 */
@JvmField @JvmField
val ShowLove = PokeMessage(2, -1) val ShowLove = PokeMessage("比心", 2, -1)
/** 点赞 */ /** 点赞 */
@JvmField @JvmField
val Like = PokeMessage(3, -1) val Like = PokeMessage("点赞", 3, -1)
/** 心碎 */ /** 心碎 */
@JvmField @JvmField
val Heartbroken = PokeMessage(4, -1) val Heartbroken = PokeMessage("心碎", 4, -1)
/** 666 */ /** 666 */
@JvmField @JvmField
val SixSixSix = PokeMessage(5, -1) val SixSixSix = PokeMessage("666", 5, -1)
/** 放大招 */ /** 放大招 */
@JvmField @JvmField
val FangDaZhao = PokeMessage(6, -1) val FangDaZhao = PokeMessage("放大招", 6, -1)
/** 宝贝球 (SVIP) */
@JvmField
val BaoBeiQiu = PokeMessage("宝贝球", 126, 2011)
/** 玫瑰花 (SVIP) */
@JvmField
val Rose = PokeMessage("玫瑰花", 126, 2007)
/** 召唤术 (SVIP) */
@JvmField
val ZhaoHuanShu = PokeMessage("召唤术", 126, 2006)
/** 让你皮 (SVIP) */
@JvmField
val RangNiPi = PokeMessage("让你皮", 126, 2009)
/** 结印 (SVIP) */
@JvmField
val JieYin = PokeMessage("结印", 126, 2005)
/** 手雷 (SVIP) */
@JvmField
val ShouLei = PokeMessage("手雷", 126, 2004)
/** 勾引 */
@JvmField
val GouYin = PokeMessage("勾引", 126, 2003)
/** 抓一下 (SVIP) */
@JvmField
val ZhuaYiXia = PokeMessage("抓一下", 126, 2001)
/** 碎屏 (SVIP) */
@JvmField
val SuiPing = PokeMessage("碎屏", 126, 2002)
/** 敲门 (SVIP) */
@JvmField
val QiaoMen = PokeMessage("敲门", 126, 2002)
/**
* 所有类型数组
*/
@JvmStatic
val values: Array<PokeMessage> = arrayOf(
Poke, ShowLove, Like, Heartbroken, SixSixSix,
FangDaZhao, BaoBeiQiu, Rose, ZhaoHuanShu, RangNiPi,
JieYin, ShouLei, GouYin, ZhuaYiXia, SuiPing
)
} }
@OptIn(MiraiExperimentalAPI::class) @OptIn(MiraiExperimentalAPI::class)