mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
64c800c945
@ -90,18 +90,19 @@ internal object SendForwardMessage : IActionHandler() {
|
||||
if (it.asJsonObject["type"].asStringOrNull != "node") return@map ForwardMsgNode.EmptyNode // 过滤非node类型消息段
|
||||
it.asJsonObject["data"].asJsonObject.let { data ->
|
||||
if (data.containsKey("content")) {
|
||||
data["content"].asJsonArray.forEach { msg ->
|
||||
if (msg.asJsonObject["type"].asStringOrNull == "node") {
|
||||
LogCenter.log("合并转发消息不支持嵌套", Level.ERROR)
|
||||
return@map ForwardMsgNode.EmptyNode
|
||||
if (data["content"] is JsonArray) {
|
||||
data["content"].asJsonArray.forEach { msg ->
|
||||
if (msg.asJsonObject["type"].asStringOrNull == "node") {
|
||||
LogCenter.log("合并转发消息不支持嵌套", Level.ERROR)
|
||||
return@map ForwardMsgNode.EmptyNode
|
||||
}
|
||||
}
|
||||
}
|
||||
ForwardMsgNode.MessageNode(
|
||||
name = data["name"].asStringOrNull ?: "",
|
||||
content = data["content"]
|
||||
)
|
||||
}
|
||||
else ForwardMsgNode.MessageIdNode(data["id"].asInt)
|
||||
} else ForwardMsgNode.MessageIdNode(data["id"].asInt)
|
||||
}
|
||||
}.map {
|
||||
if (it is ForwardMsgNode.MessageIdNode) {
|
||||
@ -131,7 +132,9 @@ internal object SendForwardMessage : IActionHandler() {
|
||||
suspendCoroutine {
|
||||
GlobalScope.launch {
|
||||
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)
|
||||
},
|
||||
{ code, why ->
|
||||
@ -154,9 +157,10 @@ internal object SendForwardMessage : IActionHandler() {
|
||||
|
||||
return ok(
|
||||
ForwardMessageResult(
|
||||
msgId = uniseq.first,
|
||||
forwardId = ""
|
||||
), echo = echo)
|
||||
msgId = uniseq.first,
|
||||
forwardId = ""
|
||||
), echo = echo
|
||||
)
|
||||
}.onFailure {
|
||||
return error("error: $it", echo)
|
||||
}
|
||||
|
@ -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.NoticeSubType
|
||||
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.RequestEvent
|
||||
import moe.fuqiuluo.shamrock.remote.service.data.push.RequestSubType
|
||||
@ -221,7 +222,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
* 群聊通知 通知器
|
||||
*/
|
||||
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(
|
||||
time = time,
|
||||
selfId = app.longAccountUin,
|
||||
@ -231,7 +232,12 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
operatorId = operation,
|
||||
userId = operation,
|
||||
groupId = groupCode,
|
||||
target = target
|
||||
target = target,
|
||||
pokeDetail = PokeDetail(
|
||||
action = action,
|
||||
suffix = suffix,
|
||||
actionImg = actionImg
|
||||
)
|
||||
))
|
||||
return true
|
||||
}
|
||||
@ -292,7 +298,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
type = NoticeType.GroupBan,
|
||||
subType = if (duration == 0) NoticeSubType.LiftBan else NoticeSubType.Ban,
|
||||
operatorId = operation,
|
||||
userId = operation,
|
||||
userId = target,
|
||||
senderId = operation,
|
||||
target = target,
|
||||
groupId = groupCode,
|
||||
@ -389,7 +395,7 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
* 私聊通知 通知器
|
||||
*/
|
||||
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(
|
||||
time = msgTime,
|
||||
selfId = app.longAccountUin,
|
||||
@ -399,7 +405,12 @@ internal object GlobalEventTransmitter: BaseSvc() {
|
||||
operatorId = operation,
|
||||
userId = operation,
|
||||
senderId = operation,
|
||||
target = target
|
||||
target = target,
|
||||
pokeDetail = PokeDetail(
|
||||
actionImg = actionImg,
|
||||
action = action,
|
||||
suffix = suffix
|
||||
)
|
||||
))
|
||||
return true
|
||||
}
|
||||
|
@ -76,9 +76,17 @@ internal data class NoticeEvent(
|
||||
@SerialName("file") val file: GroupFileMsg? = null,
|
||||
@SerialName("private_file") val privateFile: PrivateFileMsg? = null,
|
||||
@SerialName("flag") val flag: String? = null,
|
||||
|
||||
// 群名片
|
||||
@SerialName("card_new") val cardNew: String? = null,
|
||||
@SerialName("card_old") val cardOld: 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,
|
||||
val url: String,
|
||||
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",
|
||||
)
|
@ -96,6 +96,9 @@ internal object PrimitiveListener {
|
||||
|
||||
lateinit var target: String
|
||||
lateinit var operation: String
|
||||
var suffix: String? = null
|
||||
var actionImg: String? = null
|
||||
var action: String? = null
|
||||
detail[7]
|
||||
.asList
|
||||
.value
|
||||
@ -104,12 +107,17 @@ internal object PrimitiveListener {
|
||||
when(it[1].asUtf8String) {
|
||||
"uin_str1" -> operation = 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
|
||||
.transPrivatePoke(msgTime, operation.toLong(), target.toLong())) {
|
||||
.transPrivatePoke(msgTime, operation.toLong(), target.toLong(), action, suffix, actionImg)) {
|
||||
LogCenter.log("私聊戳一戳推送失败!", Level.WARN)
|
||||
}
|
||||
}
|
||||
@ -243,6 +251,9 @@ internal object PrimitiveListener {
|
||||
|
||||
lateinit var target: String
|
||||
lateinit var operation: String
|
||||
var action: String? = null
|
||||
var suffix: String? = null
|
||||
var actionImg: String? = null
|
||||
detail[26][7]
|
||||
.asList
|
||||
.value
|
||||
@ -251,12 +262,16 @@ internal object PrimitiveListener {
|
||||
when(it[1].asUtf8String) {
|
||||
"uin_str1" -> operation = 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
|
||||
.transGroupPoke(time, operation.toLong(), target.toLong(), groupCode)) {
|
||||
.transGroupPoke(time, operation.toLong(), target.toLong(), action, suffix, actionImg, groupCode)) {
|
||||
LogCenter.log("群戳一戳推送失败!", Level.WARN)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user