diff --git a/build.gradle.kts b/build.gradle.kts index 5f39f76..b243bc5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,6 +26,8 @@ dependencies { compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.8.0") testConsoleRuntime("top.mrxiaom:overflow-core:$overflow_version") testImplementation("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.8.0") + + compileOnly(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) } mirai { diff --git a/libs/mirai-hibernate-plugin-2.8.0.jar b/libs/mirai-hibernate-plugin-2.8.0.jar new file mode 100644 index 0000000..2d0bbfe Binary files /dev/null and b/libs/mirai-hibernate-plugin-2.8.0.jar differ diff --git a/src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt b/src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt index 3d9bc39..ee0ef15 100644 --- a/src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt +++ b/src/main/kotlin/ltd/guimc/lgzbot/PluginMain.kt @@ -60,6 +60,7 @@ object PluginMain : KotlinPlugin( "LgzBot", ){ author("BakaBotTeam") + dependsOn("xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin", false) } ) { lateinit var bypassMute: Permission diff --git a/src/main/kotlin/ltd/guimc/lgzbot/command/LGZBotCommand.kt b/src/main/kotlin/ltd/guimc/lgzbot/command/LGZBotCommand.kt index 28cc1ef..ff452de 100644 --- a/src/main/kotlin/ltd/guimc/lgzbot/command/LGZBotCommand.kt +++ b/src/main/kotlin/ltd/guimc/lgzbot/command/LGZBotCommand.kt @@ -17,17 +17,12 @@ import ltd.guimc.lgzbot.utils.LL4JUtils import ltd.guimc.lgzbot.utils.MessageUtils.getPlainText import ltd.guimc.lgzbot.utils.OverflowUtils import ltd.guimc.lgzbot.word.WordUtils -import net.mamoe.mirai.console.command.CommandSender -import net.mamoe.mirai.console.command.CompositeCommand -import net.mamoe.mirai.console.command.getGroupOrNull -import net.mamoe.mirai.console.command.isConsole +import net.mamoe.mirai.console.command.* import net.mamoe.mirai.contact.Member import net.mamoe.mirai.contact.NormalMember -import net.mamoe.mirai.message.data.At -import net.mamoe.mirai.message.data.MessageChainBuilder -import net.mamoe.mirai.message.data.PlainText -import net.mamoe.mirai.message.data.QuoteReply +import net.mamoe.mirai.message.data.* import top.mrxiaom.overflow.contact.Updatable +import xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder import kotlin.math.roundToInt import kotlin.time.Duration @@ -121,8 +116,14 @@ object LGZBotCommand : CompositeCommand( @SubCommand("check") @Description("使用模型检测一段文本是否合规") - suspend fun CommandSender.iI1I1i1I1i1I(string: String) { - if (LL4JUtils.predict(string)) { + suspend fun CommandSenderOnMessage<*>.iI1I1i1I1i1I(string: String) { + var str = string + if (string == "reply") { + val quote = fromEvent.message.findIsInstance() ?: return + val raw = MiraiHibernateRecorder[quote.source] as MessageChain + str = raw.getPlainText() + } + if (LL4JUtils.predict(str)) { sendMessage("不合规") } else { sendMessage("合规") @@ -135,14 +136,4 @@ object LGZBotCommand : CompositeCommand( LL4JUtils.learn(type, string) sendMessage("Done.") } - - @SubCommand("check") - @Description("使用模型检测一段文本是否合规") - suspend fun CommandSender.iI1I1i1I1i1I(string: QuoteReply) { - if (LL4JUtils.predict(string.source.originalMessage.getPlainText())) { - sendMessage("不合规") - } else { - sendMessage("合规") - } - } } \ No newline at end of file