Shamrock: Change the image upload source to a camera

This commit is contained in:
白池 2024-02-16 09:50:31 +08:00
parent 58413044e9
commit 36f8b6e54b
3 changed files with 26 additions and 6 deletions

View File

@ -205,8 +205,8 @@ internal object MsgSvc: BaseSvc() {
}
}
val result = MessageHelper.sendMessageWithoutMsgId(chatType, peedId, message, fromId, MessageCallback(peedId, 0))
result.onFailure {
LogCenter.log("sendToAio: " + it.stackTraceToString(), Level.ERROR)
if (result.isFailure) {
LogCenter.log("sendToAio: " + result.exceptionOrNull()?.stackTraceToString(), Level.ERROR)
return result
}
val sendResult = result.getOrThrow()

View File

@ -6,6 +6,7 @@ import com.tencent.mobileqq.transfile.TransferRequest
import moe.fuqiuluo.shamrock.utils.MD5
import java.io.File
import moe.fuqiuluo.qqinterface.servlet.transfile.ResourceType.*
import moe.fuqiuluo.shamrock.helper.TransfileHelper
internal object Transfer: FileTransfer() {
private val ROUTE = mapOf<ContactType, Map<ResourceType, suspend TransTarget.(Resource) -> Boolean>>(
@ -84,11 +85,14 @@ internal object Transfer: FileTransfer() {
file: File,
wait: Boolean = true
): Boolean {
return transC2CResource(peerId, file, FileMsg.TRANSFILE_TYPE_PIC, SEND_MSG_BUSINESS_TYPE_PIC_SHARE, wait) {
return transC2CResource(peerId, file, FileMsg.TRANSFILE_TYPE_PIC, SEND_MSG_BUSINESS_TYPE_PIC_CAMERA, wait) {
val picUpExtraInfo = TransferRequest.PicUpExtraInfo()
picUpExtraInfo.mIsRaw = true
picUpExtraInfo.mIsRaw = false
picUpExtraInfo.mUinType = FileMsg.UIN_BUDDY
it.mPicSendSource = 8
it.mExtraObj = picUpExtraInfo
it.mIsPresend = true
it.delayShowProgressTimeInMs = 2000
}
}
@ -97,10 +101,13 @@ internal object Transfer: FileTransfer() {
file: File,
wait: Boolean = true
): Boolean {
return transTroopResource(groupId, file, FileMsg.TRANSFILE_TYPE_PIC, SEND_MSG_BUSINESS_TYPE_PIC_SHARE, wait) {
return transTroopResource(groupId, file, FileMsg.TRANSFILE_TYPE_PIC, SEND_MSG_BUSINESS_TYPE_PIC_CAMERA, wait) {
val picUpExtraInfo = TransferRequest.PicUpExtraInfo()
picUpExtraInfo.mIsRaw = true
//picUpExtraInfo.mIsRaw = !TransfileHelper.isGifFile(file)
picUpExtraInfo.mIsRaw = false
picUpExtraInfo.mUinType = FileMsg.UIN_TROOP
it.mPicSendSource = 8
it.delayShowProgressTimeInMs = 2000
it.mExtraObj = picUpExtraInfo
}
}

View File

@ -1,6 +1,8 @@
package moe.fuqiuluo.shamrock.helper
import java.io.File
import java.io.IOException
import java.io.RandomAccessFile
internal object TransfileHelper {
private val extensionMap = mapOf(
@ -94,4 +96,15 @@ internal object TransfileHelper {
val extension = name.substring(index)
return extensionMap[extension] ?: -1
}
fun isGifFile(picFile: File): Boolean {
if (picFile.exists() && picFile.length() > 3) {
return RandomAccessFile(picFile, "r").use {
val bArr = ByteArray(3)
it.read(bArr)
if (bArr[0].toInt() == 71 && bArr[1].toInt() == 73 && bArr[2].toInt() == 70) { return true } else false
}
}
return false
}
}