Skip to content

Commit

Permalink
build: 1.4.7
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Feb 19, 2022
1 parent 042780d commit ab0bcf6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "xyz.cssxsh"
version = "1.4.6"
version = "1.4.7"

repositories {
mavenLocal()
Expand Down
14 changes: 12 additions & 2 deletions src/main/kotlin/xyz/cssxsh/mirai/plugin/BiliHelperPlugin.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.cssxsh.mirai.plugin

import kotlinx.coroutines.*
import net.mamoe.mirai.*
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.register
import net.mamoe.mirai.console.command.CommandManager.INSTANCE.unregister
import net.mamoe.mirai.console.plugin.jvm.*
Expand All @@ -12,7 +13,7 @@ import xyz.cssxsh.mirai.plugin.command.*
import xyz.cssxsh.mirai.plugin.data.*

object BiliHelperPlugin : KotlinPlugin(
JvmPluginDescription(id = "xyz.cssxsh.mirai.plugin.bilibili-helper", version = "1.4.6") {
JvmPluginDescription(id = "xyz.cssxsh.mirai.plugin.bilibili-helper", version = "1.4.7") {
name("bilibili-helper")
author("cssxsh")

Expand All @@ -37,6 +38,7 @@ object BiliHelperPlugin : KotlinPlugin(
}

logger.info { "如果要B站动态的截图内容,请修改 DynamicInfo.template, 添加 #screenshot" }
logger.info { "如果要B站专栏的截图内容,请修改 Article.template, 添加 #screenshot" }

if (SetupSelenium) {
launch(SupervisorJob()) {
Expand All @@ -47,14 +49,22 @@ object BiliHelperPlugin : KotlinPlugin(

BiliListener.registerTo(globalEventChannel())

globalEventChannel().subscribeOnce<BotOnlineEvent> {
waitOnline {
for (task in BiliTasker) {
task.start()
}
BiliCleaner.start()
}
}

private fun waitOnline(block: () -> Unit) {
if (Bot.instances.isEmpty()) {
globalEventChannel().subscribeOnce<BotOnlineEvent> { block() }
} else {
block()
}
}

override fun onDisable() {
for (command in BiliHelperCommand) {
command.unregister()
Expand Down

0 comments on commit ab0bcf6

Please sign in to comment.