Shamrock: Automatically remove group forward messages

Signed-off-by: 白池 <whitechi73@outlook.com>
This commit is contained in:
白池 2024-02-27 22:25:38 +08:00
parent a3171b3111
commit cb7bf00e17
3 changed files with 18 additions and 4 deletions

View File

@ -18,6 +18,8 @@ import moe.fuqiuluo.shamrock.helper.db.MessageDB
import moe.fuqiuluo.shamrock.tools.asJsonObject
import moe.fuqiuluo.shamrock.tools.asString
import moe.fuqiuluo.shamrock.tools.hex2ByteArray
import moe.fuqiuluo.shamrock.utils.PlatformUtils
import moe.fuqiuluo.shamrock.utils.PlatformUtils.QQ_9_0_8_VER
internal typealias IMsgElementConverter = suspend (Int, String, String, MsgElement) -> MessageSegment
@ -167,6 +169,11 @@ internal object NtMsgElementConverter {
val originalUrl = image.originImageUrl ?: ""
LogCenter.log({ "receive image: $image" }, Level.DEBUG)
var storeId = 0
if (PlatformUtils.getQQVersionCode() > QQ_9_0_8_VER) {
storeId = image.storeID
}
return MessageSegment(
type = "image",
data = hashMapOf(
@ -192,6 +199,7 @@ internal object NtMsgElementConverter {
sha = "",
fileSize = image.fileSize.toULong(),
peer = peerId,
storeId = storeId
)
MsgConstant.KCHATTYPEGUILD -> RichProtoSvc.getGuildPicDownUrl(

View File

@ -296,7 +296,12 @@ internal object NtV2RichMediaSvc: BaseSvc() {
contact = contact,
message = ArrayList(messages),
uniseq = uniseq.qqMsgId
) { _, _ -> }
) { _, _ ->
val kernelService = NTServiceFetcher.kernelService
val sessionService = kernelService.wrapperSession
val msgService = sessionService.msgService
msgService.deleteMsg(contact, arrayListOf(uniseq.qqMsgId), null)
}
it.invokeOnCancellation {
RichMediaUploadHandler.removeListener(uniseq.qqMsgId)
}

View File

@ -208,9 +208,10 @@ internal object RichProtoSvc: BaseSvc() {
sha: String = "",
fileSize: ULong = 0uL,
width: UInt = 0u,
height: UInt = 0u
height: UInt = 0u,
storeId: Int = 0
): String {
val isNtServer = originalUrl.startsWith("/download")
val isNtServer = storeId == 1 || originalUrl.startsWith("/download")
val domain = if (isNtServer) MULTIMEDIA_DOMAIN else C2C_PIC
if (originalUrl.isNotEmpty()) {
if (fileId.isNotEmpty()) getNtPicRKey(
@ -238,7 +239,7 @@ internal object RichProtoSvc: BaseSvc() {
}
return "https://$domain$originalUrl"
}
return "https://$domain/offpic_new/0/123-0-${md5}/0?term=2"
return "https://$domain/offpic_new/0/0-0-${md5}/0?term=2"
}
suspend fun getGuildPicDownUrl(