Merge remote-tracking branch 'origin/master'

This commit is contained in:
WhiteChi 2023-11-29 10:11:35 +08:00
commit 64c800c945
4 changed files with 65 additions and 19 deletions

View File

@ -90,18 +90,19 @@ internal object SendForwardMessage : IActionHandler() {
if (it.asJsonObject["type"].asStringOrNull != "node") return@map ForwardMsgNode.EmptyNode // 过滤非node类型消息段 if (it.asJsonObject["type"].asStringOrNull != "node") return@map ForwardMsgNode.EmptyNode // 过滤非node类型消息段
it.asJsonObject["data"].asJsonObject.let { data -> it.asJsonObject["data"].asJsonObject.let { data ->
if (data.containsKey("content")) { if (data.containsKey("content")) {
data["content"].asJsonArray.forEach { msg -> if (data["content"] is JsonArray) {
if (msg.asJsonObject["type"].asStringOrNull == "node") { data["content"].asJsonArray.forEach { msg ->
LogCenter.log("合并转发消息不支持嵌套", Level.ERROR) if (msg.asJsonObject["type"].asStringOrNull == "node") {
return@map ForwardMsgNode.EmptyNode LogCenter.log("合并转发消息不支持嵌套", Level.ERROR)
return@map ForwardMsgNode.EmptyNode
}
} }
} }
ForwardMsgNode.MessageNode( ForwardMsgNode.MessageNode(
name = data["name"].asStringOrNull ?: "", name = data["name"].asStringOrNull ?: "",
content = data["content"] content = data["content"]
) )
} } else ForwardMsgNode.MessageIdNode(data["id"].asInt)
else ForwardMsgNode.MessageIdNode(data["id"].asInt)
} }
}.map { }.map {
if (it is ForwardMsgNode.MessageIdNode) { if (it is ForwardMsgNode.MessageIdNode) {
@ -131,7 +132,9 @@ internal object SendForwardMessage : IActionHandler() {
suspendCoroutine { suspendCoroutine {
GlobalScope.launch { GlobalScope.launch {
var msgId: Long = 0 var msgId: Long = 0
msgId = MessageHelper.sendMessageWithMsgId(MsgConstant.KCHATTYPEC2C, selfUin, node.content!!.let { msg -> msgId = MessageHelper.sendMessageWithMsgId(MsgConstant.KCHATTYPEC2C,
selfUin,
node.content!!.let { msg ->
if (msg is JsonArray) msg else MessageHelper.decodeCQCode(msg.asString) if (msg is JsonArray) msg else MessageHelper.decodeCQCode(msg.asString)
}, },
{ code, why -> { code, why ->
@ -154,9 +157,10 @@ internal object SendForwardMessage : IActionHandler() {
return ok( return ok(
ForwardMessageResult( ForwardMessageResult(
msgId = uniseq.first, msgId = uniseq.first,
forwardId = "" forwardId = ""
), echo = echo) ), echo = echo
)
}.onFailure { }.onFailure {
return error("error: $it", echo) return error("error: $it", echo)
} }

View File

@ -19,6 +19,7 @@ import moe.fuqiuluo.shamrock.remote.service.data.push.MessageTempSource
import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeEvent import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeEvent
import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeSubType import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeSubType
import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeType import moe.fuqiuluo.shamrock.remote.service.data.push.NoticeType
import moe.fuqiuluo.shamrock.remote.service.data.push.PokeDetail
import moe.fuqiuluo.shamrock.remote.service.data.push.PrivateFileMsg import moe.fuqiuluo.shamrock.remote.service.data.push.PrivateFileMsg
import moe.fuqiuluo.shamrock.remote.service.data.push.RequestEvent import moe.fuqiuluo.shamrock.remote.service.data.push.RequestEvent
import moe.fuqiuluo.shamrock.remote.service.data.push.RequestSubType import moe.fuqiuluo.shamrock.remote.service.data.push.RequestSubType
@ -221,7 +222,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
* 群聊通知 通知器 * 群聊通知 通知器
*/ */
object GroupNoticeTransmitter { object GroupNoticeTransmitter {
suspend fun transGroupPoke(time: Long, operation: Long, target: Long, groupCode: Long): Boolean { suspend fun transGroupPoke(time: Long, operation: Long, target: Long, action: String?, suffix: String?, actionImg: String?, groupCode: Long): Boolean {
pushNotice(NoticeEvent( pushNotice(NoticeEvent(
time = time, time = time,
selfId = app.longAccountUin, selfId = app.longAccountUin,
@ -231,7 +232,12 @@ internal object GlobalEventTransmitter: BaseSvc() {
operatorId = operation, operatorId = operation,
userId = operation, userId = operation,
groupId = groupCode, groupId = groupCode,
target = target target = target,
pokeDetail = PokeDetail(
action = action,
suffix = suffix,
actionImg = actionImg
)
)) ))
return true return true
} }
@ -292,7 +298,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
type = NoticeType.GroupBan, type = NoticeType.GroupBan,
subType = if (duration == 0) NoticeSubType.LiftBan else NoticeSubType.Ban, subType = if (duration == 0) NoticeSubType.LiftBan else NoticeSubType.Ban,
operatorId = operation, operatorId = operation,
userId = operation, userId = target,
senderId = operation, senderId = operation,
target = target, target = target,
groupId = groupCode, groupId = groupCode,
@ -389,7 +395,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
* 私聊通知 通知器 * 私聊通知 通知器
*/ */
object PrivateNoticeTransmitter { object PrivateNoticeTransmitter {
suspend fun transPrivatePoke(msgTime: Long, operation: Long, target: Long): Boolean { suspend fun transPrivatePoke(msgTime: Long, operation: Long, target: Long, action: String?, suffix: String?, actionImg: String?): Boolean {
pushNotice(NoticeEvent( pushNotice(NoticeEvent(
time = msgTime, time = msgTime,
selfId = app.longAccountUin, selfId = app.longAccountUin,
@ -399,7 +405,12 @@ internal object GlobalEventTransmitter: BaseSvc() {
operatorId = operation, operatorId = operation,
userId = operation, userId = operation,
senderId = operation, senderId = operation,
target = target target = target,
pokeDetail = PokeDetail(
actionImg = actionImg,
action = action,
suffix = suffix
)
)) ))
return true return true
} }

View File

@ -76,9 +76,17 @@ internal data class NoticeEvent(
@SerialName("file") val file: GroupFileMsg? = null, @SerialName("file") val file: GroupFileMsg? = null,
@SerialName("private_file") val privateFile: PrivateFileMsg? = null, @SerialName("private_file") val privateFile: PrivateFileMsg? = null,
@SerialName("flag") val flag: String? = null, @SerialName("flag") val flag: String? = null,
// 群名片
@SerialName("card_new") val cardNew: String? = null, @SerialName("card_new") val cardNew: String? = null,
@SerialName("card_old") val cardOld: String? = null, @SerialName("card_old") val cardOld: String? = null,
// 群头衔
@SerialName("title") val title: String? = null, @SerialName("title") val title: String? = null,
// 戳一戳
@SerialName("poke_detail") val pokeDetail: PokeDetail? = null,
) )
/** /**
@ -115,4 +123,12 @@ internal data class PrivateFileMsg(
@SerialName("sub_id") val subId: String, @SerialName("sub_id") val subId: String,
val url: String, val url: String,
val expire: Long, val expire: Long,
)
@Serializable
internal data class PokeDetail (
val action: String? = "戳了戳",
val suffix: String? = "",
@SerialName("action_img_url")
val actionImg: String? = "https://tianquan.gtimg.cn/nudgeaction/item/0/expression.jpg",
) )

View File

@ -96,6 +96,9 @@ internal object PrimitiveListener {
lateinit var target: String lateinit var target: String
lateinit var operation: String lateinit var operation: String
var suffix: String? = null
var actionImg: String? = null
var action: String? = null
detail[7] detail[7]
.asList .asList
.value .value
@ -104,12 +107,17 @@ internal object PrimitiveListener {
when(it[1].asUtf8String) { when(it[1].asUtf8String) {
"uin_str1" -> operation = value "uin_str1" -> operation = value
"uin_str2" -> target = value "uin_str2" -> target = value
"action_str" -> action = value
"alt_str1" -> action = value
"suffix_str" -> suffix = value
"action_img_url" -> actionImg = value
} }
} }
LogCenter.log("私聊戳一戳: $operation -> $target")
LogCenter.log("私聊戳一戳: $operation $action $target $suffix")
if(!GlobalEventTransmitter.PrivateNoticeTransmitter if(!GlobalEventTransmitter.PrivateNoticeTransmitter
.transPrivatePoke(msgTime, operation.toLong(), target.toLong())) { .transPrivatePoke(msgTime, operation.toLong(), target.toLong(), action, suffix, actionImg)) {
LogCenter.log("私聊戳一戳推送失败!", Level.WARN) LogCenter.log("私聊戳一戳推送失败!", Level.WARN)
} }
} }
@ -243,6 +251,9 @@ internal object PrimitiveListener {
lateinit var target: String lateinit var target: String
lateinit var operation: String lateinit var operation: String
var action: String? = null
var suffix: String? = null
var actionImg: String? = null
detail[26][7] detail[26][7]
.asList .asList
.value .value
@ -251,12 +262,16 @@ internal object PrimitiveListener {
when(it[1].asUtf8String) { when(it[1].asUtf8String) {
"uin_str1" -> operation = value "uin_str1" -> operation = value
"uin_str2" -> target = value "uin_str2" -> target = value
"action_str" -> action = value
"alt_str1" -> action = value
"suffix_str" -> suffix = value
"action_img_url" -> actionImg = value
} }
} }
LogCenter.log("群戳一戳($groupCode): $operation -> $target") LogCenter.log("群戳一戳($groupCode): $operation $action $target $suffix")
if(!GlobalEventTransmitter.GroupNoticeTransmitter if(!GlobalEventTransmitter.GroupNoticeTransmitter
.transGroupPoke(time, operation.toLong(), target.toLong(), groupCode)) { .transGroupPoke(time, operation.toLong(), target.toLong(), action, suffix, actionImg, groupCode)) {
LogCenter.log("群戳一戳推送失败!", Level.WARN) LogCenter.log("群戳一戳推送失败!", Level.WARN)
} }
} }