mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
send_forward_msg(support image)
This commit is contained in:
parent
eb807a0332
commit
1424efd7f8
@ -39,11 +39,26 @@ data class CustomFace(
|
|||||||
@ProtoNumber(32) var width400: UInt? = null,
|
@ProtoNumber(32) var width400: UInt? = null,
|
||||||
@ProtoNumber(33) var height400: UInt? = null,
|
@ProtoNumber(33) var height400: UInt? = null,
|
||||||
@ProtoNumber(34) var pbReserve: PbReserve? = null,
|
@ProtoNumber(34) var pbReserve: PbReserve? = null,
|
||||||
){
|
) {
|
||||||
companion object{
|
companion object {
|
||||||
@Serializable
|
@Serializable
|
||||||
data class PbReserve(
|
data class PbReserve(
|
||||||
@ProtoNumber(1) var field1: Int? = null
|
@ProtoNumber(1) var field1: Int? = null,
|
||||||
|
@ProtoNumber(3) var field3: Int? = null,
|
||||||
|
@ProtoNumber(4) var field4: Int? = null,
|
||||||
|
@ProtoNumber(10) var field10: Int? = null,
|
||||||
|
@ProtoNumber(21) var field21: Object1? = null,
|
||||||
|
@ProtoNumber(31) var field31: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Object1(
|
||||||
|
@ProtoNumber(1) var field1: Int? = null,
|
||||||
|
@ProtoNumber(2) var field2: String? = null,
|
||||||
|
@ProtoNumber(3) var field3: Int? = null,
|
||||||
|
@ProtoNumber(4) var field4: Int? = null,
|
||||||
|
@ProtoNumber(5) var field5: Int? = null,
|
||||||
|
@ProtoNumber(7) var md5Str: String? = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,16 +5,16 @@ import kotlinx.serialization.protobuf.ProtoNumber
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class NotOnlineImage(
|
data class NotOnlineImage(
|
||||||
@ProtoNumber(1) val filePath: ByteArray? = null,
|
@ProtoNumber(1) val filePath: String? = null,
|
||||||
@ProtoNumber(2) val fileLen: UInt? = null,
|
@ProtoNumber(2) val fileLen: UInt? = null,
|
||||||
@ProtoNumber(3) val downloadPath: ByteArray? = null,
|
@ProtoNumber(3) val downloadPath: String? = null,
|
||||||
@ProtoNumber(4) val oldVerSendFile: ByteArray? = null,
|
@ProtoNumber(4) val oldVerSendFile: ByteArray? = null,
|
||||||
@ProtoNumber(5) val imgType: UInt? = null,
|
@ProtoNumber(5) val imgType: UInt? = null,
|
||||||
@ProtoNumber(6) val previewsImage: ByteArray? = null,
|
@ProtoNumber(6) val previewsImage: ByteArray? = null,
|
||||||
@ProtoNumber(7) val picMd5: ByteArray? = null,
|
@ProtoNumber(7) val picMd5: ByteArray? = null,
|
||||||
@ProtoNumber(8) val picHeight: UInt? = null,
|
@ProtoNumber(8) val picHeight: UInt? = null,
|
||||||
@ProtoNumber(9) val picWidth: UInt? = null,
|
@ProtoNumber(9) val picWidth: UInt? = null,
|
||||||
@ProtoNumber(10) val resId: ByteArray? = null, // md5 + ".jpg"
|
@ProtoNumber(10) val resId: String? = null, // md5 + ".jpg"
|
||||||
@ProtoNumber(11) val flag: ByteArray? = null,
|
@ProtoNumber(11) val flag: ByteArray? = null,
|
||||||
@ProtoNumber(12) val thumbUrl: String? = null,
|
@ProtoNumber(12) val thumbUrl: String? = null,
|
||||||
@ProtoNumber(13) val original: Boolean? = null,
|
@ProtoNumber(13) val original: Boolean? = null,
|
||||||
@ -39,8 +39,23 @@ data class NotOnlineImage(
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class PbReserve(
|
data class PbReserve(
|
||||||
@ProtoNumber(1) var field1: Int? = null,
|
@ProtoNumber(1) var field1: Int? = null,
|
||||||
|
@ProtoNumber(3) var field3: Int? = null,
|
||||||
|
@ProtoNumber(4) var field4: Int? = null,
|
||||||
@ProtoNumber(8) var field8: String? = null,
|
@ProtoNumber(8) var field8: String? = null,
|
||||||
@ProtoNumber(30) var url: String? = null
|
@ProtoNumber(10) var field10: Int? = null,
|
||||||
|
@ProtoNumber(20) var field20: Object1? = null,
|
||||||
|
@ProtoNumber(30) var url: String? = null,
|
||||||
|
@ProtoNumber(31) var md5Str: String? = null
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Object1(
|
||||||
|
@ProtoNumber(1) var field1: Int? = null,
|
||||||
|
@ProtoNumber(2) var field2: String? = null,
|
||||||
|
@ProtoNumber(3) var field3: Int? = null,
|
||||||
|
@ProtoNumber(4) var field4: Int? = null,
|
||||||
|
@ProtoNumber(5) var field5: Int? = null,
|
||||||
|
@ProtoNumber(7) var field7: String? = null
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ package moe.fuqiuluo.qqinterface.servlet.msg
|
|||||||
|
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.MsgElement
|
import com.tencent.qqnt.kernel.nativeinterface.MsgElement
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.converter.ElemConverter
|
import moe.fuqiuluo.qqinterface.servlet.msg.converter.ElemConverter
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.converter.MsgElementConverter
|
import moe.fuqiuluo.qqinterface.servlet.msg.converter.NtMsgElementConverter
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
import moe.fuqiuluo.shamrock.helper.Level
|
||||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
||||||
@ -56,7 +56,7 @@ internal suspend fun List<MsgElement>.toSegments(chatType: Int, peerId: String,
|
|||||||
val messageData = arrayListOf<MessageSegment>()
|
val messageData = arrayListOf<MessageSegment>()
|
||||||
this.forEach { msg ->
|
this.forEach { msg ->
|
||||||
kotlin.runCatching {
|
kotlin.runCatching {
|
||||||
val converter = MsgElementConverter[msg.elementType]
|
val converter = NtMsgElementConverter[msg.elementType]
|
||||||
converter?.invoke(chatType, peerId, subPeer, msg)
|
converter?.invoke(chatType, peerId, subPeer, msg)
|
||||||
?: throw UnsupportedOperationException("不支持的消息element类型:${msg.elementType}")
|
?: throw UnsupportedOperationException("不支持的消息element类型:${msg.elementType}")
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
|
@ -21,23 +21,23 @@ import moe.fuqiuluo.shamrock.tools.hex2ByteArray
|
|||||||
|
|
||||||
internal typealias IMsgElementConverter = suspend (Int, String, String, MsgElement) -> MessageSegment
|
internal typealias IMsgElementConverter = suspend (Int, String, String, MsgElement) -> MessageSegment
|
||||||
|
|
||||||
internal object MsgElementConverter {
|
internal object NtMsgElementConverter {
|
||||||
private val convertMap = hashMapOf(
|
private val convertMap = hashMapOf(
|
||||||
MsgConstant.KELEMTYPETEXT to MsgElementConverter::convertTextElem,
|
MsgConstant.KELEMTYPETEXT to NtMsgElementConverter::convertTextElem,
|
||||||
MsgConstant.KELEMTYPEFACE to MsgElementConverter::convertFaceElem,
|
MsgConstant.KELEMTYPEFACE to NtMsgElementConverter::convertFaceElem,
|
||||||
MsgConstant.KELEMTYPEPIC to MsgElementConverter::convertImageElem,
|
MsgConstant.KELEMTYPEPIC to NtMsgElementConverter::convertImageElem,
|
||||||
MsgConstant.KELEMTYPEPTT to MsgElementConverter::convertVoiceElem,
|
MsgConstant.KELEMTYPEPTT to NtMsgElementConverter::convertVoiceElem,
|
||||||
MsgConstant.KELEMTYPEVIDEO to MsgElementConverter::convertVideoElem,
|
MsgConstant.KELEMTYPEVIDEO to NtMsgElementConverter::convertVideoElem,
|
||||||
MsgConstant.KELEMTYPEMARKETFACE to MsgElementConverter::convertMarketFaceElem,
|
MsgConstant.KELEMTYPEMARKETFACE to NtMsgElementConverter::convertMarketFaceElem,
|
||||||
MsgConstant.KELEMTYPEARKSTRUCT to MsgElementConverter::convertStructJsonElem,
|
MsgConstant.KELEMTYPEARKSTRUCT to NtMsgElementConverter::convertStructJsonElem,
|
||||||
MsgConstant.KELEMTYPEREPLY to MsgElementConverter::convertReplyElem,
|
MsgConstant.KELEMTYPEREPLY to NtMsgElementConverter::convertReplyElem,
|
||||||
MsgConstant.KELEMTYPEGRAYTIP to MsgElementConverter::convertGrayTipsElem,
|
MsgConstant.KELEMTYPEGRAYTIP to NtMsgElementConverter::convertGrayTipsElem,
|
||||||
MsgConstant.KELEMTYPEFILE to MsgElementConverter::convertFileElem,
|
MsgConstant.KELEMTYPEFILE to NtMsgElementConverter::convertFileElem,
|
||||||
MsgConstant.KELEMTYPEMARKDOWN to MsgElementConverter::convertMarkdownElem,
|
MsgConstant.KELEMTYPEMARKDOWN to NtMsgElementConverter::convertMarkdownElem,
|
||||||
//MsgConstant.KELEMTYPEMULTIFORWARD to MsgElementConverter::convertXmlMultiMsgElem,
|
//MsgConstant.KELEMTYPEMULTIFORWARD to MsgElementConverter::convertXmlMultiMsgElem,
|
||||||
//MsgConstant.KELEMTYPESTRUCTLONGMSG to MsgElementConverter::convertXmlLongMsgElem,
|
//MsgConstant.KELEMTYPESTRUCTLONGMSG to MsgElementConverter::convertXmlLongMsgElem,
|
||||||
MsgConstant.KELEMTYPEFACEBUBBLE to MsgElementConverter::convertBubbleFaceElem,
|
MsgConstant.KELEMTYPEFACEBUBBLE to NtMsgElementConverter::convertBubbleFaceElem,
|
||||||
MsgConstant.KELEMTYPEINLINEKEYBOARD to MsgElementConverter::convertInlineKeyboardElem
|
MsgConstant.KELEMTYPEINLINEKEYBOARD to NtMsgElementConverter::convertInlineKeyboardElem
|
||||||
)
|
)
|
||||||
|
|
||||||
operator fun get(type: Int): IMsgElementConverter? = convertMap[type]
|
operator fun get(type: Int): IMsgElementConverter? = convertMap[type]
|
@ -2,7 +2,7 @@ package moe.fuqiuluo.qqinterface.servlet.msg.maker
|
|||||||
|
|
||||||
import android.graphics.BitmapFactory
|
import android.graphics.BitmapFactory
|
||||||
import androidx.exifinterface.media.ExifInterface
|
import androidx.exifinterface.media.ExifInterface
|
||||||
import com.tencent.qqnt.kernel.nativeinterface.*
|
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import moe.fuqiuluo.qqinterface.servlet.CardSvc
|
import moe.fuqiuluo.qqinterface.servlet.CardSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
import moe.fuqiuluo.qqinterface.servlet.GroupSvc
|
||||||
@ -11,23 +11,12 @@ import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
|||||||
import moe.fuqiuluo.qqinterface.servlet.ark.WeatherSvc
|
import moe.fuqiuluo.qqinterface.servlet.ark.WeatherSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.toJson
|
import moe.fuqiuluo.qqinterface.servlet.msg.toJson
|
||||||
import moe.fuqiuluo.qqinterface.servlet.msg.toSegments
|
import moe.fuqiuluo.qqinterface.servlet.msg.toSegments
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.*
|
import moe.fuqiuluo.qqinterface.servlet.transfile.NtV2RichMediaSvc
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.data.PictureResource
|
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.data.Private
|
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.Transfer
|
|
||||||
import moe.fuqiuluo.qqinterface.servlet.transfile.data.Troop
|
|
||||||
import moe.fuqiuluo.shamrock.helper.*
|
import moe.fuqiuluo.shamrock.helper.*
|
||||||
import moe.fuqiuluo.shamrock.helper.ActionMsgException
|
|
||||||
import moe.fuqiuluo.shamrock.helper.Level
|
|
||||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
|
||||||
import moe.fuqiuluo.shamrock.helper.LogicException
|
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper.messageArrayToMessageElements
|
import moe.fuqiuluo.shamrock.helper.MessageHelper.messageArrayToMessageElements
|
||||||
import moe.fuqiuluo.shamrock.helper.ParamsException
|
|
||||||
import moe.fuqiuluo.shamrock.tools.*
|
import moe.fuqiuluo.shamrock.tools.*
|
||||||
import moe.fuqiuluo.shamrock.utils.DeflateTools
|
import moe.fuqiuluo.shamrock.utils.DeflateTools
|
||||||
import moe.fuqiuluo.shamrock.utils.FileUtils
|
import moe.fuqiuluo.shamrock.utils.FileUtils
|
||||||
import moe.fuqiuluo.shamrock.xposed.helper.NTServiceFetcher
|
|
||||||
import moe.fuqiuluo.shamrock.xposed.helper.msgService
|
|
||||||
import protobuf.auto.toByteArray
|
import protobuf.auto.toByteArray
|
||||||
import protobuf.message.Elem
|
import protobuf.message.Elem
|
||||||
import protobuf.message.element.*
|
import protobuf.message.element.*
|
||||||
@ -36,8 +25,9 @@ import java.io.File
|
|||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
import kotlin.random.nextULong
|
import kotlin.random.nextULong
|
||||||
|
import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
internal typealias IMessageElementMaker = suspend (Int, Long, String, JsonObject) -> Result<Elem>
|
internal typealias IElemMaker = suspend (Int, Long, String, JsonObject) -> Result<Elem>
|
||||||
|
|
||||||
internal object ElemMaker {
|
internal object ElemMaker {
|
||||||
private val makerArray = hashMapOf(
|
private val makerArray = hashMapOf(
|
||||||
@ -46,30 +36,30 @@ internal object ElemMaker {
|
|||||||
"face" to ElemMaker::createFaceElem,
|
"face" to ElemMaker::createFaceElem,
|
||||||
"pic" to ElemMaker::createImageElem,
|
"pic" to ElemMaker::createImageElem,
|
||||||
"image" to ElemMaker::createImageElem,
|
"image" to ElemMaker::createImageElem,
|
||||||
// "voice" to MessageElementMaker::createRecordElem,
|
// "voice" to ElemMaker::createRecordElem,
|
||||||
// "record" to MessageElementMaker::createRecordElem,
|
// "record" to ElemMaker::createRecordElem,
|
||||||
// "video" to MessageElementMaker::createVideoElem,
|
// "video" to ElemMaker::createVideoElem,
|
||||||
"markdown" to ElemMaker::createMarkdownElem,
|
"markdown" to ElemMaker::createMarkdownElem,
|
||||||
"button" to ElemMaker::createButtonElem,
|
"button" to ElemMaker::createButtonElem,
|
||||||
"inline_keyboard" to ElemMaker::createButtonElem,
|
"inline_keyboard" to ElemMaker::createButtonElem,
|
||||||
"dice" to ElemMaker::createNewDiceElem,
|
"dice" to ElemMaker::createNewDiceElem,
|
||||||
"rps" to ElemMaker::createNewRpsElem,
|
"rps" to ElemMaker::createNewRpsElem,
|
||||||
"poke" to ElemMaker::createPokeElem,
|
"poke" to ElemMaker::createPokeElem,
|
||||||
// "anonymous" to MessageElementMaker::createAnonymousElem,
|
// "anonymous" to ElemMaker::createAnonymousElem,
|
||||||
// "share" to MessageElementMaker::createShareElem,
|
// "share" to ElemMaker::createShareElem,
|
||||||
// "contact" to MessageElementMaker::createContactElem,
|
// "contact" to ElemMaker::createContactElem,
|
||||||
// "location" to MessageElementMaker::createLocationElem,
|
// "location" to ElemMaker::createLocationElem,
|
||||||
// "music" to MessageElementMaker::createMusicElem,
|
// "music" to ElemMaker::createMusicElem,
|
||||||
"reply" to ElemMaker::createReplyElem,
|
"reply" to ElemMaker::createReplyElem,
|
||||||
// "touch" to MessageElementMaker::createTouchElem,
|
// "touch" to ElemMaker::createTouchElem,
|
||||||
"weather" to ElemMaker::createWeatherElem,
|
"weather" to ElemMaker::createWeatherElem,
|
||||||
"json" to ElemMaker::createJsonElem,
|
"json" to ElemMaker::createJsonElem,
|
||||||
// "node" to MessageMaker::createNodeElem,
|
//"forward" to MessageMaker::createForwardElem,
|
||||||
//"multi_msg" to MessageMaker::createLongMsgStruct,
|
//"multi_msg" to MessageMaker::createLongMsgStruct,
|
||||||
//"bubble_face" to MessageElementMaker::createBubbleFaceElem,
|
//"bubble_face" to ElemMaker::createBubbleFaceElem,
|
||||||
)
|
)
|
||||||
|
|
||||||
operator fun get(type: String): IMessageElementMaker? = makerArray[type]
|
operator fun get(type: String): IElemMaker? = makerArray[type]
|
||||||
|
|
||||||
private suspend fun createTextElem(
|
private suspend fun createTextElem(
|
||||||
chatType: Int,
|
chatType: Int,
|
||||||
@ -226,26 +216,6 @@ internal object ElemMaker {
|
|||||||
}
|
}
|
||||||
requireNotNull(file)
|
requireNotNull(file)
|
||||||
|
|
||||||
val md5HexStr = QQNTWrapperUtil.CppProxy.genFileMd5Hex(file.absolutePath)
|
|
||||||
val msgService = NTServiceFetcher.kernelService.msgService!!
|
|
||||||
val originalPath = msgService.getRichMediaFilePathForMobileQQSend(
|
|
||||||
RichMediaFilePathInfo(
|
|
||||||
2, 0, md5HexStr, file.name, 1, 0, null, "", true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
if (!QQNTWrapperUtil.CppProxy.fileIsExist(originalPath) || QQNTWrapperUtil.CppProxy.getFileSize(
|
|
||||||
originalPath
|
|
||||||
) != file.length()
|
|
||||||
) {
|
|
||||||
val thumbPath = msgService.getRichMediaFilePathForMobileQQSend(
|
|
||||||
RichMediaFilePathInfo(
|
|
||||||
2, 0, md5HexStr, file.name, 2, 720, null, "", true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
QQNTWrapperUtil.CppProxy.copyFile(file.absolutePath, originalPath)
|
|
||||||
QQNTWrapperUtil.CppProxy.copyFile(file.absolutePath, thumbPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
val options = BitmapFactory.Options()
|
val options = BitmapFactory.Options()
|
||||||
options.inJustDecodeBounds = true
|
options.inJustDecodeBounds = true
|
||||||
BitmapFactory.decodeFile(file.absolutePath, options)
|
BitmapFactory.decodeFile(file.absolutePath, options)
|
||||||
@ -264,53 +234,77 @@ internal object ElemMaker {
|
|||||||
picHeight = options.outWidth
|
picHeight = options.outWidth
|
||||||
}
|
}
|
||||||
|
|
||||||
val elem = when (chatType) {
|
val uploadRet = NtV2RichMediaSvc.tryUploadResourceByNt(
|
||||||
MsgConstant.KCHATTYPEGROUP -> {
|
chatType = chatType,
|
||||||
Transfer with Troop(peerId) trans PictureResource(file)
|
elementType = MsgConstant.KELEMTYPEPIC,
|
||||||
Elem(
|
resources = arrayListOf(file),
|
||||||
customFace = CustomFace(
|
timeout = 30.seconds
|
||||||
filePath = "${md5HexStr.substring(0, 8)}-${md5HexStr.substring(8, 4)}-${
|
).getOrThrow().first()
|
||||||
md5HexStr.substring(
|
LogCenter.log(uploadRet.toString(), Level.DEBUG)
|
||||||
12,
|
|
||||||
4
|
|
||||||
)
|
|
||||||
}-${md5HexStr.substring(16, 4)}-${md5HexStr.substring(20, 12)}.${FileUtils.getFileType(file)}",
|
|
||||||
fileId = 0u,
|
|
||||||
serverIp = 0u,
|
|
||||||
serverPort = 0u,
|
|
||||||
fileType = 1001u,
|
|
||||||
useful = 1u,
|
|
||||||
md5 = md5HexStr.hex2ByteArray(),
|
|
||||||
bizType = data["subType"].asIntOrNull?.toUInt(),
|
|
||||||
imageType = FileUtils.getPicType(file).toUInt(),
|
|
||||||
width = picWidth.toUInt(),
|
|
||||||
height = picHeight.toUInt(),
|
|
||||||
size = QQNTWrapperUtil.CppProxy.getFileSize(file.absolutePath).toUInt(),
|
|
||||||
origin = isOriginal,
|
|
||||||
thumbWidth = 0u,
|
|
||||||
thumbHeight = 0u,
|
|
||||||
pbReserve = CustomFace.Companion.PbReserve(field1 = 0)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
MsgConstant.KCHATTYPEC2C -> {
|
val elem = when (chatType) {
|
||||||
Transfer with Private(peerId) trans PictureResource(file)
|
MsgConstant.KCHATTYPEGROUP -> Elem(
|
||||||
Elem(
|
customFace = CustomFace(
|
||||||
notOnlineImage = NotOnlineImage(
|
filePath = uploadRet.fileName,
|
||||||
filePath = "${md5HexStr}.${FileUtils.getFileType(file)}".toByteArray(),
|
fileId = uploadRet.uuid.toUInt(),
|
||||||
fileLen = QQNTWrapperUtil.CppProxy.getFileSize(file.absolutePath).toUInt(),
|
serverIp = 0u,
|
||||||
downloadPath = "".toByteArray(),
|
serverPort = 0u,
|
||||||
imgType = FileUtils.getPicType(file).toUInt(),
|
fileType = FileUtils.getPicType(file).toUInt(),
|
||||||
picMd5 = md5HexStr.hex2ByteArray(),
|
useful = 1u,
|
||||||
picHeight = picWidth.toUInt(),
|
md5 = uploadRet.md5.hex2ByteArray(),
|
||||||
picWidth = picHeight.toUInt(),
|
bizType = data["subType"].asIntOrNull?.toUInt(),
|
||||||
resId = "".toByteArray(),
|
imageType = FileUtils.getPicType(file).toUInt(),
|
||||||
original = isOriginal, // true
|
width = picWidth.toUInt(),
|
||||||
pbReserve = NotOnlineImage.Companion.PbReserve(field1 = 0)
|
height = picHeight.toUInt(),
|
||||||
|
size = uploadRet.fileSize.toUInt(),
|
||||||
|
origin = isOriginal,
|
||||||
|
thumbWidth = 0u,
|
||||||
|
thumbHeight = 0u,
|
||||||
|
pbReserve = CustomFace.Companion.PbReserve(
|
||||||
|
field1 = 0,
|
||||||
|
field3 = 0,
|
||||||
|
field4 = 0,
|
||||||
|
field10 = 0,
|
||||||
|
field21 = CustomFace.Companion.Object1(
|
||||||
|
field1 = 0,
|
||||||
|
field2 = "",
|
||||||
|
field3 = 0,
|
||||||
|
field4 = 0,
|
||||||
|
field5 = 0,
|
||||||
|
md5Str = uploadRet.md5
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
|
|
||||||
|
MsgConstant.KCHATTYPEC2C -> Elem(
|
||||||
|
notOnlineImage = NotOnlineImage(
|
||||||
|
filePath = uploadRet.fileName,
|
||||||
|
fileLen = uploadRet.fileSize.toUInt(),
|
||||||
|
downloadPath = uploadRet.uuid,
|
||||||
|
imgType = FileUtils.getPicType(file).toUInt(),
|
||||||
|
picMd5 = uploadRet.md5.hex2ByteArray(),
|
||||||
|
picHeight = picWidth.toUInt(),
|
||||||
|
picWidth = picHeight.toUInt(),
|
||||||
|
resId = uploadRet.uuid,
|
||||||
|
original = isOriginal, // true
|
||||||
|
pbReserve = NotOnlineImage.Companion.PbReserve(
|
||||||
|
field1 = 0,
|
||||||
|
field3 = 0,
|
||||||
|
field4 = 0,
|
||||||
|
field10 = 0,
|
||||||
|
field20 = NotOnlineImage.Companion.Object1(
|
||||||
|
field1 = 0,
|
||||||
|
field2 = "",
|
||||||
|
field3 = 0,
|
||||||
|
field4 = 0,
|
||||||
|
field5 = 0,
|
||||||
|
field7 = "",
|
||||||
|
),
|
||||||
|
md5Str = uploadRet.md5
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
else -> throw LogicException("Not supported chatType($chatType) for PictureMsg")
|
else -> throw LogicException("Not supported chatType($chatType) for PictureMsg")
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,6 @@ internal object NtMsgElementMaker {
|
|||||||
"new_dice" to NtMsgElementMaker::createNewDiceElem,
|
"new_dice" to NtMsgElementMaker::createNewDiceElem,
|
||||||
"new_rps" to NtMsgElementMaker::createNewRpsElem,
|
"new_rps" to NtMsgElementMaker::createNewRpsElem,
|
||||||
"basketball" to NtMsgElementMaker::createBasketballElem,
|
"basketball" to NtMsgElementMaker::createBasketballElem,
|
||||||
//"node" to MessageMaker::createNodeElem,
|
|
||||||
//"multi_msg" to MessageMaker::createLongMsgStruct,
|
//"multi_msg" to MessageMaker::createLongMsgStruct,
|
||||||
"bubble_face" to NtMsgElementMaker::createBubbleFaceElem,
|
"bubble_face" to NtMsgElementMaker::createBubbleFaceElem,
|
||||||
"button" to NtMsgElementMaker::createInlineKeywordElem,
|
"button" to NtMsgElementMaker::createInlineKeywordElem,
|
||||||
@ -179,17 +178,6 @@ internal object NtMsgElementMaker {
|
|||||||
return Result.success(elem)
|
return Result.success(elem)
|
||||||
}
|
}
|
||||||
|
|
||||||
// private suspend fun createNodeElem(
|
|
||||||
// chatType: Int,
|
|
||||||
// msgId: Long,
|
|
||||||
// peerId: String,
|
|
||||||
// data: JsonObject
|
|
||||||
// ): Result<MsgElement> {
|
|
||||||
// data.checkAndThrow("data")
|
|
||||||
// SendForwardMessage(MsgConstant.KCHATTYPEC2C, TicketSvc.getUin(), data["content"].asJsonArray)
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private suspend fun createBasketballElem(
|
private suspend fun createBasketballElem(
|
||||||
chatType: Int,
|
chatType: Int,
|
||||||
msgId: Long,
|
msgId: Long,
|
||||||
|
@ -146,11 +146,13 @@ internal object SendForwardMessage : IActionHandler() {
|
|||||||
).also {
|
).also {
|
||||||
desc[++i] = record.sendMemberName.ifEmpty { record.sendNickName } + ": "
|
desc[++i] = record.sendMemberName.ifEmpty { record.sendNickName } + ": "
|
||||||
}.map {
|
}.map {
|
||||||
desc[++i] += when (it.type) {
|
desc[i] += when (it.type) {
|
||||||
"text" -> it.data["text"] as String
|
"text" -> it.data["text"] as String
|
||||||
"at" -> "@${it.data["name"] as String? ?: it.data["qq"] as String}"
|
"at" -> "@${it.data["name"] as String? ?: it.data["qq"] as String}"
|
||||||
"face" -> "[表情]"
|
"face" -> "[表情]"
|
||||||
"voice" -> "[语音]"
|
"pic", "image" -> "[图片]"
|
||||||
|
"voice", "record" -> "[语音]"
|
||||||
|
"video" -> "[视频]"
|
||||||
"node" -> "[合并转发消息]"
|
"node" -> "[合并转发消息]"
|
||||||
"markdown" -> "[Markdown消息]"
|
"markdown" -> "[Markdown消息]"
|
||||||
"button" -> "[Button类型]"
|
"button" -> "[Button类型]"
|
||||||
@ -197,7 +199,7 @@ internal object SendForwardMessage : IActionHandler() {
|
|||||||
body = MsgBody(
|
body = MsgBody(
|
||||||
richText = RichText(
|
richText = RichText(
|
||||||
elements = MessageHelper.messageArrayToMessageElements(
|
elements = MessageHelper.messageArrayToMessageElements(
|
||||||
chatType = MsgConstant.KCHATTYPEGROUP,
|
chatType = chatType,
|
||||||
msgId = Random.nextLong(),
|
msgId = Random.nextLong(),
|
||||||
peerId = data["uin"]?.asString ?: TicketSvc.getUin(),
|
peerId = data["uin"]?.asString ?: TicketSvc.getUin(),
|
||||||
messageList = when (data["content"]) {
|
messageList = when (data["content"]) {
|
||||||
@ -207,7 +209,7 @@ internal object SendForwardMessage : IActionHandler() {
|
|||||||
}.also {
|
}.also {
|
||||||
desc[++i] =
|
desc[++i] =
|
||||||
(data["name"].asStringOrNull ?: data["uin"].asStringOrNull
|
(data["name"].asStringOrNull ?: data["uin"].asStringOrNull
|
||||||
?: TicketSvc.getNickname() )+ ": "
|
?: TicketSvc.getNickname()) + ": "
|
||||||
}.onEach {
|
}.onEach {
|
||||||
val type = it.asJsonObject["type"].asString
|
val type = it.asJsonObject["type"].asString
|
||||||
val itData = it.asJsonObject["data"].asJsonObject
|
val itData = it.asJsonObject["data"].asJsonObject
|
||||||
@ -215,8 +217,9 @@ internal object SendForwardMessage : IActionHandler() {
|
|||||||
"text" -> itData["text"].asString
|
"text" -> itData["text"].asString
|
||||||
"at" -> "@${itData["name"].asStringOrNull ?: itData["qq"].asString}"
|
"at" -> "@${itData["name"].asStringOrNull ?: itData["qq"].asString}"
|
||||||
"face" -> "[表情]"
|
"face" -> "[表情]"
|
||||||
"image" -> "[图片]"
|
"pic", "image" -> "[图片]"
|
||||||
"voice" -> "[语音]"
|
"voice", "record" -> "[语音]"
|
||||||
|
"video" -> "[视频]"
|
||||||
"node" -> "[合并转发消息]"
|
"node" -> "[合并转发消息]"
|
||||||
"markdown" -> "[Markdown消息]"
|
"markdown" -> "[Markdown消息]"
|
||||||
"button" -> "[Button类型]"
|
"button" -> "[Button类型]"
|
||||||
|
@ -27,13 +27,18 @@ fun Routing.testAction() {
|
|||||||
val resId = fetchOrThrow("res_id")
|
val resId = fetchOrThrow("res_id")
|
||||||
val peerId = fetchOrThrow("peer_Id")
|
val peerId = fetchOrThrow("peer_Id")
|
||||||
val messageType = fetchOrThrow("message_type")
|
val messageType = fetchOrThrow("message_type")
|
||||||
call.respondText(SendMsgByResid(resId, peerId, messageType))
|
call.respondText(SendMsgByResid(peerId, resId, messageType))
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrPost("/createUidFromTinyId") {
|
getOrPost("/createUidFromTinyId") {
|
||||||
val selfId = fetchOrThrow("selfId").toLong()
|
val selfId = fetchOrThrow("selfId").toLong()
|
||||||
val peerId = fetchOrThrow("peerId")
|
val peerId = fetchOrThrow("peerId")
|
||||||
call.respondText(NTServiceFetcher.kernelService.wrapperSession.msgService.createUidFromTinyId(selfId, peerId.toLong()))
|
call.respondText(
|
||||||
|
NTServiceFetcher.kernelService.wrapperSession.msgService.createUidFromTinyId(
|
||||||
|
selfId,
|
||||||
|
peerId.toLong()
|
||||||
|
)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
getOrPost("/addSendMsg") {
|
getOrPost("/addSendMsg") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user