mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: Change the image upload source to a camera
This commit is contained in:
parent
58413044e9
commit
36f8b6e54b
@ -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()
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user