更新版本到1.3.0

增加在间隔时间内是否拦截事件选项
更新依赖版本
This commit is contained in:
2023-02-13 22:44:14 +08:00
parent f20fd9b807
commit 22e8624f0b
3 changed files with 18 additions and 8 deletions

View File

@ -1,13 +1,13 @@
plugins {
val kotlinVersion = "1.6.0"
val kotlinVersion = "1.7.10"
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
id("net.mamoe.mirai-console") version "2.12.2"
id("net.mamoe.mirai-console") version "2.14.0"
}
group = "top.jie65535"
version = "1.2.1"
version = "1.3.0"
repositories {
mavenLocal()

View File

@ -47,4 +47,9 @@ object JNRPluginConfig : AutoSavePluginConfig("jnr") {
*/
@ValueDescription("用户私聊回复间隔0表示无限制")
var userInterval: Long by value(0L)
/**
* 是否在间隔期间依然拦截事件 [isIntercept] 有关
*/
var interceptAtInterval: Boolean by value(true)
}

View File

@ -18,7 +18,7 @@ object JNudgeReply : KotlinPlugin(
JvmPluginDescription(
id = "me.jie65535.mirai-console-jnr-plugin",
name = "J Nudge Reply",
version = "1.2.1",
version = "1.3.0",
) {
author("jie65535")
info("""自定义戳一戳回复插件""")
@ -61,7 +61,7 @@ object JNudgeReply : KotlinPlugin(
}
// 判断间隔
if (isReply) {
val isIgnored = if (isReply) {
val totalWeight = replyList.sumOf { it.weight }
var w = Random.nextInt(totalWeight)
for (msg in replyList) {
@ -72,18 +72,23 @@ object JNudgeReply : KotlinPlugin(
w -= msg.weight
}
}
false
} else {
logger.info("正在CD中本次已忽略")
true
}
// 拦截事件
if (JNRPluginConfig.priority != EventPriority.MONITOR && JNRPluginConfig.isIntercept) {
intercept()
if (JNRPluginConfig.priority != EventPriority.MONITOR && JNRPluginConfig.isIntercept
) {
// 在被忽略的情况下判断是否拦截
if (!isIgnored || JNRPluginConfig.interceptAtInterval)
intercept()
}
}
}
logger.info { "Plugin loaded" }
logger.info { "Plugin loaded. https://github.com/jie65535/mirai-console-jnr-plugin" }
}
private suspend fun doReply(message: ReplyMessage, event: NudgeEvent) {