File tree Expand file tree Collapse file tree
commonMain/kotlin/org/ntqqrev/acidify/message
jsMain/kotlin/org/ntqqrev/acidify/js
acidify-milky/src/commonMain/kotlin/org/ntqqrev/acidify/milky/transform Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import org.ntqqrev.acidify.common.AcidifyDsl
88import org.ntqqrev.acidify.common.MediaSource
99import org.ntqqrev.acidify.common.MediaSource.Companion.toMediaSource
1010import kotlin.js.JsName
11+ import kotlin.time.Clock
1112
1213/* *
1314 * 构建发送消息
@@ -175,11 +176,13 @@ class BotOutgoingMessageBuilder {
175176 * 添加一个伪造合并转发消息
176177 * @param senderUin 该消息的发送者 QQ 号
177178 * @param senderName 该消息的发送者昵称
179+ * @param timestamp 该消息的 Unix 事件戳(秒)
178180 * @param block 构建该消息的内容
179181 */
180182 inline fun node (
181183 senderUin : Long ,
182184 senderName : String ,
185+ timestamp : Long = Clock .System .now().epochSeconds,
183186 block : BotOutgoingMessageBuilder .() -> Unit
184187 ) {
185188 val messageBuilder = BotOutgoingMessageBuilder ()
@@ -188,7 +191,8 @@ class BotOutgoingMessageBuilder {
188191 BotOutgoingSegment .Forward .Node (
189192 senderUin,
190193 senderName,
191- messageBuilder.segments
194+ messageBuilder.segments,
195+ timestamp,
192196 )
193197 )
194198 }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import org.ntqqrev.acidify.common.MediaSource
44import org.ntqqrev.acidify.common.MediaSource.Companion.toMediaSource
55import kotlin.js.JsExport
66import kotlin.js.JsName
7+ import kotlin.time.Clock
78
89/* *
910 * 发送消息段
@@ -185,11 +186,13 @@ sealed class BotOutgoingSegment {
185186 * @property senderUin 发送者 QQ 号
186187 * @property senderName 发送者名称
187188 * @property segments 消息内容
189+ * @property timestamp 消息的 Unix 事件戳(秒)
188190 */
189191 data class Node (
190192 val senderUin : Long ,
191193 val senderName : String ,
192194 val segments : List <BotOutgoingSegment >,
195+ val timestamp : Long = Clock .System .now().epochSeconds,
193196 )
194197 }
195198
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ import org.ntqqrev.acidify.internal.util.pbEncode
2929import org.ntqqrev.acidify.message.BotOutgoingSegment
3030import org.ntqqrev.acidify.message.MessageScene
3131import kotlin.random.Random
32- import kotlin.time.Clock
3332
3433internal class MessageBuildingContext (
3534 val bot : AbstractBot ,
@@ -556,7 +555,7 @@ internal class MessageBuildingContext(
556555 },
557556 random = Random .nextInt(),
558557 sequence = fakeSequence,
559- time = Clock . System .now().epochSeconds ,
558+ time = timestamp ,
560559 clientSequence = fakeSequence,
561560 msgUid = Random .nextLong(1000000000000 , 9999999999999 ),
562561 forwardExt = ContentHead .Forward (
Original file line number Diff line number Diff line change 11package org.ntqqrev.acidify.js
22
33import org.ntqqrev.acidify.message.BotOutgoingMessageBuilder
4+ import kotlin.time.Clock
45
56@JsExport
67@JsName(" BotForwardBlockBuilder" )
@@ -11,11 +12,13 @@ class JsBotForwardBlockBuilder internal constructor(
1112 fun node (
1213 senderUin : Long ,
1314 senderName : String ,
14- block : (JsBotOutgoingMessageBuilder ) -> Unit
15+ block : (JsBotOutgoingMessageBuilder ) -> Unit ,
16+ timestamp : Long = Clock .System .now().epochSeconds
1517 ) {
1618 underlying.node(
1719 senderUin,
18- senderName
20+ senderName,
21+ timestamp,
1922 ) {
2023 val b = JsBotOutgoingMessageBuilder (this )
2124 block(b)
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ import org.ntqqrev.acidify.milky.MediaSourceScope
1414import org.ntqqrev.acidify.milky.MilkyContext
1515import org.ntqqrev.acidify.milky.tracked
1616import org.ntqqrev.milky.*
17+ import kotlin.time.Clock
1718
1819suspend fun MilkyContext.transformIncomingMessage (msg : BotIncomingMessage ): IncomingMessage ? {
1920 val bot = application.dependencies.resolve<AbstractBot >()
@@ -282,7 +283,8 @@ suspend fun MilkyContext.transformOutgoingSegment(
282283 senderName = msg.senderName,
283284 segments = msg.segments.map { seg ->
284285 async { transformOutgoingSegment(scene, peerUin, seg) }
285- }.awaitAll()
286+ }.awaitAll(),
287+ timestamp = msg.time ? : Clock .System .now().epochSeconds,
286288 )
287289 }
288290 BotOutgoingSegment .Forward (
You can’t perform that action at this time.
0 commit comments