Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.

Commit 153c815

Browse files
committed
refactor: 优化&清理代码
1 parent d3c0123 commit 153c815

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

component/component-mirai/src/main/java/love/forte/simbot/component/mirai/message/MiraiMessageContent.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ public abstract class MiraiMessageContent : MessageContent {
7878
public data class MiraiListMessageContent(val list: List<MiraiMessageContent>) : MiraiMessageContent() {
7979
override suspend fun getMessage(contact: Contact): Message {
8080
return when {
81-
list.isEmpty() -> EmptyMessageChain
81+
list.isEmpty() -> emptyMessageChain()
8282
list.size == 1 -> list[0].getMessage(contact)
8383
list.size == 2 -> list.first().getMessage(contact) + list.last().getMessage(contact)
8484
else -> list.map { it.getMessage(contact) }
8585
.asSequence()
8686
.filter { it.isNotEmptyMsg() }
87-
.reduceOrNull { m1, m2 -> m1 + m2 } ?: EmptyMessageChain
87+
.reduceOrNull { m1, m2 -> m1 + m2 } ?: emptyMessageChain()
8888
}
8989

9090
}
@@ -392,10 +392,9 @@ constructor(
392392
@Deprecated("Use MiraiAudioMessageContent", replaceWith = ReplaceWith("MiraiAudioMessageContent"))
393393
public class MiraiVoiceMessageContent(
394394
override val neko: Neko,
395-
@Suppress("DEPRECATION") private val voiceFunction: suspend (Contact) -> Audio,
395+
private val voiceFunction: suspend (Contact) -> Audio,
396396
) : MiraiMessageContent(), NekoAble {
397397

398-
@Suppress("DEPRECATION")
399398
@Volatile
400399
private lateinit var voice: Audio
401400

core-api/api/src/main/java/love/forte/simbot/api/sender/ErrorSender.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import love.forte.simbot.api.message.results.Result
2323
/**
2424
* [Sender] 的 无效化实现,所有的方法均会抛出异常。
2525
*/
26-
@Suppress("DEPRECATION", "OverridingDeprecatedMember")
26+
@Suppress("OverridingDeprecatedMember")
2727
object ErrorSender : Sender.Def {
2828
override suspend fun groupMsg(
2929
parent: String?,
@@ -45,6 +45,7 @@ object ErrorSender : Sender.Def {
4545
): Nothing =
4646
NO("Sender.sendGroupNotice")
4747

48+
@Deprecated("此方法未来将会被从标注接口中移除,且从2.3.0后、移除之前不会在进行维护。")
4849
override fun sendGroupSign(group: String, title: String, message: String): Nothing =
4950
NO("Sender.sendGroupSign")
5051

core-api/core/src/main/java/love/forte/simbot/core/SimbotApp.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ import java.nio.file.Path
5050
import java.util.*
5151
import kotlin.concurrent.thread
5252
import kotlin.io.path.*
53-
import kotlin.time.Duration
53+
import kotlin.time.Duration.Companion.days
54+
import kotlin.time.Duration.Companion.milliseconds
5455
import kotlin.time.ExperimentalTime
5556

5657

@@ -478,7 +479,6 @@ protected constructor(
478479
): SimbotContext {
479480

480481
// 资源配置数据,获取appType的注解。
481-
@Suppress("UNCHECKED_CAST")
482482
val resourceData: List<SimbotResourceData> =
483483
AnnotationUtil.getAnnotation(appType, SimbotApplication::class.java)?.value
484484
?.map {
@@ -661,7 +661,7 @@ private class Tips {
661661
}
662662

663663
val lastMod = local.getLastModifiedTime().toMillis()
664-
if (Duration.milliseconds(System.currentTimeMillis() - lastMod) > Duration.days(7)) {
664+
if ((System.currentTimeMillis() - lastMod).milliseconds > 7.days) {
665665
local.deleteIfExists()
666666
}
667667

0 commit comments

Comments
 (0)