Skip to content

Commit

Permalink
Merge pull request #63 from simple-robot/dev/main
Browse files Browse the repository at this point in the history
Release: v0.9.1
  • Loading branch information
ForteScarlet authored Jun 23, 2024
2 parents 77c75dd + 3778a16 commit a5bee97
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .changelog/v0.9.1.md
Original file line number Diff line number Diff line change
@@ -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`,这是对我们最大的鼓励与认可!
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ import kotlin.jvm.JvmSynthetic
* 且在重新连接的过程中始终失败并达到了重试次数上限,此时会话中的任务会被视为因异常结束,
* 并连带 [OneBotBot] 的任务一同终结。
*
* ### 日志
*
* [OneBotBot] 的内部会输出三种日志:
* - `love.forte.simbot.component.onebot.v11.core.bot.OneBotBot.$uniqueId`
* bot的基本日志,例如连接信息、接收到的原始事件等debug日志。
*
* @author ForteScarlet
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,19 @@ 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 ->
serializersModule = serializersModule overwriteWith confMd
}
}

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
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,4 +557,4 @@ public fun <T : Any> OneBotApi<T>.requestDataReserve(


internal actual fun initConfig(key: String, default: String?): String? =
System.getProperty(key)
System.getProperty(key) ?: default
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<Logger name="love.forte.simbot.component.onebot" level="debug" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Logger name="io.ktor.client" level="debug" additivity="false">
<AppenderRef ref="Console"/>
</Logger>
<Root level="error">
<AppenderRef ref="Console"/>
</Root>
Expand Down

0 comments on commit a5bee97

Please sign in to comment.