mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-13 14:50:43 +08:00
[core] Code style & comments update
This commit is contained in:
parent
8d9c820a92
commit
b8321870aa
@ -62,7 +62,7 @@ internal class RoamingMessagesImplGroup(
|
||||
resp.msgElem.asSequence()
|
||||
.filter { lastOfferedSeq == -1 || it.msgHead.msgSeq < lastOfferedSeq }
|
||||
.filter { it.time in timeStart..timeEnd }
|
||||
.sortedByDescending { it.msgHead.msgSeq } // Ensure caller receiver newer messages first
|
||||
.sortedByDescending { it.msgHead.msgSeq } // Ensure caller receives newer messages first
|
||||
.filter { filter.apply(it) } // Call filter after sort
|
||||
.asFlow()
|
||||
.map { listOf(it).toMessageChainOnline(bot, contact.id, MessageSourceKind.GROUP) }
|
||||
|
@ -71,6 +71,7 @@ internal class GeneralMessageSenderProtocol : MessageProtocol(PRIORITY_GENERAL_S
|
||||
fragmented = step == SendMessageStep.FRAGMENTED || currentMessageChain.contains(ForceAsFragmentedMessage)
|
||||
) { source = it }
|
||||
|
||||
// Patch time to be actual server time
|
||||
var finalTime = bot.clock.server.currentTimeSeconds().toInt()
|
||||
val sendPacketOk = sendAllPackets(bot, step, contact, packets) { idx, rsp ->
|
||||
if (rsp is MessageSvcPbSendMsg.Response.SUCCESS) {
|
||||
@ -102,8 +103,7 @@ internal class GeneralMessageSenderProtocol : MessageProtocol(PRIORITY_GENERAL_S
|
||||
packets.forEachIndexed { index, packet ->
|
||||
if (!sendSinglePacket(
|
||||
bot, packet, step, contact,
|
||||
index, packetResponseConsumer
|
||||
)
|
||||
) { packetResponseConsumer(index, it) }
|
||||
) return@sendAllPackets false
|
||||
}
|
||||
|
||||
@ -115,15 +115,14 @@ internal class GeneralMessageSenderProtocol : MessageProtocol(PRIORITY_GENERAL_S
|
||||
packet: OutgoingPacket,
|
||||
step: SendMessageStep,
|
||||
contact: Contact,
|
||||
index: Int,
|
||||
packetResponseConsumer: (Int, MessageSvcPbSendMsg.Response) -> Unit,
|
||||
packetResponseConsumer: (MessageSvcPbSendMsg.Response) -> Unit,
|
||||
): Boolean {
|
||||
val originalMessage = attributes[ORIGINAL_MESSAGE]
|
||||
val protocolStrategy = components[MessageProtocolStrategy]
|
||||
val finalMessage = currentMessageChain
|
||||
|
||||
val resp = protocolStrategy.sendPacket(bot, packet) as MessageSvcPbSendMsg.Response
|
||||
packetResponseConsumer(index, resp)
|
||||
packetResponseConsumer(resp)
|
||||
if (resp is MessageSvcPbSendMsg.Response.MessageTooLarge) {
|
||||
logger.info { "STEP $step: message too large." }
|
||||
val next = step.nextStepOrNull()
|
||||
|
@ -157,22 +157,20 @@ internal class QuoteReplyProtocol : MessageProtocol(PRIORITY_METADATA) {
|
||||
markAsConsumed()
|
||||
collect(ImMsgBody.Elem(srcMsg = source.toJceData()))
|
||||
if (sourceCommon.kind == MessageSourceKind.GROUP) {
|
||||
|
||||
@Suppress("RemoveExplicitTypeArguments")
|
||||
val needPlusAt = sequence<Boolean> {
|
||||
fun isPlusNeed(): Boolean {
|
||||
if (source is OnlineMessageSource.Incoming.FromGroup) {
|
||||
try {
|
||||
val sender0 = source.sender
|
||||
yield(sender0 !is AnonymousMember)
|
||||
return sender0 !is AnonymousMember
|
||||
} catch (_: IllegalStateException) {
|
||||
// Member not available now
|
||||
}
|
||||
}
|
||||
|
||||
yield(sourceCommon.fromId != 80000000L)
|
||||
return sourceCommon.fromId != 80000000L // #2501
|
||||
}
|
||||
|
||||
if (needPlusAt.first()) {
|
||||
if (isPlusNeed()) {
|
||||
processAlso(At(sourceCommon.fromId))
|
||||
|
||||
// transformOneMessage(PlainText(" "))
|
||||
|
Loading…
Reference in New Issue
Block a user