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

Commit

Permalink
refactor: 优化&清理代码
Browse files Browse the repository at this point in the history
  • Loading branch information
ForteScarlet committed Oct 30, 2022
1 parent d3c0123 commit 153c815
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ public abstract class MiraiMessageContent : MessageContent {
public data class MiraiListMessageContent(val list: List<MiraiMessageContent>) : MiraiMessageContent() {
override suspend fun getMessage(contact: Contact): Message {
return when {
list.isEmpty() -> EmptyMessageChain
list.isEmpty() -> emptyMessageChain()
list.size == 1 -> list[0].getMessage(contact)
list.size == 2 -> list.first().getMessage(contact) + list.last().getMessage(contact)
else -> list.map { it.getMessage(contact) }
.asSequence()
.filter { it.isNotEmptyMsg() }
.reduceOrNull { m1, m2 -> m1 + m2 } ?: EmptyMessageChain
.reduceOrNull { m1, m2 -> m1 + m2 } ?: emptyMessageChain()
}

}
Expand Down Expand Up @@ -392,10 +392,9 @@ constructor(
@Deprecated("Use MiraiAudioMessageContent", replaceWith = ReplaceWith("MiraiAudioMessageContent"))
public class MiraiVoiceMessageContent(
override val neko: Neko,
@Suppress("DEPRECATION") private val voiceFunction: suspend (Contact) -> Audio,
private val voiceFunction: suspend (Contact) -> Audio,
) : MiraiMessageContent(), NekoAble {

@Suppress("DEPRECATION")
@Volatile
private lateinit var voice: Audio

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import love.forte.simbot.api.message.results.Result
/**
* [Sender] 的 无效化实现,所有的方法均会抛出异常。
*/
@Suppress("DEPRECATION", "OverridingDeprecatedMember")
@Suppress("OverridingDeprecatedMember")
object ErrorSender : Sender.Def {
override suspend fun groupMsg(
parent: String?,
Expand All @@ -45,6 +45,7 @@ object ErrorSender : Sender.Def {
): Nothing =
NO("Sender.sendGroupNotice")

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import java.nio.file.Path
import java.util.*
import kotlin.concurrent.thread
import kotlin.io.path.*
import kotlin.time.Duration
import kotlin.time.Duration.Companion.days
import kotlin.time.Duration.Companion.milliseconds
import kotlin.time.ExperimentalTime


Expand Down Expand Up @@ -478,7 +479,6 @@ protected constructor(
): SimbotContext {

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

val lastMod = local.getLastModifiedTime().toMillis()
if (Duration.milliseconds(System.currentTimeMillis() - lastMod) > Duration.days(7)) {
if ((System.currentTimeMillis() - lastMod).milliseconds > 7.days) {
local.deleteIfExists()
}

Expand Down

0 comments on commit 153c815

Please sign in to comment.