mirror of
https://github.com/mamoe/mirai.git
synced 2024-12-31 05:34:43 +08:00
Change currentTimeSeconds from property to function
This commit is contained in:
parent
360df3e011
commit
db100d336f
@ -196,7 +196,7 @@ public fun Iterable<MessageEvent>.toForwardMessage(displayStrategy: DisplayStrat
|
||||
@JvmOverloads
|
||||
public fun Message.toForwardMessage(
|
||||
sender: User,
|
||||
time: Int = currentTimeSeconds.toInt(),
|
||||
time: Int = currentTimeSeconds().toInt(),
|
||||
displayStrategy: DisplayStrategy = DisplayStrategy
|
||||
): ForwardMessage = this.toForwardMessage(sender.id, sender.nameCardOrNick, time, displayStrategy)
|
||||
|
||||
@ -207,7 +207,7 @@ public fun Message.toForwardMessage(
|
||||
public fun Message.toForwardMessage(
|
||||
senderId: Long,
|
||||
senderName: String,
|
||||
time: Int = currentTimeSeconds.toInt(),
|
||||
time: Int = currentTimeSeconds().toInt(),
|
||||
displayStrategy: DisplayStrategy = DisplayStrategy
|
||||
): ForwardMessage =
|
||||
RawForwardMessage(listOf(ForwardMessage.Node(senderId, time, senderName, this))).render(displayStrategy)
|
||||
@ -331,7 +331,7 @@ public class ForwardMessageBuilder private constructor(
|
||||
* 当前时间.
|
||||
* 在使用 [says] 时若不指定时间, 则会使用 [currentTime] 自增 1 的时间.
|
||||
*/
|
||||
public var currentTime: Int = currentTimeSeconds.toInt()
|
||||
public var currentTime: Int = currentTimeSeconds().toInt()
|
||||
|
||||
public inner class BuilderNode : ForwardMessage.INode {
|
||||
|
||||
|
@ -137,7 +137,7 @@ public abstract class MessageSourceBuilder {
|
||||
internal val originalMessages: MessageChainBuilder = MessageChainBuilder()
|
||||
|
||||
public fun time(from: MessageSource): MessageSourceBuilder = apply { this.time = from.time }
|
||||
public val now: Int get() = currentTimeSeconds.toInt()
|
||||
public val now: Int get() = currentTimeSeconds().toInt()
|
||||
public fun time(value: Int): MessageSourceBuilder = apply { this.time = value }
|
||||
|
||||
public fun internalId(from: MessageSource): MessageSourceBuilder = apply { this.internalIds = from.internalIds }
|
||||
@ -218,7 +218,7 @@ internal class MessageSourceBuilderImpl : MessageSourceBuilder() {
|
||||
override var targetUin: Long = 0
|
||||
|
||||
override var ids: IntArray = intArrayOf()
|
||||
override var time: Int = currentTimeSeconds.toInt()
|
||||
override var time: Int = currentTimeSeconds().toInt()
|
||||
override var internalIds: IntArray = intArrayOf()
|
||||
|
||||
@JvmSynthetic
|
||||
|
@ -19,12 +19,15 @@ import kotlin.time.ExperimentalTime
|
||||
|
||||
/**
|
||||
* 时间戳
|
||||
*
|
||||
* @see System.currentTimeMillis
|
||||
*/
|
||||
public fun currentTimeMillis(): Long = System.currentTimeMillis()
|
||||
|
||||
@get:JvmSynthetic
|
||||
public inline val currentTimeSeconds: Long
|
||||
get() = currentTimeMillis() / 1000
|
||||
/**
|
||||
* 时间戳到秒
|
||||
*/
|
||||
public fun currentTimeSeconds(): Long = currentTimeMillis() / 1000
|
||||
|
||||
|
||||
// 临时使用, 待 Kotlin Duration 稳定后使用 Duration.
|
||||
|
@ -564,7 +564,7 @@ internal open class MiraiImpl : IMirai, LowLevelApiAccessor {
|
||||
|
||||
val group = getGroup(groupCode)
|
||||
|
||||
val time = currentTimeSeconds
|
||||
val time = currentTimeSeconds()
|
||||
val sequenceId = client.atomicNextMessageSequenceId()
|
||||
|
||||
network.run {
|
||||
|
@ -323,7 +323,7 @@ internal class GroupImpl(
|
||||
listOf(
|
||||
ForwardMessage.Node(
|
||||
senderId = bot.id,
|
||||
time = currentTimeSeconds.toInt(),
|
||||
time = currentTimeSeconds().toInt(),
|
||||
message = chain,
|
||||
senderName = bot.nick
|
||||
)
|
||||
|
@ -136,7 +136,7 @@ internal class MemberImpl constructor(
|
||||
get() = if (_muteTimestamp == 0 || _muteTimestamp == 0xFFFFFFFF.toInt()) {
|
||||
0
|
||||
} else {
|
||||
(_muteTimestamp - currentTimeSeconds.toInt()).coerceAtLeast(0)
|
||||
(_muteTimestamp - currentTimeSeconds().toInt()).coerceAtLeast(0)
|
||||
}
|
||||
|
||||
override var nameCard: String
|
||||
|
@ -13,7 +13,6 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import net.mamoe.mirai.internal.utils.io.ProtoBuf
|
||||
import net.mamoe.mirai.utils.currentTimeSeconds
|
||||
import kotlin.jvm.JvmField
|
||||
|
||||
internal interface ImgReq : ProtoBuf
|
||||
|
||||
@ -37,6 +36,6 @@ internal class GetImgUrlReq(
|
||||
@ProtoNumber(11) @JvmField val addressBook: Int = 0,//[ChatType.internalID]== 1006为1[为CONTACT时] 我觉得发0没问题
|
||||
@ProtoNumber(12) @JvmField val buType: Int = 1,//确定
|
||||
@ProtoNumber(13) @JvmField val buildVer: String = "8.2.7.4410",//版本号
|
||||
@ProtoNumber(14) @JvmField val timestamp: Int = currentTimeSeconds.toInt(),//(pic_up_timestamp)
|
||||
@ProtoNumber(14) @JvmField val timestamp: Int = currentTimeSeconds().toInt(),//(pic_up_timestamp)
|
||||
@ProtoNumber(15) @JvmField val requestTransferType: Int = 1
|
||||
) : ImgReq
|
@ -189,7 +189,7 @@ internal inline fun MessageSvcPbSendMsg.createToTemp(
|
||||
internalIds = intArrayOf(Random.nextInt().absoluteValue),
|
||||
sender = client.bot,
|
||||
target = member,
|
||||
time = currentTimeSeconds.toInt(),
|
||||
time = currentTimeSeconds().toInt(),
|
||||
sequenceIds = intArrayOf(client.atomicNextMessageSequenceId()),
|
||||
originalMessage = message
|
||||
)
|
||||
@ -217,7 +217,7 @@ internal inline fun MessageSvcPbSendMsg.createToFriend(
|
||||
internalIds = intArrayOf(rand),
|
||||
sender = client.bot,
|
||||
target = qq,
|
||||
time = currentTimeSeconds.toInt(),
|
||||
time = currentTimeSeconds().toInt(),
|
||||
sequenceIds = intArrayOf(client.nextFriendSeq()),
|
||||
originalMessage = message
|
||||
)
|
||||
@ -245,7 +245,7 @@ internal inline fun MessageSvcPbSendMsg.createToGroup(
|
||||
internalIds = intArrayOf(Random.nextInt().absoluteValue),
|
||||
sender = client.bot,
|
||||
target = group,
|
||||
time = currentTimeSeconds.toInt(),
|
||||
time = currentTimeSeconds().toInt(),
|
||||
originalMessage = message//,
|
||||
// sourceMessage = message
|
||||
)
|
||||
|
@ -207,7 +207,7 @@ private object Transformers732 : Map<Int, Lambda732> by mapOf(
|
||||
}
|
||||
else -> {
|
||||
group.botAsMember.checkIsMemberImpl()._muteTimestamp =
|
||||
currentTimeSeconds.toInt() + timeSeconds
|
||||
currentTimeSeconds().toInt() + timeSeconds
|
||||
sequenceOf(BotMuteEvent(timeSeconds, operator))
|
||||
}
|
||||
}
|
||||
@ -220,7 +220,7 @@ private object Transformers732 : Map<Int, Lambda732> by mapOf(
|
||||
return@lambda732 emptySequence()
|
||||
}
|
||||
|
||||
member._muteTimestamp = currentTimeSeconds.toInt() + timeSeconds
|
||||
member._muteTimestamp = currentTimeSeconds().toInt() + timeSeconds
|
||||
return@lambda732 if (timeSeconds == 0) sequenceOf(MemberUnmuteEvent(member, operator))
|
||||
else sequenceOf(MemberMuteEvent(member, timeSeconds, operator))
|
||||
},
|
||||
|
@ -516,7 +516,7 @@ internal class WtLogin {
|
||||
|
||||
// TODO sigMap??? =0x21410e0 // from qq
|
||||
|
||||
val creationTime = currentTimeSeconds
|
||||
val creationTime = currentTimeSeconds()
|
||||
val expireTime = creationTime + 2160000L
|
||||
|
||||
val outPSKeyMap: PSKeyMap = mutableMapOf()
|
||||
@ -689,7 +689,7 @@ internal class WtLogin {
|
||||
*/
|
||||
private fun QQAndroidClient.analysisTlv130(t130: ByteArray) = t130.read {
|
||||
discardExact(2)
|
||||
timeDifference = readUInt().toLong() - currentTimeSeconds
|
||||
timeDifference = readUInt().toLong() - currentTimeSeconds()
|
||||
ipFromT149 = readBytes(4)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user