From 5b560d6e3bf1115410e98ceb031cf9098c101516 Mon Sep 17 00:00:00 2001 From: Eritque arcus <1930893235@qq.com> Date: Thu, 5 Aug 2021 10:07:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=87=86=E5=A4=87v2.7-RC-dev4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 9 ++++++ cpp/demo.cpp | 2 +- cpp/include/miraiCP.hpp | 2 +- kotlin/gradle/libs.versions.toml | 2 +- kotlin/loader/src/main/kotlin/KotlinMain.kt | 30 +++++++++++++++++-- .../loader/src/main/kotlin/console/Console.kt | 4 +++ kotlin/plugin/build.gradle.kts | 2 +- kotlin/plugin/src/main/kotlin/PluginMain.kt | 2 +- kotlin/shared/src/main/kotlin/PublicShared.kt | 2 +- 9 files changed, 46 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 01e347490..a8cc5d918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change Log +## v2.7-RC-dev4 + ++ 支持把plugin部分发布到maven, 以增加mcl支持 ++ mirai依赖更新到v2.7-RC-dev-3 ++ loader支持(-g)参数创建(覆盖)config.json模板 ++ 修复匿名聊天造成的找不到群成员造成的异常退出 + +> 该版本主要为了发布到maven,较于上一版没什么改动 + ## v2.7-RC-dev3 + 优化cmake组合方式(所以推荐一并更新全部的Cmake文件) diff --git a/cpp/demo.cpp b/cpp/demo.cpp index 9968c0a8c..7e9dc2633 100644 --- a/cpp/demo.cpp +++ b/cpp/demo.cpp @@ -15,7 +15,7 @@ // // MiraiCP依赖文件(只需要引入这一个) -#include "miraiCP.hpp" +#include using namespace std; using namespace MiraiCP; // 多线程示例 diff --git a/cpp/include/miraiCP.hpp b/cpp/include/miraiCP.hpp index 277f02cfd..e894b43a4 100644 --- a/cpp/include/miraiCP.hpp +++ b/cpp/include/miraiCP.hpp @@ -39,7 +39,7 @@ namespace MiraiCP { using json = nlohmann::json; // 开始声明MiraiCP常量声明代码 /// MiraiCP当前版本 - const std::string MiraiCPVersion = "v2.7-RC-dev3"; + const std::string MiraiCPVersion = "v2.7-RC-dev4"; /// @brief 插件信息 class PluginConfig{ diff --git a/kotlin/gradle/libs.versions.toml b/kotlin/gradle/libs.versions.toml index 0c0843121..cb6bdc788 100644 --- a/kotlin/gradle/libs.versions.toml +++ b/kotlin/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] kotlinVersion = "1.5.10" miraiVersion = "2.7-RC-dev-3" -miraiCPVersion = "2.7-RC-dev3" +miraiCPVersion = "2.7-RC-dev4" [libraries] mirai-core-api = { module = "net.mamoe:mirai-core-api", version.ref = "miraiVersion" } diff --git a/kotlin/loader/src/main/kotlin/KotlinMain.kt b/kotlin/loader/src/main/kotlin/KotlinMain.kt index 45cd6c104..b5dae3763 100644 --- a/kotlin/loader/src/main/kotlin/KotlinMain.kt +++ b/kotlin/loader/src/main/kotlin/KotlinMain.kt @@ -35,6 +35,7 @@ import tech.eritquearcus.miraicp.shared.PublicShared.logger import tech.eritquearcus.miraicp.shared.PublicShared.now_tag import tech.eritquearcus.miraicp.shared.PublicShared.onEnable import java.io.File +import kotlin.system.exitProcess private fun String.decodeHex(): ByteArray { check(length % 2 == 0) { "Must have an even length" } @@ -153,15 +154,36 @@ fun main(args: Array){ var f = File(path) when(args.size) { 1 -> { + if(args[0] == "-g"){ + File("config.json").writeText( + """ + { + "accounts": [{ + "id": qqid, + "passwords": "passwords密码", + "protocol": "pad", + "heatBeat": "STAT_HB", + "md5": false, + "autoLogin": false + }], + "cppPath": "dll路径" + } + + """.trimIndent() + ) + println("生成成功") + exitProcess(0) + } f = File(args[0]) if (!f.exists() || !f.isFile || !f.canRead()) { - println("配置文件路径(${f.absolutePath})读取错误,文件不存在/不是文件/不可读, 使用默认路径重试") + println("配置文件路径(${f.absolutePath})读取错误,文件不存在/不是文件/不可读, 使用默认路径(./config.json)重试") f = File(path) if (!f.exists() || !f.isFile || !f.canRead()) { f = File(path) if (!f.exists() || !f.isFile || !f.canRead()) { println("默认配置文件路径(${f.absolutePath})读取错误,文件不存在/不是文件/不可读") - return + println("使用 -g 可以生成config.json模板(java -jar MiraiCP-loader-.jar -g)") + exitProcess(1) } } } @@ -171,7 +193,9 @@ fun main(args: Array){ f = File(path) if (!f.exists() || !f.isFile || !f.canRead()) { println("默认配置文件路径(${f.absolutePath})读取错误,文件不存在/不是文件/不可读") - return + println("使用 -g 可以生成config.json模板(java -jar MiraiCP-loader-.jar -g)") + System.`in`.read() + exitProcess(1) } } } diff --git a/kotlin/loader/src/main/kotlin/console/Console.kt b/kotlin/loader/src/main/kotlin/console/Console.kt index e51a8c841..d8528f049 100644 --- a/kotlin/loader/src/main/kotlin/console/Console.kt +++ b/kotlin/loader/src/main/kotlin/console/Console.kt @@ -24,6 +24,7 @@ import net.mamoe.mirai.utils.PlatformLogger import org.fusesource.jansi.Ansi import org.jline.reader.LineReader import org.jline.reader.LineReaderBuilder +import org.jline.reader.UserInterruptException import org.jline.reader.impl.completer.NullCompleter import org.jline.terminal.Terminal import org.jline.terminal.TerminalBuilder @@ -31,6 +32,7 @@ import org.jline.terminal.impl.AbstractWindowsTerminal import tech.eritquearcus.miraicp.loader.KotlinMain import tech.eritquearcus.miraicp.shared.PublicShared import java.time.LocalDateTime +import kotlin.system.exitProcess @OptIn(MiraiInternalApi::class) object Console { @@ -93,6 +95,8 @@ object Console { } catch (e: CancellationException) { PublicShared.logger.error(e) return@launch + }catch(e: UserInterruptException){ + exitProcess(1) } if (re.isEmpty() || re.isBlank()) continue Command.parse(re) diff --git a/kotlin/plugin/build.gradle.kts b/kotlin/plugin/build.gradle.kts index c08bb187d..664667cde 100644 --- a/kotlin/plugin/build.gradle.kts +++ b/kotlin/plugin/build.gradle.kts @@ -45,7 +45,7 @@ mavenCentralPublish { publicationConfigurators.add { groupId = "io.github.nambers" artifactId = "MiraiCP-plugin" -// artifact("MiraiCP-plugin-2.7-RC-dev3.mirai.jar") + description = "C++ SDK of Mirai" artifact(tasks["buildPlugin"]) this.pom { name.set("MiraiCP-plugin") diff --git a/kotlin/plugin/src/main/kotlin/PluginMain.kt b/kotlin/plugin/src/main/kotlin/PluginMain.kt index 33d73e71b..9b5f84695 100644 --- a/kotlin/plugin/src/main/kotlin/PluginMain.kt +++ b/kotlin/plugin/src/main/kotlin/PluginMain.kt @@ -31,7 +31,7 @@ object PluginMain : KotlinPlugin( JvmPluginDescription( id = "tech.eritquearcus.miraiCP", name = "miraiCP", - version = "2.7-RC-dev3" + version = "2.7-RC-dev4" ){ author("Eritque arcus") } diff --git a/kotlin/shared/src/main/kotlin/PublicShared.kt b/kotlin/shared/src/main/kotlin/PublicShared.kt index 998dbd506..b2d1c7cb7 100644 --- a/kotlin/shared/src/main/kotlin/PublicShared.kt +++ b/kotlin/shared/src/main/kotlin/PublicShared.kt @@ -59,7 +59,7 @@ object PublicShared { lateinit var cpp: CPP_lib val gson: Gson = Gson() lateinit var logger: MiraiLogger - const val now_tag = "v2.7-RC-dev3" + const val now_tag = "v2.7-RC-dev4" lateinit var dll_name: String val logger4plugins: MutableMap = mutableMapOf()