mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-04 07:30:15 +08:00
Fix voice transform
This commit is contained in:
parent
31a8932070
commit
d8228c523e
@ -283,7 +283,7 @@ internal class GroupImpl(
|
|||||||
response.fileKey,
|
response.fileKey,
|
||||||
)
|
)
|
||||||
Voice(
|
Voice(
|
||||||
"${resource.md5.toUHexString("")}.${resource.formatName}",
|
"${resource.md5.toUHexString("")}.amr",
|
||||||
resource.md5,
|
resource.md5,
|
||||||
resource.size,
|
resource.size,
|
||||||
resource.voiceCodec,
|
resource.voiceCodec,
|
||||||
|
@ -244,31 +244,14 @@ internal fun MsgComm.Msg.toMessageChain(
|
|||||||
groupIdOrZero: Long,
|
groupIdOrZero: Long,
|
||||||
onlineSource: Boolean,
|
onlineSource: Boolean,
|
||||||
isTemp: Boolean = false
|
isTemp: Boolean = false
|
||||||
): MessageChain = toMessageChain(bot, bot.id, groupIdOrZero, onlineSource, isTemp)
|
): MessageChain = listOf(this).toMessageChain(bot, bot.id, groupIdOrZero, onlineSource, isTemp)
|
||||||
|
|
||||||
internal fun List<MsgOnlinePush.PbPushMsg>.toMessageChain(
|
internal fun List<MsgOnlinePush.PbPushMsg>.toMessageChain(
|
||||||
bot: Bot,
|
bot: Bot,
|
||||||
groupIdOrZero: Long,
|
groupIdOrZero: Long,
|
||||||
onlineSource: Boolean,
|
onlineSource: Boolean,
|
||||||
isTemp: Boolean = false
|
isTemp: Boolean = false
|
||||||
): MessageChain = toMessageChain(bot, bot.id, groupIdOrZero, onlineSource, isTemp)
|
): MessageChain = map { it.msg }.toMessageChain(bot, bot.id, groupIdOrZero, onlineSource, isTemp)
|
||||||
|
|
||||||
@JvmName("toMessageChain1")
|
|
||||||
internal fun List<MsgOnlinePush.PbPushMsg>.toMessageChain(
|
|
||||||
bot: Bot?,
|
|
||||||
botId: Long,
|
|
||||||
groupIdOrZero: Long,
|
|
||||||
onlineSource: Boolean,
|
|
||||||
isTemp: Boolean = false
|
|
||||||
): MessageChain = map { it.msg }.toMessageChain(bot, botId, groupIdOrZero, onlineSource, isTemp)
|
|
||||||
|
|
||||||
internal fun MsgComm.Msg.toMessageChain(
|
|
||||||
bot: Bot?,
|
|
||||||
botId: Long,
|
|
||||||
groupIdOrZero: Long,
|
|
||||||
onlineSource: Boolean,
|
|
||||||
isTemp: Boolean = false
|
|
||||||
): MessageChain = listOf(this).toMessageChain(bot, botId, groupIdOrZero, onlineSource, isTemp)
|
|
||||||
|
|
||||||
internal fun List<MsgComm.Msg>.toMessageChain(
|
internal fun List<MsgComm.Msg>.toMessageChain(
|
||||||
bot: Bot?,
|
bot: Bot?,
|
||||||
@ -280,7 +263,7 @@ internal fun List<MsgComm.Msg>.toMessageChain(
|
|||||||
val elements = this.flatMap { it.msgBody.richText.elems }
|
val elements = this.flatMap { it.msgBody.richText.elems }
|
||||||
|
|
||||||
@OptIn(ExperimentalStdlibApi::class)
|
@OptIn(ExperimentalStdlibApi::class)
|
||||||
val ppts = buildList<Message> {
|
val ptts = buildList<Message> {
|
||||||
this@toMessageChain.forEach { msg ->
|
this@toMessageChain.forEach { msg ->
|
||||||
msg.msgBody.richText.ptt?.run {
|
msg.msgBody.richText.ptt?.run {
|
||||||
// when (fileType) {
|
// when (fileType) {
|
||||||
@ -291,7 +274,7 @@ internal fun List<MsgComm.Msg>.toMessageChain(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return buildMessageChain(elements.size + 1 + ppts.size) {
|
return buildMessageChain(elements.size + 1 + ptts.size) {
|
||||||
if (onlineSource) {
|
if (onlineSource) {
|
||||||
checkNotNull(bot) { "bot is null" }
|
checkNotNull(bot) { "bot is null" }
|
||||||
when {
|
when {
|
||||||
@ -303,7 +286,7 @@ internal fun List<MsgComm.Msg>.toMessageChain(
|
|||||||
+OfflineMessageSourceImplByMsg(this@toMessageChain, botId)
|
+OfflineMessageSourceImplByMsg(this@toMessageChain, botId)
|
||||||
}
|
}
|
||||||
elements.joinToMessageChain(groupIdOrZero, botId, this)
|
elements.joinToMessageChain(groupIdOrZero, botId, this)
|
||||||
addAll(ppts)
|
addAll(ptts)
|
||||||
}.cleanupRubbishMessageElements()
|
}.cleanupRubbishMessageElements()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ internal object MessageSvcPbSendMsg : OutgoingPacketFactory<MessageSvcPbSendMsg.
|
|||||||
msgBody = ImMsgBody.MsgBody(
|
msgBody = ImMsgBody.MsgBody(
|
||||||
richText = ImMsgBody.RichText(
|
richText = ImMsgBody.RichText(
|
||||||
elems = message.toRichTextElems(messageTarget = targetGroup, withGeneralFlags = true),
|
elems = message.toRichTextElems(messageTarget = targetGroup, withGeneralFlags = true),
|
||||||
ptt = message.get(PttMessage)?.run {
|
ptt = message[PttMessage]?.run {
|
||||||
ImMsgBody.Ptt(
|
ImMsgBody.Ptt(
|
||||||
fileName = fileName.toByteArray(),
|
fileName = fileName.toByteArray(),
|
||||||
fileMd5 = md5,
|
fileMd5 = md5,
|
||||||
|
@ -87,7 +87,7 @@ internal class PttStore {
|
|||||||
innerIp = 0,
|
innerIp = 0,
|
||||||
buildVer = "6.5.5.663".encodeToByteArray(),
|
buildVer = "6.5.5.663".encodeToByteArray(),
|
||||||
voiceLength = 1,
|
voiceLength = 1,
|
||||||
codec = resource.voiceCodec,
|
codec = 0, // don't use resource.codec
|
||||||
voiceType = 1,
|
voiceType = 1,
|
||||||
boolNewUpChan = true
|
boolNewUpChan = true
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user