diff --git a/.changelog/v0.9.1.md b/.changelog/v0.9.1.md new file mode 100644 index 0000000..2529b95 --- /dev/null +++ b/.changelog/v0.9.1.md @@ -0,0 +1,7 @@ +> 对应核心版本: [**v4.0.1**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.1) + + +我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-onebot/issues)或[协助](https://github.com/simple-robot/simbot-component-onebot/pulls), +感谢您的贡献与支持! + +也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可! diff --git a/buildSrc/src/main/kotlin/P.kt b/buildSrc/src/main/kotlin/P.kt index e466c04..39f7913 100644 --- a/buildSrc/src/main/kotlin/P.kt +++ b/buildSrc/src/main/kotlin/P.kt @@ -41,7 +41,7 @@ object P { override val homepage: String get() = HOMEPAGE - private val baseVersion = v(0, 9, 0) + private val baseVersion = v(0, 9, 1) val snapshotVersion = baseVersion - Version.SNAPSHOT override val version = if (isSnapshot()) snapshotVersion else baseVersion diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt index d3901ae..131ffe0 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/OneBotBot.kt @@ -57,6 +57,11 @@ import kotlin.jvm.JvmSynthetic * 且在重新连接的过程中始终失败并达到了重试次数上限,此时会话中的任务会被视为因异常结束, * 并连带 [OneBotBot] 的任务一同终结。 * + * ### 日志 + * + * [OneBotBot] 的内部会输出三种日志: + * - `love.forte.simbot.component.onebot.v11.core.bot.OneBotBot.$uniqueId` + * bot的基本日志,例如连接信息、接收到的原始事件等debug日志。 * * @author ForteScarlet */ diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt index f8e86ff..cf401e8 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/commonMain/kotlin/love/forte/simbot/component/onebot/v11/core/bot/internal/OneBotBotImpl.kt @@ -102,6 +102,11 @@ internal class OneBotBotImpl( private val eventProcessor: EventProcessor, baseDecoderJson: Json, ) : OneBotBot, JobBasedBot() { + companion object { + private const val BASE_LOGGER_NAME = + "love.forte.simbot.component.onebot.v11.core.bot.OneBotBot" + } + override val subContext = coroutineContext.minusKey(Job) override val decoderJson: Json = Json(baseDecoderJson) { configuration.serializersModule?.also { confMd -> @@ -109,10 +114,7 @@ internal class OneBotBotImpl( } } - internal val logger = LoggerFactory - .getLogger( - "love.forte.simbot.component.onebot.v11.core.bot.OneBotBot.$uniqueId" - ) + internal val logger = LoggerFactory.getLogger("$BASE_LOGGER_NAME.$uniqueId") private val eventServerHost = configuration.eventServerHost private val connectMaxRetryTimes = configuration.wsConnectMaxRetryTimes @@ -319,14 +321,14 @@ internal class OneBotBotImpl( while (session == null && retryTimes <= connectMaxRetryTimes) { try { - logger.debug("Connect to ws server {}", eventServerHost) + logger.debug("Connect to ws server {}", wsHost) session = createSession() } catch (e: Exception) { retryTimes++ @Suppress("ConvertTwoComparisonsToRangeCheck") if (connectMaxRetryTimes > 0 && retryTimes > connectMaxRetryTimes) { - "Connect to ws server $eventServerHost failed in $retryTimes times.".also { msg -> + "Connect to ws server $wsHost failed in $retryTimes times.".also { msg -> val ex = IllegalStateException(msg) sessionJob.completeExceptionally(ex) @@ -337,7 +339,7 @@ internal class OneBotBotImpl( if (logger.isWarnEnabled()) { logger.warn( "Connect to ws server {} failed: {}, retry in {}...", - eventServerHost, + wsHost, e.message, connectRetryDelay.toString(), e, @@ -384,7 +386,7 @@ internal class OneBotBotImpl( if (currentSession == null) return - logger.debug("Connected to ws server {}, session: {}", eventServerHost, currentSession) + logger.debug("Connected to ws server {}, session: {}", wsHost, currentSession) this@WsEventSession.session = currentSession diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.jvm.kt b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.jvm.kt index 17be698..c4d43a0 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.jvm.kt +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmMain/kotlin/love/forte/simbot/component/onebot/v11/core/api/OneBotApiRequests.jvm.kt @@ -557,4 +557,4 @@ public fun OneBotApi.requestDataReserve( internal actual fun initConfig(key: String, default: String?): String? = - System.getProperty(key) + System.getProperty(key) ?: default diff --git a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/resources/log4j2.xml b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/resources/log4j2.xml index b3ce07d..797f27f 100644 --- a/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/resources/log4j2.xml +++ b/simbot-component-onebot-v11/simbot-component-onebot-v11-core/src/jvmTest/resources/log4j2.xml @@ -9,6 +9,9 @@ + + +