Shamrock: fix 群头衔推送

This commit is contained in:
Simplxs 2023-12-02 11:11:22 +08:00
parent bffb7caf04
commit b5a9884448
No known key found for this signature in database
GPG Key ID: E23537FF14DD6507
2 changed files with 19 additions and 11 deletions

View File

@ -319,23 +319,23 @@ internal sealed class MessageElemConverter: IMessageConvert {
element: MsgElement element: MsgElement
): MessageSegment { ): MessageSegment {
val tip = element.grayTipElement val tip = element.grayTipElement
when(val tipType = tip.subElementType) { when(tip.subElementType) {
MsgConstant.GRAYTIPELEMENTSUBTYPEJSON -> { MsgConstant.GRAYTIPELEMENTSUBTYPEJSON -> {
val notify = tip.jsonGrayTipElement val notify = tip.jsonGrayTipElement
when(notify.busiId) { when(notify.busiId) {
/* 新人入群 */ 17L, /* 新人入群 */ 17L, /* 群戳一戳 */1061L,
/* 群戳一戳 */1061L, /* 群撤回 */1014L -> {} /* 群撤回 */1014L, /* 群设精消息 */2401L -> {}
else -> LogCenter.log("不支持的灰条类型(JSON): $tipType", Level.WARN) else -> LogCenter.log("不支持的灰条类型(JSON): ${notify.busiId}", Level.WARN)
} }
} }
MsgConstant.GRAYTIPELEMENTSUBTYPEXMLMSG -> { MsgConstant.GRAYTIPELEMENTSUBTYPEXMLMSG -> {
val notify = tip.xmlElement val notify = tip.xmlElement
when(notify.busiId) { when(notify.busiId) {
/* 群戳一戳 */12L -> {} /* 群戳一戳 */1061L -> {}
else -> LogCenter.log("不支持的灰条类型(XML): $tipType", Level.WARN) else -> LogCenter.log("不支持的灰条类型(XML): ${notify.busiId}", Level.WARN)
} }
} }
else -> LogCenter.log("不支持的提示类型: $tip", Level.WARN) else -> LogCenter.log("不支持的提示类型: ${tip.subElementType}", Level.WARN)
} }
// 提示类消息这里提供的是一个xml不具备解析通用性 // 提示类消息这里提供的是一个xml不具备解析通用性
// 在这里不推送 // 在这里不推送

View File

@ -166,7 +166,7 @@ internal object PrimitiveListener {
val groupId = pb[1, 3, 2, 1, 13, 4].asLong val groupId = pb[1, 3, 2, 1, 13, 4].asLong
var oldCard = "" var oldCard = ""
val targetQQ = ContactHelper.getUinByUidAsync(targetId).toLong() val targetQQ = ContactHelper.getUinByUidAsync(targetId).toLong()
LogCenter.log("群组[$groupId]成员$targetId 群名片变动 -> $newCard") LogCenter.log("群组[$groupId]成员$targetQQ 群名片变动 -> $newCard")
// oldCard暂时获取不到 // oldCard暂时获取不到
// GroupSvc.getTroopMemberInfoByUin(groupId.toString(), targetQQ.toString()).onSuccess { // GroupSvc.getTroopMemberInfoByUin(groupId.toString(), targetQQ.toString()).onSuccess {
// oldCard = it.troopnick // oldCard = it.troopnick
@ -181,12 +181,20 @@ internal object PrimitiveListener {
} }
private suspend fun onGroupTitleChange(msgTime: Long, pb: ProtoMap) { private suspend fun onGroupTitleChange(msgTime: Long, pb: ProtoMap) {
val targetUin = pb[1, 3, 2, 5, 5].asLong val groupCode = pb[1, 1, 1].asULong
val groupId = pb[1, 3, 2, 4].asLong val readPacket = ByteReadPacket(pb[1, 3, 2].asByteArray)
val detail = if (readPacket.readBuf32Long() == groupCode) {
readPacket.discardExact(1)
ProtoUtils.decodeFromByteArray(readPacket.readBytes(readPacket.readShort().toInt()))
} else pb[1, 3, 2]
val targetUin = detail[5, 5].asLong
val groupId = detail[4].asLong
// 恭喜<{\"cmd\":5,\"data\":\"qq\",\"text}\":\"nickname\"}>获得群主授予的<{\"cmd\":1,\"data\":\"https://qun.qq.com/qqweb/m/qun/medal/detail.html?_wv=16777223&bid=2504&gc=gid&isnew=1&medal=302&uin=uin\",\"text\":\"title\",\"url\":\"https://qun.qq.com/qqweb/m/qun/medal/detail.html?_wv=16777223&bid=2504&gc=gid&isnew=1&medal=302&uin=uin\"}>头衔 // 恭喜<{\"cmd\":5,\"data\":\"qq\",\"text}\":\"nickname\"}>获得群主授予的<{\"cmd\":1,\"data\":\"https://qun.qq.com/qqweb/m/qun/medal/detail.html?_wv=16777223&bid=2504&gc=gid&isnew=1&medal=302&uin=uin\",\"text\":\"title\",\"url\":\"https://qun.qq.com/qqweb/m/qun/medal/detail.html?_wv=16777223&bid=2504&gc=gid&isnew=1&medal=302&uin=uin\"}>头衔
val titleChangeInfo = pb[1, 3, 2, 5, 2].asUtf8String val titleChangeInfo = detail[5, 2].asUtf8String
if (titleChangeInfo.indexOf("群主授予") == -1) { if (titleChangeInfo.indexOf("群主授予") == -1) {
return return
} }