mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Fix interface(get_img
) support for nt
Signed-off-by: 白池 <whitechi73@outlook.com>
This commit is contained in:
parent
52ec43abf8
commit
3619cba33c
@ -113,7 +113,15 @@ internal object ElemConverter {
|
||||
val md5 = customFace.md5.toHexString()
|
||||
|
||||
ImageDB.getInstance().imageMappingDao().insert(
|
||||
ImageMapping(md5.uppercase(), chatType, customFace.size!!.toLong())
|
||||
ImageMapping(
|
||||
fileName = md5.uppercase(),
|
||||
md5 = md5.uppercase(),
|
||||
chatType = chatType,
|
||||
size = customFace.size!!.toLong(),
|
||||
sha = "",
|
||||
fileId = customFace.fileUuid,
|
||||
storeId = 0,
|
||||
)
|
||||
)
|
||||
|
||||
val origUrl = customFace.origUrl!!
|
||||
@ -148,7 +156,15 @@ internal object ElemConverter {
|
||||
val md5 = notOnlineImage.picMd5.toHexString()
|
||||
|
||||
ImageDB.getInstance().imageMappingDao().insert(
|
||||
ImageMapping(md5.uppercase(), chatType, notOnlineImage.fileLen!!.toLong())
|
||||
ImageMapping(
|
||||
fileName = md5.uppercase(),
|
||||
md5 = md5.uppercase(),
|
||||
chatType = chatType,
|
||||
size = notOnlineImage.fileLen!!.toLong(),
|
||||
sha = "",
|
||||
fileId = notOnlineImage.fileUuid,
|
||||
storeId = 0,
|
||||
)
|
||||
)
|
||||
|
||||
val origUrl = notOnlineImage.origUrl!!
|
||||
|
@ -157,8 +157,21 @@ internal object NtMsgElementConverter {
|
||||
.replace("-", "").split(".")[0])
|
||||
.uppercase()
|
||||
|
||||
var storeId = 0
|
||||
if (PlatformUtils.getQQVersionCode() > QQ_9_0_8_VER) {
|
||||
storeId = image.storeID
|
||||
}
|
||||
|
||||
ImageDB.getInstance().imageMappingDao().insert(
|
||||
ImageMapping(md5, chatType, image.fileSize)
|
||||
ImageMapping(
|
||||
fileName = md5,
|
||||
md5 = md5,
|
||||
chatType = chatType,
|
||||
size = image.fileSize,
|
||||
sha = "",
|
||||
fileId = image.fileUuid,
|
||||
storeId = storeId,
|
||||
)
|
||||
)
|
||||
|
||||
//LogCenter.log(image.toString())
|
||||
@ -166,11 +179,6 @@ 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
|
||||
}
|
||||
|
||||
/*
|
||||
PicElement{picSubType=0,fileName=A655FCDADABC40D0CEAF6F9AF92937CD.jpg,fileSize=142865,picWidth=886,picHeight=1920,original=false,md5HexStr=a655fcdadabc40d0ceaf6f9af92937cd,sourcePath=null,thumbPath=null,transferStatus=2,progress=0,picType=1000,invalidState=0,fileUuid=CgoxMDI5Mzc0MTE1EhTnucgrUbp3MJjjagUM2-VxSQ5V7hiR3Agg_goo9ZCZt-HNhANQgJqeAQ,fileSubId=,thumbFileSize=0,fileBizId=null,downloadIndex=null,summary=,emojiFrom=null,emojiWebUrl=null,emojiAd=EmojiAD{url=,desc=,},emojiMall=EmojiMall{packageId=0,emojiId=0,},emojiZplan=EmojiZPlan{actionId=0,actionName=,actionType=0,playerNumber=0,peerUid=0,bytesReserveInfo=,},originImageMd5=,originImageUrl=null,importRichMediaContext=null,isFlashPic=false,}
|
||||
*/
|
||||
|
@ -17,7 +17,12 @@ data class ImageMapping (
|
||||
@PrimaryKey
|
||||
val fileName: String,
|
||||
val chatType: Int,
|
||||
val size: Long
|
||||
val size: Long,
|
||||
|
||||
val md5: String,
|
||||
val sha: String,
|
||||
val fileId: String,
|
||||
val storeId: Int
|
||||
)
|
||||
|
||||
@Dao
|
||||
@ -34,7 +39,7 @@ internal abstract class ImageDB: RoomDatabase() {
|
||||
abstract fun imageMappingDao(): ImageMappingDao
|
||||
|
||||
companion object {
|
||||
private const val DB_NAME = "image_mapping.db"
|
||||
private const val DB_NAME = "image_mapping_v2.db"
|
||||
|
||||
@Volatile
|
||||
private var instance: ImageDB? = null
|
||||
|
@ -3,6 +3,7 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import com.tencent.qqnt.kernel.nativeinterface.MsgConstant
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import moe.fuqiuluo.qqinterface.servlet.TicketSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.transfile.RichProtoSvc
|
||||
import moe.fuqiuluo.shamrock.helper.db.ImageDB
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
@ -10,7 +11,7 @@ import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
import moe.fuqiuluo.shamrock.tools.EmptyJsonString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("get_image")
|
||||
@OneBotHandler("get_image", ["get_img"])
|
||||
internal object GetImage: IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
val echo = session.echo
|
||||
@ -35,8 +36,27 @@ internal object GetImage: IActionHandler() {
|
||||
image.size,
|
||||
image.fileName,
|
||||
when(image.chatType) {
|
||||
MsgConstant.KCHATTYPEGROUP -> RichProtoSvc.getGroupPicDownUrl("", fileMd5)
|
||||
MsgConstant.KCHATTYPEC2C -> RichProtoSvc.getC2CPicDownUrl("", fileMd5)
|
||||
MsgConstant.KCHATTYPEGROUP -> RichProtoSvc.getGroupPicDownUrl(
|
||||
originalUrl = "",
|
||||
md5 = fileMd5,
|
||||
fileSize = image.size.toULong(),
|
||||
sha = "",
|
||||
fileId = image.fileId,
|
||||
width = 100u,
|
||||
height = 100u,
|
||||
peer = TicketSvc.getUin()
|
||||
)
|
||||
MsgConstant.KCHATTYPEC2C -> RichProtoSvc.getC2CPicDownUrl(
|
||||
originalUrl = "",
|
||||
md5 = fileMd5,
|
||||
fileSize = image.size.toULong(),
|
||||
sha = "",
|
||||
fileId = image.fileId,
|
||||
storeId = image.storeId,
|
||||
width = 100u,
|
||||
height = 100u,
|
||||
peer = TicketSvc.getUin()
|
||||
)
|
||||
else -> error("Not supported chat type: ${image.chatType}, convertMsgElementsToMsgSegment::Pic")
|
||||
}
|
||||
), echo = echo)
|
||||
|
Loading…
x
Reference in New Issue
Block a user