From f1e6e2fbf53090289d1468c7cdcf24daf8ab21eb Mon Sep 17 00:00:00 2001 From: dongRogen <3601778801@qq.com> Date: Thu, 4 Aug 2022 10:01:51 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8E=E6=8C=81=E4=B9=85=E5=8C=96=E5=AF=B9?= =?UTF-8?q?=E8=B1=A1=20-=20=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=EF=BC=9A?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=97=B4=E9=9A=94=E3=80=81=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E6=8E=A8=E9=80=81bot=20-=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=95=B0=E6=8D=AE=EF=BC=9A=E8=AE=A2=E9=98=85=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=E3=80=81=E6=A8=A1=E7=BB=84=E6=9C=80=E6=96=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E7=9A=84id=E9=9B=86=E5=90=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/top/jie65535/jcf/PluginConfig.kt | 12 +++++++ .../kotlin/top/jie65535/jcf/PluginData.kt | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/main/kotlin/top/jie65535/jcf/PluginData.kt diff --git a/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt b/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt index de3aafe..cf2f418 100644 --- a/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt +++ b/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt @@ -20,4 +20,16 @@ object PluginConfig : AutoSavePluginConfig("JCurseforgeConfig") { MinecraftService.ModClass.CUSTOMIZATION to "cfcustom ", ) ) + + /** + * 订阅信息推送bot + */ + @ValueDescription("订阅信息推送bot(qq id)") + val subscribeSender: Long by value(-1L) + + /** + * 检查间隔 + */ + @ValueDescription("检查间隔(单位:秒)") + val checkInterval: Long by value(60 * 60 * 4L) } diff --git a/src/main/kotlin/top/jie65535/jcf/PluginData.kt b/src/main/kotlin/top/jie65535/jcf/PluginData.kt new file mode 100644 index 0000000..3082cef --- /dev/null +++ b/src/main/kotlin/top/jie65535/jcf/PluginData.kt @@ -0,0 +1,36 @@ +package top.jie65535.jcf + +import net.mamoe.mirai.console.data.AutoSavePluginData +import net.mamoe.mirai.console.data.value +import net.mamoe.mirai.console.data.ValueDescription + +object PluginData : AutoSavePluginData("JCurseforgeData") { + + /** + * 模组最新文件的id集合 + * ```json + * { + * mod_id: file_id, + * ... + * } + * ``` + */ + @ValueDescription("模组最新文件的id集合") + var modsLastFile: MutableMap by value() + + /** + * 订阅记录 + * ```json + * { + * mod_id: { + * group_id: [ qq_id, ... ], + * ... + * }, + * ... + * } + * ``` + * 个人订阅时,group为0 + */ + @ValueDescription("订阅记录") + var subscriptionSet: MutableMap>> by value() +} From 09974aad9e9942f510faf61800bb21c14ee95f7b Mon Sep 17 00:00:00 2001 From: dongRogen <3601778801@qq.com> Date: Thu, 4 Aug 2022 10:59:10 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=A4=84=E7=90=86=20-=20=E5=AE=9E=E7=8E=B0=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=A4=84=E7=90=86=20SubscribeHandler=20-=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=AD=E7=9A=84=20HTMLPattern=20=E8=AE=BE?= =?UTF-8?q?=E4=B8=BA=20public=20-=20=E8=A1=A5=E5=85=85=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E8=AE=A2=E9=98=85=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=20-=20PluginMain=20=E5=90=AF=E7=94=A8=E8=AE=A2=E9=98=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/top/jie65535/jcf/MessageHandler.kt | 17 +- .../kotlin/top/jie65535/jcf/PluginMain.kt | 14 +- .../top/jie65535/jcf/SubscribeHandler.kt | 309 ++++++++++++++++++ 3 files changed, 334 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt diff --git a/src/main/kotlin/top/jie65535/jcf/MessageHandler.kt b/src/main/kotlin/top/jie65535/jcf/MessageHandler.kt index 280bf47..05e7db3 100644 --- a/src/main/kotlin/top/jie65535/jcf/MessageHandler.kt +++ b/src/main/kotlin/top/jie65535/jcf/MessageHandler.kt @@ -1,7 +1,9 @@ package top.jie65535.jcf +import io.ktor.http.* import kotlinx.coroutines.* import net.mamoe.mirai.event.* +import net.mamoe.mirai.event.events.GroupMessageEvent import net.mamoe.mirai.event.events.MessageEvent import net.mamoe.mirai.message.data.* import net.mamoe.mirai.message.data.MessageSource.Key.quote @@ -125,7 +127,7 @@ class MessageHandler( subject.sendMessage( buildForwardMessage { // logo - mod.logo.thumbnailUrl?.let { + mod.logo?.thumbnailUrl?.let { if (it.isNotBlank()) bot says loadImage(it) } // basic info @@ -141,7 +143,7 @@ class MessageHandler( 主页:${mod.links.websiteUrl} """.trimIndent() }) - var msg = "$WAIT_REPLY_TIMEOUT_S 秒内回复 $SUBSCRIBE_KEYWORD 订阅模组更新(TODO)" + var msg = "$WAIT_REPLY_TIMEOUT_S 秒内回复 $SUBSCRIBE_KEYWORD 订阅模组更新" if (mod.latestFiles.isNotEmpty()) { msg += "\n回复编号查看文件详细信息\n" + "回复 $VIEW_FILES_KEYWORD 查看全部历史文件" @@ -163,9 +165,14 @@ class MessageHandler( eventChannel.nextEvent(EventPriority.MONITOR) { it.sender == sender } } val nextMessage = next.message.content + val subsHandler = PluginMain.subscribeHandler if (nextMessage.equals(SUBSCRIBE_KEYWORD, true)) { - // TODO 实现订阅模组更新功能 - subject.sendMessage("订阅更新功能暂未完成,敬请期待") + if (next is GroupMessageEvent) { + subsHandler.sub(mod.id, next.sender.id, next.group.id) + } else { + subsHandler.sub(mod.id, next.sender.id) + } + subject.sendMessage(QuoteReply(next.source) + "已添加订阅") } else if (mod.latestFiles.isNotEmpty()) { if (nextMessage.equals(VIEW_FILES_KEYWORD, true)) { // 查看所有文件 @@ -248,7 +255,7 @@ class MessageHandler( return image } - private val HTMLPattern = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE) + val HTMLPattern: Pattern = Pattern.compile("<[^>]+>", Pattern.CASE_INSENSITIVE) fun MessageEvent.sendLargeMessage(message: String): Message { return buildForwardMessage { for (g in message.indices step ONE_GRP_SIZE) { diff --git a/src/main/kotlin/top/jie65535/jcf/PluginMain.kt b/src/main/kotlin/top/jie65535/jcf/PluginMain.kt index e859afa..ebe9a1f 100644 --- a/src/main/kotlin/top/jie65535/jcf/PluginMain.kt +++ b/src/main/kotlin/top/jie65535/jcf/PluginMain.kt @@ -1,5 +1,6 @@ package top.jie65535.jcf +import kotlinx.coroutines.launch import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin @@ -17,8 +18,14 @@ object PluginMain: KotlinPlugin( "https://github.com/jie65535/mirai-console-jcf-plugin") } ) { + /** + * 订阅处理类 + */ + lateinit var subscribeHandler: SubscribeHandler private set + override fun onEnable() { logger.info { "Plugin loaded" } + PluginData.reload() PluginConfig.reload() PluginCommands.register() @@ -31,7 +38,12 @@ object PluginMain: KotlinPlugin( val service = MinecraftService(PluginConfig.apiKey) val eventChannel = GlobalEventChannel.parentScope(this) val messageHandler = MessageHandler(service, eventChannel, logger) + subscribeHandler = SubscribeHandler(service, logger) messageHandler.startListen() + launch { + subscribeHandler.load(this) + } + subscribeHandler.start()// TODO 添加可切换闲置状态的命令 logger.info { "Plugin Enabled" } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt new file mode 100644 index 0000000..f753020 --- /dev/null +++ b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt @@ -0,0 +1,309 @@ +package top.jie65535.jcf + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.buffer +import kotlinx.coroutines.flow.flow +import kotlinx.coroutines.launch +import net.mamoe.mirai.Bot +import net.mamoe.mirai.message.data.At +import net.mamoe.mirai.message.data.buildMessageChain +import net.mamoe.mirai.utils.MiraiLogger +import top.jie65535.jcf.model.mod.Mod + +/** + * 处理订阅 + * + * @param service api服务 + * @param logger 日志 + */ +class SubscribeHandler( + private val service: MinecraftService, + private val logger: MiraiLogger, +) { + + // region -- 参数 + + /** + * 清理订阅 + * + * @param mod 模组id;为null将清空所有订阅 + * @param group 群号;为null将移除指定mod下所有订阅 + */ + fun clean(mod: Int? = null, group: Long? = null) { + var updInner = false + val modSet = HashMap(PluginData.modsLastFile) + val subSet = HashMap(PluginData.subscriptionSet) + if (mod == null) { + subSet.clear() + modSet.clear() + logger.info("清理所有订阅") + } else if (group == null) { + modSet -= mod + subSet -= mod + logger.info("清理mod[${MOD_INFO_CACHE[mod]?.name}]的订阅") + } else { + subSet[mod]?.let { + logger.info("清理群/分组[$group]的订阅") + updInner = true + it -= group + } + } + + if (modSet.size != PluginData.modsLastFile.size) { + PluginData.modsLastFile = modSet + } + if (subSet.size != PluginData.subscriptionSet.size || updInner) { + PluginData.subscriptionSet = subSet + } + } + + /** + * 取消订阅 + * + * @param mod 模组id + * @param qq 个人q号或群成员q号 + * @param group 群号;为null时(默认)表示个人订阅 + */ + fun unsub(mod: Int, qq: Long, group: Long? = null) { + if (mod < 0 || qq < 0) return + + val gid = group ?: GROUP_ID_SINGLE + val subSet = HashMap(PluginData.subscriptionSet) + + val groups = subSet[mod] ?: return + val members = groups[gid] ?: return + members -= qq + PluginData.subscriptionSet = subSet + logger.info("取消订阅--{$mod:{$gid:[$qq]}}") + } + + /** + * 记录订阅 + * + * @param mod 模组id + * @param qq q号 + * @param group 群号;为null时(默认)表示个人订阅 + */ + fun sub(mod: Int, qq: Long, group: Long? = null) { + if (mod < 0 || qq < 0) return + val gid = group ?: GROUP_ID_SINGLE + val modSet = HashMap(PluginData.modsLastFile) + val subSet = HashMap(PluginData.subscriptionSet) + if (mod !in modSet) modSet[mod] = -1 + + val groupSet = subSet[mod] ?: mutableMapOf() + val qqSet = groupSet[gid] ?: mutableListOf() + var changed = gid !in groupSet + subSet[mod] = groupSet + groupSet[gid] = qqSet + if (qq !in qqSet) { + qqSet += qq + changed = true + logger.info("添加订阅--{$mod:{$gid:[$qq]}}") + } + + if (mod !in PluginData.modsLastFile) { + PluginData.modsLastFile = modSet + } + if (changed) { + PluginData.subscriptionSet = subSet + } + } + // endregion + + // region -- 流程 + + /** + * 检查更新 + * + * @param init 是否初始化 + * @return 检查到更新的{ mod : newFileId } + */ + private suspend fun checkUpdate(init: Boolean = false) = flow { + val oldSet = PluginData.modsLastFile + if (oldSet.isNotEmpty()) { + for ((mod, old) in oldSet) { + try { + val info = service.getMod(mod) + logger.info("模组更新【${info.name}】") + MOD_INFO_CACHE[mod] = info + val last = info.latestFilesIndexes[0].fileId + if (old != last || init) { + emit(mod to last) + } + } catch (e: Exception) { + logger.warning("err msg: ${e.message}") + emit(mod to -1) + continue + } + }// for + } + } + + /** + * 获取更新日志 + * + * @param mod 模组id + * @param file 文件id + * @return 更新日志 + */ + private suspend fun getChangeLogs(mod: Int, file: Int): String = try { + val changelog = service.getModFileChangelog(mod, file) + MessageHandler.HTMLPattern.matcher(changelog) + .replaceAll("") + .replace(Regex("\n+"), "\n") + } catch (e: Exception) { + logger.warning("err msg: ${e.message}") + "" + } + + /** + * 执行发送 + * + * @param sender 发送消息的bot + * @param modLogs { mod : changeLog } + */ + private suspend fun send(sender: Bot, modLogs: Pair) { + val (mod, logs) = modLogs + if (logs.isBlank()) return + + val subGroups = PluginData.subscriptionSet[mod] ?: return + val modName = MOD_INFO_CACHE[mod]?.name ?: return + val title = "你订阅的mod【$modName】更新啦!" + val context = "更新日志:\n$logs" + subGroups.forEach { (group, qqs) -> + if (group == GROUP_ID_SINGLE) { + qqs.forEach { + sender.getFriend(it)?.apply { + sendMessage(title) + sendMessage(context) + } + } + } else { + sender.getGroup(group)?.apply { + val titleChain = buildMessageChain { + qqs.forEach { +At(it) } + +"\n$title" + } + sendMessage(titleChain) + sendMessage(context) + } + }// if else + }// foreach + } + + /** + * 准备发送更新日志 + * + * @param senderQQ 指定发送消息的机器人id + * @param updMod { mod : file } + */ + private suspend fun feedback(senderQQ: Long, updMod: Pair) { + val (mod, file) = updMod + if (mod < 0) return + + Bot.instances.firstOrNull { + it.isOnline && it.id == senderQQ + }?.let { sender -> + val log = getChangeLogs(mod, file) + send(sender, mod to log) + }// let + } + + /** + * 循环执行 + */ + private fun CoroutineScope.loop() = launch { + val senderQQ = PluginConfig.subscribeSender + val interval = PluginConfig.checkInterval + if (senderQQ < 0) { + logger.warning("必须配置订阅信息推送bot(qq id)才可以进行订阅推送!") + logger.warning("插件会持续收集订阅与检查mod更新,但无法进行消息推送。") + } + logger.info("subscription listening") + while (true) { + delay(1000 * interval) + if (isIdle) continue + + val subSet = HashMap(PluginData.subscriptionSet) + val modFiles = HashMap(PluginData.modsLastFile) + checkUpdate() + .buffer() + .collect { + val (mod, file) = it + if (file < 0) { + modFiles -= mod + subSet -= mod + } else { + modFiles[mod] = file + feedback(senderQQ, it) + } + } + PluginData.subscriptionSet = subSet + PluginData.modsLastFile = modFiles + }// while + } + + // endregion + + // region -- 状态 + + /** + * 是否闲置 + */ + var isIdle = true + private set + + /** + * 取消闲置 + */ + fun start() { + isIdle = false + } + + /** + * 进入闲置 + */ + fun idle() { + isIdle = true + } + + /** + * 初始化,并开始订阅循环 + * + * @param scope 指定协程上下文 + */ + suspend fun load(scope: CoroutineScope) { + logger.info("loading plugin data...") + val subs = HashMap(PluginData.subscriptionSet) + val files = HashMap(PluginData.modsLastFile) + checkUpdate(true) + .buffer() + .collect { (mod, file) -> + if (file < 0) { + files -= mod + subs -= mod + } else { + files[mod] = file + } + } + PluginData.subscriptionSet = subs + PluginData.modsLastFile = files + scope.loop() + } + // endregion + + companion object { + + /** + * 标识个人订阅 + */ + const val GROUP_ID_SINGLE: Long = 0 + + /** + * 缓存模组信息 + */ + private val MOD_INFO_CACHE: MutableMap = mutableMapOf() + } +} From 21bcedcb1715ebb2829e0105483d2027be9df3b3 Mon Sep 17 00:00:00 2001 From: dongRogen <3601778801@qq.com> Date: Thu, 4 Aug 2022 11:40:31 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=B0=83=E6=95=B4=20=E6=A3=80=E6=9F=A5mod?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=A4=84=E6=94=B9=E7=94=A8=E6=89=B9=E9=87=8F?= =?UTF-8?q?=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/top/jie65535/jcf/SubscribeHandler.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt index f753020..980df73 100644 --- a/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt +++ b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt @@ -123,14 +123,22 @@ class SubscribeHandler( private suspend fun checkUpdate(init: Boolean = false) = flow { val oldSet = PluginData.modsLastFile if (oldSet.isNotEmpty()) { + val fetchMods = service.getMods(oldSet.keys.toIntArray()) + .asSequence() + .map { it.id to it } + .toMap() for ((mod, old) in oldSet) { try { - val info = service.getMod(mod) - logger.info("模组更新【${info.name}】") - MOD_INFO_CACHE[mod] = info - val last = info.latestFilesIndexes[0].fileId + val new = fetchMods[mod] + if (new == null) { + emit(mod to -1) + continue + } + MOD_INFO_CACHE[mod] = new + val last = new.latestFilesIndexes[0].fileId if (old != last || init) { emit(mod to last) + logger.info("模组更新【${new.name}】") } } catch (e: Exception) { logger.warning("err msg: ${e.message}") From b2090cc09b884aeaf6886b517581a992c4ca3a69 Mon Sep 17 00:00:00 2001 From: dongRogen <3601778801@qq.com> Date: Tue, 9 Aug 2022 20:32:39 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=AF=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=97=B2=E7=BD=AE=E7=8A=B6=E6=80=81=E7=9A=84=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/top/jie65535/jcf/PluginCommands.kt | 41 ++++++++++++++++++- .../kotlin/top/jie65535/jcf/PluginConfig.kt | 4 +- .../kotlin/top/jie65535/jcf/PluginMain.kt | 2 +- .../top/jie65535/jcf/SubscribeHandler.kt | 3 +- 4 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/top/jie65535/jcf/PluginCommands.kt b/src/main/kotlin/top/jie65535/jcf/PluginCommands.kt index e5a1b63..e78a0c7 100644 --- a/src/main/kotlin/top/jie65535/jcf/PluginCommands.kt +++ b/src/main/kotlin/top/jie65535/jcf/PluginCommands.kt @@ -20,4 +20,43 @@ object PluginCommands : CompositeCommand(PluginMain, "jcf") { } sendMessage(msg.toString()) } -} \ No newline at end of file + + @SubCommand + @Description("设置订阅信息推送bot(qq id)") + suspend fun CommandSender.setSubsSender(sender: Long) { + PluginConfig.subscribeSender = sender + sendMessage("OK! ") + } + + @SubCommand + @Description("设置检查间隔(单位:秒)") + suspend fun CommandSender.setCheckInterval(second: Long) { + PluginConfig.checkInterval = second + sendMessage("OK! 将在下次检查结束后应用") + } + + @SubCommand + @Description("查看订阅处理的状态") + suspend fun CommandSender.subStat() { + val subs = PluginMain.subscribeHandler + if (subs.isIdle) { + sendMessage("订阅器闲置中") + } else { + sendMessage("订阅处理正常运行中") + } + } + + @SubCommand + @Description("使订阅器闲置") + suspend fun CommandSender.idleSubs() { + PluginMain.subscribeHandler.idle() + sendMessage("OK,已闲置") + } + + @SubCommand + @Description("使订阅器恢复运行") + suspend fun CommandSender.runSubs() { + PluginMain.subscribeHandler.start() + sendMessage("OK,已恢复订阅处理") + } +} diff --git a/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt b/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt index cf2f418..39d78b2 100644 --- a/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt +++ b/src/main/kotlin/top/jie65535/jcf/PluginConfig.kt @@ -25,11 +25,11 @@ object PluginConfig : AutoSavePluginConfig("JCurseforgeConfig") { * 订阅信息推送bot */ @ValueDescription("订阅信息推送bot(qq id)") - val subscribeSender: Long by value(-1L) + var subscribeSender: Long by value(-1L) /** * 检查间隔 */ @ValueDescription("检查间隔(单位:秒)") - val checkInterval: Long by value(60 * 60 * 4L) + var checkInterval: Long by value(60 * 60 * 4L) } diff --git a/src/main/kotlin/top/jie65535/jcf/PluginMain.kt b/src/main/kotlin/top/jie65535/jcf/PluginMain.kt index ebe9a1f..21e941d 100644 --- a/src/main/kotlin/top/jie65535/jcf/PluginMain.kt +++ b/src/main/kotlin/top/jie65535/jcf/PluginMain.kt @@ -43,7 +43,7 @@ object PluginMain: KotlinPlugin( launch { subscribeHandler.load(this) } - subscribeHandler.start()// TODO 添加可切换闲置状态的命令 + subscribeHandler.start() logger.info { "Plugin Enabled" } } } diff --git a/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt index 980df73..0a8b3ac 100644 --- a/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt +++ b/src/main/kotlin/top/jie65535/jcf/SubscribeHandler.kt @@ -224,14 +224,13 @@ class SubscribeHandler( */ private fun CoroutineScope.loop() = launch { val senderQQ = PluginConfig.subscribeSender - val interval = PluginConfig.checkInterval if (senderQQ < 0) { logger.warning("必须配置订阅信息推送bot(qq id)才可以进行订阅推送!") logger.warning("插件会持续收集订阅与检查mod更新,但无法进行消息推送。") } logger.info("subscription listening") while (true) { - delay(1000 * interval) + delay(1000 * PluginConfig.checkInterval) if (isIdle) continue val subSet = HashMap(PluginData.subscriptionSet)