From 401634eb247052b510204a113f69dbe28e5e72fa Mon Sep 17 00:00:00 2001 From: Him188 Date: Sat, 14 Dec 2019 22:35:55 +0800 Subject: [PATCH] Add a configuration `logPreviousMessages` --- .../network/protocol/tim/TIMBotNetworkHandler.kt | 4 +++- .../kotlin/net.mamoe.mirai/utils/BotConfiguration.kt | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt index cce7597ab..682b8397d 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/network/protocol/tim/TIMBotNetworkHandler.kt @@ -226,7 +226,9 @@ internal class TIMBotNetworkHandler internal constructor(coroutineContext: Corou return if (!packet::class.annotations.filterIsInstance().any()) { - bot.logger.verbose("Packet received: $packet") + if ((packet as? BroadcastControllable)?.shouldBroadcast != false) { + bot.logger.verbose("Packet received: $packet") + } } when (packet) { diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt index af3cbfc64..cbddc629a 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/BotConfiguration.kt @@ -62,6 +62,12 @@ class BotConfiguration : CoroutineContext.Element { * 验证码处理器 */ var captchaSolver: CaptchaSolver = DefaultCaptchaSolver + /** + * 登录完成后几秒会收到好友消息的历史记录, + * 这些历史记录不会触发事件. + * 这个选项为是否把这些记录添加到日志 + */ + var logPreviousMessages: Boolean = false companion object Key : CoroutineContext.Key { /**