mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Merge branch 'master' of https://github.com/ikechan8370/OpenShamrock
This commit is contained in:
commit
2f264ee9e4
@ -110,8 +110,8 @@ fun LabFragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Function(
|
Function(
|
||||||
title = "拦截QQ无用发包",
|
title = "拦截QQ无用收包",
|
||||||
desc = "测试阶段,可能导致网络异常。",
|
desc = "测试阶段,可能导致网络异常或掉线。",
|
||||||
descColor = it,
|
descColor = it,
|
||||||
isSwitch = ShamrockConfig.isInjectPacket(ctx)
|
isSwitch = ShamrockConfig.isInjectPacket(ctx)
|
||||||
) {
|
) {
|
||||||
|
@ -5,6 +5,7 @@ import com.tencent.qqnt.kernel.nativeinterface.MsgRecord
|
|||||||
import kotlinx.serialization.SerialName
|
import kotlinx.serialization.SerialName
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.JsonElement
|
import kotlinx.serialization.json.JsonElement
|
||||||
|
import moe.fuqiuluo.qqinterface.servlet.MsgSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.convert.MessageConvert
|
import moe.fuqiuluo.qqinterface.servlet.msg.convert.MessageConvert
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||||
import moe.fuqiuluo.shamrock.helper.db.MessageDB
|
import moe.fuqiuluo.shamrock.helper.db.MessageDB
|
||||||
@ -53,23 +54,46 @@ internal object GetHistoryMsg: IActionHandler() {
|
|||||||
return logic(result.msg ?: "获取历史消息失败", echo = echo)
|
return logic(result.msg ?: "获取历史消息失败", echo = echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
val msgList = result.data!!.map { msg ->
|
val msgList = ArrayList<MessageDetail>().apply {
|
||||||
val msgHash = MessageHelper.generateMsgIdHash(msg.chatType, msg.msgId)
|
addAll(result.data!!.map { msg ->
|
||||||
MessageDetail(
|
val msgHash = MessageHelper.generateMsgIdHash(msg.chatType, msg.msgId)
|
||||||
time = msg.msgTime.toInt(),
|
MessageDetail(
|
||||||
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
time = msg.msgTime.toInt(),
|
||||||
msgId = msgHash,
|
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
||||||
realId = msg.msgSeq.toInt(),
|
msgId = msgHash,
|
||||||
sender = MessageSender(
|
realId = msg.msgSeq.toInt(),
|
||||||
msg.senderUin, msg.sendNickName, "unknown", 0, msg.senderUid
|
sender = MessageSender(
|
||||||
),
|
msg.senderUin, msg.sendNickName, "unknown", 0, msg.senderUid
|
||||||
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
|
),
|
||||||
it.toJson()
|
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
|
||||||
},
|
it.toJson()
|
||||||
peerId = msg.peerUin,
|
},
|
||||||
groupId = if (msg.chatType == MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0,
|
peerId = msg.peerUin,
|
||||||
targetId = if (msg.chatType != MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0
|
groupId = if (msg.chatType == MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0,
|
||||||
)
|
targetId = if (msg.chatType != MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0
|
||||||
|
)
|
||||||
|
})
|
||||||
|
if (startMsgId != 0L) {
|
||||||
|
val msg = MsgSvc.getMsgByQMsgId(chatType, peerId, startMsgId).onFailure {
|
||||||
|
return logic("Obtain msg failed, please check your msg_id.", echo)
|
||||||
|
}.getOrThrow()
|
||||||
|
val seq = msg.clientSeq.toInt()
|
||||||
|
add(MessageDetail(
|
||||||
|
time = msg.msgTime.toInt(),
|
||||||
|
msgType = MessageHelper.obtainDetailTypeByMsgType(msg.chatType),
|
||||||
|
msgId = MessageHelper.generateMsgIdHash(msg.chatType, msg.msgId),
|
||||||
|
realId = seq,
|
||||||
|
sender = MessageSender(
|
||||||
|
msg.senderUin, msg.sendNickName, "unknown", 0, msg.senderUid
|
||||||
|
),
|
||||||
|
message = MessageConvert.convertMessageRecordToMsgSegment(msg).map {
|
||||||
|
it.toJson()
|
||||||
|
},
|
||||||
|
peerId = msg.peerUin,
|
||||||
|
groupId = if (msg.chatType == MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0,
|
||||||
|
targetId = if (msg.chatType != MsgConstant.KCHATTYPEGROUP) msg.peerUin else 0
|
||||||
|
))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok(data = GetHistoryMsgResult(msgList), echo = echo)
|
return ok(data = GetHistoryMsgResult(msgList), echo = echo)
|
||||||
|
@ -15,8 +15,8 @@ internal object SetGroupUnique: IActionHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend operator fun invoke(groupId: String, userId: String, unique: String, echo: JsonElement = EmptyJsonString): String {
|
suspend operator fun invoke(groupId: String, userId: String, unique: String, echo: JsonElement = EmptyJsonString): String {
|
||||||
if (!GroupSvc.isAdmin(groupId)) {
|
if (!GroupSvc.isOwner(groupId)) {
|
||||||
return error("you are not admin", echo)
|
return error("you are not owner", echo)
|
||||||
}
|
}
|
||||||
GroupSvc.setGroupUniqueTitle(groupId, userId, unique)
|
GroupSvc.setGroupUniqueTitle(groupId, userId, unique)
|
||||||
return ok("成功", echo)
|
return ok("成功", echo)
|
||||||
|
@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit
|
|||||||
fun Routing.otherAction() {
|
fun Routing.otherAction() {
|
||||||
|
|
||||||
if (ShamrockConfig.allowShell()) {
|
if (ShamrockConfig.allowShell()) {
|
||||||
getOrPost("/shell") {
|
post("/shell") {
|
||||||
val runtime = Runtime.getRuntime()
|
val runtime = Runtime.getRuntime()
|
||||||
val dir = fetchOrThrow("dir")
|
val dir = fetchOrThrow("dir")
|
||||||
val out = StringBuilder()
|
val out = StringBuilder()
|
||||||
|
@ -113,7 +113,7 @@ internal class HookWrapperCodec: IAction {
|
|||||||
from.putWupBuffer(merge.toByteArray())
|
from.putWupBuffer(merge.toByteArray())
|
||||||
} else if (from.appId != MAGIC_APP_ID) {
|
} else if (from.appId != MAGIC_APP_ID) {
|
||||||
if (from.serviceCmd in IgnoredCmd && ShamrockConfig.isInjectPacket()) {
|
if (from.serviceCmd in IgnoredCmd && ShamrockConfig.isInjectPacket()) {
|
||||||
from.serviceCmd = "ShamrockInjectedCmd"
|
from.serviceCmd = "ShamrockInjectedCmd_${from.serviceCmd}"
|
||||||
from.putWupBuffer(EMPTY_BYTE_ARRAY)
|
from.putWupBuffer(EMPTY_BYTE_ARRAY)
|
||||||
} else {
|
} else {
|
||||||
pushOnReceive(from)
|
pushOnReceive(from)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user