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