From 39ad39f2ab1d33094ffae46bccac2f72d2c8e723 Mon Sep 17 00:00:00 2001 From: only52607 Date: Sun, 22 May 2022 18:49:37 +0800 Subject: [PATCH 1/9] catch mainFunc invoke exception --- .../com/github/only52607/luamirai/lua/LuaMiraiScript.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt index 66ea91c..a8442b3 100644 --- a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt +++ b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt @@ -80,7 +80,11 @@ class LuaMiraiScript( if (coroutineContext[ContinuationInterceptor] == null) { coroutineContext += taskLib.asCoroutineDispatcher() } - mainFunc.invoke() + try { + mainFunc.invoke() + } catch (e: Exception) { + e.printStackTrace(PrintStream(stderr ?: System.err)) + } } override suspend fun onStop() { @@ -127,7 +131,7 @@ class LuaMiraiScript( private val parentFinder: ResourceFinder, private val botScriptResourceFinder: BotScriptResourceFinder? ) : ResourceFinder { - override fun findResource(filename: String): InputStream { + override fun findResource(filename: String): InputStream? { val resource = botScriptResourceFinder?.findResource(filename) if (resource != null) return resource return parentFinder.findResource(filename) From f05d4b1a5d129826e4c08f45e31190e32c6ae095 Mon Sep 17 00:00:00 2001 From: only52607 Date: Sun, 22 May 2022 19:36:37 +0800 Subject: [PATCH 2/9] update luakt version --- lua-mirai-adapter-luakt/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua-mirai-adapter-luakt/build.gradle b/lua-mirai-adapter-luakt/build.gradle index 81e288e..07bbc70 100644 --- a/lua-mirai-adapter-luakt/build.gradle +++ b/lua-mirai-adapter-luakt/build.gradle @@ -4,5 +4,5 @@ dependencies { implementation "org.xerial:sqlite-jdbc:3.7.2" implementation "org.jsoup:jsoup:1.7.3" implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2" - implementation "com.github.only52607.luakt:luakt:2.5.6" + implementation "com.github.only52607.luakt:luakt:2.5.7" } \ No newline at end of file From 68e4c5ca695362c3a79beb68d468187b0a266ff8 Mon Sep 17 00:00:00 2001 From: only52607 Date: Sun, 22 May 2022 21:11:03 +0800 Subject: [PATCH 3/9] let ConfigurableScriptSource extends Wrapper --- .../configuration/ConfigurableScriptSource.kt | 17 ++--------------- .../luamirai/core/script/BotScriptSource.kt | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/lua-mirai-configuration/src/main/kotlin/com/github/only52607/luamirai/configuration/ConfigurableScriptSource.kt b/lua-mirai-configuration/src/main/kotlin/com/github/only52607/luamirai/configuration/ConfigurableScriptSource.kt index b691ad5..fccdba7 100644 --- a/lua-mirai-configuration/src/main/kotlin/com/github/only52607/luamirai/configuration/ConfigurableScriptSource.kt +++ b/lua-mirai-configuration/src/main/kotlin/com/github/only52607/luamirai/configuration/ConfigurableScriptSource.kt @@ -2,7 +2,6 @@ package com.github.only52607.luamirai.configuration import com.github.only52607.luamirai.core.script.BotScriptSource import kotlinx.serialization.Serializable -import java.io.InputStream /** * ClassName: ConfigurableScriptSource @@ -13,19 +12,7 @@ import java.io.InputStream */ @Serializable(ConfigurableScriptSourceSerializer::class) class ConfigurableScriptSource( - val source: BotScriptSource, + source: BotScriptSource, var alias: String? = null, var autoStart: Boolean = false -) : BotScriptSource( - lang = source.lang, - name = source.name, - size = source.size, - charset = source.charset, -) { - override val mainInputStream: InputStream - get() = source.mainInputStream - - override fun toString(): String { - return source.toString() - } -} \ No newline at end of file +) : BotScriptSource.Wrapper(source) \ No newline at end of file diff --git a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt index 754bc5a..4b8e2e3 100644 --- a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt +++ b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt @@ -64,4 +64,20 @@ abstract class BotScriptSource( return "URLSource(name=$name, url=$url, lang=$lang)" } } + + open class Wrapper( + val source: BotScriptSource + ) : BotScriptSource( + lang = source.lang, + name = source.name, + size = source.size, + charset = source.charset, + ) { + override val mainInputStream: InputStream + get() = source.mainInputStream + + override fun toString(): String { + return source.toString() + } + } } \ No newline at end of file From e43a0b7f8a809c11c1ea0152f39a6cc739399e9e Mon Sep 17 00:00:00 2001 From: only52607 Date: Sun, 22 May 2022 21:12:04 +0800 Subject: [PATCH 4/9] add search path in file directory --- .../only52607/luamirai/lua/LuaMiraiScript.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt index a8442b3..78b003e 100644 --- a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt +++ b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt @@ -26,7 +26,7 @@ import kotlin.coroutines.ContinuationInterceptor import kotlin.coroutines.CoroutineContext class LuaMiraiScript( - override var source: BotScriptSource, + override val source: BotScriptSource, override val header: BotScriptHeader, mainInputStream: InputStream ) : AbstractBotScript(), CoroutineScope { @@ -73,6 +73,7 @@ class LuaMiraiScript( STDERR = stderr?.let(::PrintStream) STDIN = stdin } + initSearchPath(source) mainFunc = globals.load(mainInputStream, source.name, "bt", globals) } @@ -127,6 +128,19 @@ class LuaMiraiScript( load(SocketLib(LuaMiraiValueMapper)) } + private fun initSearchPath(botScriptSource: BotScriptSource) { + when (botScriptSource) { + is BotScriptSource.Wrapper -> { + initSearchPath(botScriptSource.source) + } + is BotScriptSource.FileSource -> { + globals.get("package").apply { + set("path", get("path").optjstring("?.lua") + ";${botScriptSource.file.parent}/?.lua") + } + } + } + } + class ResourceFinderAdapter( private val parentFinder: ResourceFinder, private val botScriptResourceFinder: BotScriptResourceFinder? From b1ab4b0405a46346dd2f55cde99d635c1c08ae14 Mon Sep 17 00:00:00 2001 From: only52607 Date: Sun, 22 May 2022 23:40:29 +0800 Subject: [PATCH 5/9] add json dependency to parse manifest.json --- lua-mirai-core/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua-mirai-core/build.gradle b/lua-mirai-core/build.gradle index e69de29..d8b03f8 100644 --- a/lua-mirai-core/build.gradle +++ b/lua-mirai-core/build.gradle @@ -0,0 +1,3 @@ +dependencies { + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2" +} \ No newline at end of file From 14fd646306809f4c9f76ef7d0fedb74cc42e26b4 Mon Sep 17 00:00:00 2001 From: only52607 Date: Mon, 23 May 2022 00:09:46 +0800 Subject: [PATCH 6/9] add packaged script support --- .../luamirai/lua/LuaMiraiScriptBuilder.kt | 32 ++++++- .../luamirai/core/script/BotScriptSource.kt | 89 ++++++++++++++++++- 2 files changed, 115 insertions(+), 6 deletions(-) diff --git a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScriptBuilder.kt b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScriptBuilder.kt index 77665c0..13d412d 100644 --- a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScriptBuilder.kt +++ b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScriptBuilder.kt @@ -4,8 +4,13 @@ import com.github.only52607.luamirai.core.BotScriptBuilder import com.github.only52607.luamirai.core.script.BotScript import com.github.only52607.luamirai.core.script.BotScriptHeader import com.github.only52607.luamirai.core.script.BotScriptSource +import com.github.only52607.luamirai.core.script.mutableBotScriptHeaderOf import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive import java.io.BufferedInputStream /** @@ -44,16 +49,35 @@ class LuaMiraiScriptBuilder( private suspend fun prepareHeader() { if (headerInitialized) return - prepareMainInputStream() + val manifestInputStream = source.resourceFinder?.findResource("manifest.json") + header = if (manifestInputStream != null) { + readHeaderFromJsonManifest(String(manifestInputStream.readBytes())) + } else { + prepareMainInputStream() + readHeaderFromCodeInputStream() + } + headerInitialized = true + } + + private suspend fun readHeaderFromCodeInputStream(): BotScriptHeader { mainInputStream.mark(MAX_SCRIPT_HEADER) - withContext(Dispatchers.IO) { + return withContext(Dispatchers.IO) { try { - header = LuaHeaderReader.readHeader(mainInputStream) + LuaHeaderReader.readHeader(mainInputStream) } finally { mainInputStream.reset() } } - headerInitialized = true + } + + private fun readHeaderFromJsonManifest(jsonString: String): BotScriptHeader { + val json = Json + val manifest: JsonObject = json.parseToJsonElement(jsonString).jsonObject + return mutableBotScriptHeaderOf { + manifest["header"]?.jsonObject?.forEach { key, value -> + this@mutableBotScriptHeaderOf[key] = value.jsonPrimitive.content + } + } } override suspend fun buildInstance(): BotScript { diff --git a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt index 4b8e2e3..bd3c4e1 100644 --- a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt +++ b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt @@ -1,10 +1,16 @@ package com.github.only52607.luamirai.core.script +import kotlinx.serialization.json.Json +import kotlinx.serialization.json.JsonObject +import kotlinx.serialization.json.jsonObject +import kotlinx.serialization.json.jsonPrimitive import java.io.ByteArrayInputStream import java.io.File +import java.io.FileNotFoundException import java.io.InputStream import java.net.URL import java.nio.charset.Charset +import java.util.zip.ZipFile /** * ClassName: BotScriptSource @@ -19,24 +25,100 @@ abstract class BotScriptSource( var name: String, open var size: Long?, open val charset: Charset?, - val resourceFinder: BotScriptResourceFinder? = null + ) { abstract val mainInputStream: InputStream + open val resourceFinder: BotScriptResourceFinder? = null + class FileSource( val file: File, scriptLang: String, name: String = "@${file.name}", charset: Charset = Charsets.UTF_8 ) : BotScriptSource(scriptLang, name, file.length(), charset) { + private var textFileSource: TextFileSource? = null + private var zipFileSource: ZipSource? = null + + init { + if (isPackage()) { + zipFileSource = ZipSource(file, scriptLang, name, charset) + } else { + textFileSource = TextFileSource(file, scriptLang, name, charset) + } + } + + private fun isPackage(): Boolean { + return file.name.endsWith(".zip") || file.name.endsWith(".lmpk") + } + override val mainInputStream: InputStream - get() = file.inputStream() + get() = zipFileSource?.mainInputStream ?: textFileSource?.mainInputStream + ?: throw Exception("FileSource has not been initialized") + + override val resourceFinder: BotScriptResourceFinder? + get() = zipFileSource?.resourceFinder ?: textFileSource?.resourceFinder override fun toString(): String { return "FileSource(name=$name, file=$file, lang=$lang)" } } + class TextFileSource( + val file: File, + scriptLang: String, + name: String = "@${file.name}", + charset: Charset = Charsets.UTF_8 + ) : BotScriptSource(scriptLang, name, file.length(), charset) { + override val mainInputStream: InputStream + get() = file.inputStream() + + override fun toString(): String { + return "TextFileSource(name=$name, file=$file, lang=$lang)" + } + } + + class ZipSource( + val file: File, + scriptLang: String, + name: String = "@${file.name}", + charset: Charset = Charsets.UTF_8 + ) : BotScriptSource(scriptLang, name, file.length(), charset) { + + private val zipFile = ZipFile(file) + + private val json = Json + + private val manifest: JsonObject = getInputStream("manifest.json")?.let { + json.parseToJsonElement(String(it.readBytes())).jsonObject + } ?: throw FileNotFoundException("manifest.json not found in ${file.absolutePath}") + + private val mainFileName: String = manifest["main"]?.jsonPrimitive?.content + ?: throw Exception("You must specify the main field as the script entry") + + init { + super.name = mainFileName + } + + private fun getInputStream(name: String) = zipFile.getEntry(name)?.let { zipFile.getInputStream(it) } + + override val mainInputStream: InputStream + get() = getInputStream(mainFileName) + ?: throw FileNotFoundException("File $mainFileName not found in ${file.absolutePath}") + + override val resourceFinder: BotScriptResourceFinder + get() = object : BotScriptResourceFinder { + override fun findResource(filename: String): InputStream? { + val zipEntryName = filename.replace("\\", "/") + return getInputStream(zipEntryName) + } + } + + override fun toString(): String { + return "ZipSource(name=$name, file=$file, lang=$lang)" + } + } + class StringSource( val content: String, lang: String, @@ -76,6 +158,9 @@ abstract class BotScriptSource( override val mainInputStream: InputStream get() = source.mainInputStream + override val resourceFinder: BotScriptResourceFinder? + get() = source.resourceFinder + override fun toString(): String { return source.toString() } From ec1c79cc40f6727483d5263848758e580a5929cf Mon Sep 17 00:00:00 2001 From: only52607 Date: Mon, 23 May 2022 09:33:01 +0800 Subject: [PATCH 7/9] add directory source --- .../luamirai/core/script/BotScriptSource.kt | 77 +++++++++++++------ 1 file changed, 53 insertions(+), 24 deletions(-) diff --git a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt index bd3c4e1..7b4cc80 100644 --- a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt +++ b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt @@ -25,7 +25,6 @@ abstract class BotScriptSource( var name: String, open var size: Long?, open val charset: Charset?, - ) { abstract val mainInputStream: InputStream @@ -37,15 +36,11 @@ abstract class BotScriptSource( name: String = "@${file.name}", charset: Charset = Charsets.UTF_8 ) : BotScriptSource(scriptLang, name, file.length(), charset) { - private var textFileSource: TextFileSource? = null - private var zipFileSource: ZipSource? = null - init { - if (isPackage()) { - zipFileSource = ZipSource(file, scriptLang, name, charset) - } else { - textFileSource = TextFileSource(file, scriptLang, name, charset) - } + private val scriptSource: BotScriptSource = when { + file.isDirectory -> DirectorySource(file, scriptLang, name, charset) + isPackage() -> ZipSource(file, scriptLang, name, charset) + else -> TextFileSource(file, scriptLang, name, charset) } private fun isPackage(): Boolean { @@ -53,11 +48,10 @@ abstract class BotScriptSource( } override val mainInputStream: InputStream - get() = zipFileSource?.mainInputStream ?: textFileSource?.mainInputStream - ?: throw Exception("FileSource has not been initialized") + get() = scriptSource.mainInputStream override val resourceFinder: BotScriptResourceFinder? - get() = zipFileSource?.resourceFinder ?: textFileSource?.resourceFinder + get() = scriptSource.resourceFinder override fun toString(): String { return "FileSource(name=$name, file=$file, lang=$lang)" @@ -78,6 +72,43 @@ abstract class BotScriptSource( } } + class DirectorySource( + val directory: File, + scriptLang: String, + name: String = "@${directory.name}", + charset: Charset = Charsets.UTF_8 + ) : BotScriptSource(scriptLang, name, directory.length(), charset) { + + override val resourceFinder: BotScriptResourceFinder = object : BotScriptResourceFinder { + override fun findResource(filename: String): InputStream? { + val file = File(directory, filename) + if (!file.exists()) return null + return file.inputStream() + } + } + + private val json = Json + + override val mainInputStream: InputStream + get() = resourceFinder.findResource(mainFileName) + ?: throw FileNotFoundException("File $mainFileName not found in ${directory.absolutePath}") + + private val manifest: JsonObject = resourceFinder.findResource("manifest.json")?.let { + json.parseToJsonElement(String(it.readBytes())).jsonObject + } ?: throw FileNotFoundException("manifest.json not found in ${directory.absolutePath}") + + private val mainFileName: String = manifest["main"]?.jsonPrimitive?.content + ?: throw Exception("You must specify the main field as the script entry") + + init { + super.name = mainFileName + } + + override fun toString(): String { + return "DirectorySource(name=$name, directory=$directory, lang=$lang)" + } + } + class ZipSource( val file: File, scriptLang: String, @@ -85,11 +116,19 @@ abstract class BotScriptSource( charset: Charset = Charsets.UTF_8 ) : BotScriptSource(scriptLang, name, file.length(), charset) { + override val resourceFinder: BotScriptResourceFinder = object : BotScriptResourceFinder { + override fun findResource(filename: String): InputStream? { + val zipEntryName = filename.replace("\\", "/") + val zipEntry = zipFile.getEntry(zipEntryName) ?: return null + return zipFile.getInputStream(zipEntry) + } + } + private val zipFile = ZipFile(file) private val json = Json - private val manifest: JsonObject = getInputStream("manifest.json")?.let { + private val manifest: JsonObject = resourceFinder.findResource("manifest.json")?.let { json.parseToJsonElement(String(it.readBytes())).jsonObject } ?: throw FileNotFoundException("manifest.json not found in ${file.absolutePath}") @@ -100,20 +139,10 @@ abstract class BotScriptSource( super.name = mainFileName } - private fun getInputStream(name: String) = zipFile.getEntry(name)?.let { zipFile.getInputStream(it) } - override val mainInputStream: InputStream - get() = getInputStream(mainFileName) + get() = resourceFinder.findResource(mainFileName) ?: throw FileNotFoundException("File $mainFileName not found in ${file.absolutePath}") - override val resourceFinder: BotScriptResourceFinder - get() = object : BotScriptResourceFinder { - override fun findResource(filename: String): InputStream? { - val zipEntryName = filename.replace("\\", "/") - return getInputStream(zipEntryName) - } - } - override fun toString(): String { return "ZipSource(name=$name, file=$file, lang=$lang)" } From dd9bc2b0ef26756ffc39ae2fa1741c03f229da77 Mon Sep 17 00:00:00 2001 From: only52607 Date: Mon, 23 May 2022 09:43:08 +0800 Subject: [PATCH 8/9] find resource directly instead of add path --- .../only52607/luamirai/lua/LuaMiraiScript.kt | 14 -------------- .../luamirai/core/script/BotScriptSource.kt | 9 +++++++++ 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt index 78b003e..fa157b0 100644 --- a/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt +++ b/lua-mirai-adapter-luakt/src/main/kotlin/com/github/only52607/luamirai/lua/LuaMiraiScript.kt @@ -73,7 +73,6 @@ class LuaMiraiScript( STDERR = stderr?.let(::PrintStream) STDIN = stdin } - initSearchPath(source) mainFunc = globals.load(mainInputStream, source.name, "bt", globals) } @@ -128,19 +127,6 @@ class LuaMiraiScript( load(SocketLib(LuaMiraiValueMapper)) } - private fun initSearchPath(botScriptSource: BotScriptSource) { - when (botScriptSource) { - is BotScriptSource.Wrapper -> { - initSearchPath(botScriptSource.source) - } - is BotScriptSource.FileSource -> { - globals.get("package").apply { - set("path", get("path").optjstring("?.lua") + ";${botScriptSource.file.parent}/?.lua") - } - } - } - } - class ResourceFinderAdapter( private val parentFinder: ResourceFinder, private val botScriptResourceFinder: BotScriptResourceFinder? diff --git a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt index 7b4cc80..d28cc2a 100644 --- a/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt +++ b/lua-mirai-core/src/main/kotlin/com/github/only52607/luamirai/core/script/BotScriptSource.kt @@ -64,6 +64,15 @@ abstract class BotScriptSource( name: String = "@${file.name}", charset: Charset = Charsets.UTF_8 ) : BotScriptSource(scriptLang, name, file.length(), charset) { + override val resourceFinder: BotScriptResourceFinder = object : BotScriptResourceFinder { + val directory = file.parentFile + override fun findResource(filename: String): InputStream? { + val file = File(directory, filename) + if (!file.exists()) return null + return file.inputStream() + } + } + override val mainInputStream: InputStream get() = file.inputStream() From 34ef006f111f3341167c9a15dae09a63f57b6ea6 Mon Sep 17 00:00:00 2001 From: only52607 Date: Mon, 23 May 2022 10:00:08 +0800 Subject: [PATCH 9/9] optimize source add output --- .../com/github/only52607/luamirai/console/LuaMiraiCommand.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua-mirai-mcl-plugin/src/main/kotlin/com/github/only52607/luamirai/console/LuaMiraiCommand.kt b/lua-mirai-mcl-plugin/src/main/kotlin/com/github/only52607/luamirai/console/LuaMiraiCommand.kt index ff0e99b..69b3d1b 100644 --- a/lua-mirai-mcl-plugin/src/main/kotlin/com/github/only52607/luamirai/console/LuaMiraiCommand.kt +++ b/lua-mirai-mcl-plugin/src/main/kotlin/com/github/only52607/luamirai/console/LuaMiraiCommand.kt @@ -109,8 +109,8 @@ class LuaMiraiCommand( } val builder = BotScriptBuilder.fromSource(ConfigurableScriptSource(source)) builders.add(builder) - logger.info("添加脚本源[${builders.size - 1}] $fileName 成功,脚本信息:") - logger.info(builder.readHeader().simpleInfo) + logger.info("添加脚本源[${builders.size - 1}] $fileName 成功") + logger.info("脚本信息:\n" + builder.readHeader().simpleInfo) updateConfig() }