diff --git a/.github/workflows/Gradle CI.yml b/.github/workflows/Gradle CI.yml
index 029ac50..97b38a3 100644
--- a/.github/workflows/Gradle CI.yml
+++ b/.github/workflows/Gradle CI.yml
@@ -1,47 +1,29 @@
-name: Gradle CI
+name: build
-# Controls when the action will run.
on:
- # Triggers the workflow on push and pull request events but only for the master branch
push:
- branches:
- - master
- pull_request:
- branches:
- - master
-
- # Allows to run this workflow manually from the Actions tab
- workflow_dispatch:
+ branches: [ master ]
jobs:
-
build:
-
- name: Gradle-Build
-
- # The type of runner that the job will run on
- runs-on: ubuntu-20.04
-
- # Steps represent a sequence of tasks that will be executed as part of the job
+ runs-on: ubuntu-latest
steps:
- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- - name: Checkout
- uses: actions/checkout@v3
-
- # Setup JDK
- - name: Setup Java JDK
- uses: actions/setup-java@v3
+ - name: Checkout repository
+ uses: actions/checkout@v2
+ - name: Java setup
+ uses: actions/setup-java@v2
with:
+ distribution: 'adopt'
java-version: 11
- distribution: 'zulu'
- cache: 'gradle'
-
- # Validate Gradle Wrapper
- - name: Gradle Wrapper Validation
- uses: gradle/wrapper-validation-action@v1.0.5
-
- # Build
- - name: Make gradlew executable
- run: chmod +x ./gradlew
- - name: Build with Gradle
- run: ./gradlew build
+ check-latest: true
+ - uses: burrunan/gradle-cache-action@v1
+ name: BuildPluginLegacy
+ with:
+ job-id: jdk11
+ arguments: buildPluginLegacy
+ gradle-version: wrapper
+ - name: Upload build artifacts
+ uses: actions/upload-artifact@v2
+ with:
+ name: lgz-bot
+ path: build/mirai/*.jar
diff --git a/README.md b/README.md
index c0285b4..832695e 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,4 @@
-# mirai-console-plugin-template
+# mirai-quotly-bot
-[Mirai Console](https://github.com/mamoe/mirai-console) 插件模板, 使用 Kotlin + Gradle.
-
-[如何使用](https://github.com/project-mirai/how-to-use-plugin-template)
+A qq quotly plugin depend on [quote-api](https://github.com/LyoSU/quote-api)
+listenport=3000
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index de06fa0..b85f0b5 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -1,17 +1,33 @@
plugins {
- val kotlinVersion = "1.6.10"
+ val kotlinVersion = "1.8.0"
kotlin("jvm") version kotlinVersion
kotlin("plugin.serialization") version kotlinVersion
id("net.mamoe.mirai-console") version "2.13.2"
}
-group = "org.example"
+dependencies {
+ val overflow_version = "2.16.0-db61867-SNAPSHOT"
+ implementation("org.json:json:20230227")
+ implementation("cn.hutool:hutool-http:5.8.26")
+ implementation("org.apache.httpcomponents:httpclient:4.5.14")
+
+ compileOnly("top.mrxiaom:overflow-core-api:$overflow_version")
+ compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:2.8.0")
+ compileOnly("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"))))
+}
+
+group = "ltd.guimc.plugin"
version = "0.1.0"
repositories {
if (System.getenv("CI")?.toBoolean() != true) {
maven("https://maven.aliyun.com/repository/public") // 阿里云国内代理仓库
}
+ maven { url = uri("https://repo.repsy.io/mvn/chrynan/public") }
+ maven("https://s01.oss.sonatype.org/content/repositories/snapshots")
mavenCentral()
}
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/settings.gradle.kts b/settings.gradle.kts
index e47c53b..37553f2 100644
--- a/settings.gradle.kts
+++ b/settings.gradle.kts
@@ -1 +1 @@
-rootProject.name = "mirai-console-plugin-template"
\ No newline at end of file
+rootProject.name = "mirai-quotly-bot"
\ No newline at end of file
diff --git a/src/main/java/org/example/mirai/plugin/JavaPluginMain.java b/src/main/java/org/example/mirai/plugin/JavaPluginMain.java
deleted file mode 100644
index a32d52e..0000000
--- a/src/main/java/org/example/mirai/plugin/JavaPluginMain.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package org.example.mirai.plugin;
-
-import kotlin.Lazy;
-import kotlin.LazyKt;
-import net.mamoe.mirai.console.permission.*;
-import net.mamoe.mirai.console.plugin.jvm.JavaPlugin;
-import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription;
-import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescriptionBuilder;
-import net.mamoe.mirai.contact.Member;
-import net.mamoe.mirai.contact.User;
-import net.mamoe.mirai.event.Event;
-import net.mamoe.mirai.event.EventChannel;
-import net.mamoe.mirai.event.GlobalEventChannel;
-import net.mamoe.mirai.event.events.FriendMessageEvent;
-import net.mamoe.mirai.event.events.GroupMessageEvent;
-
-
-/**
- * 使用 Java 请把
- * {@code /src/main/resources/META-INF.services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin}
- * 文件内容改成 {@code org.example.mirai.plugin.JavaPluginMain}
- * 也就是当前主类全类名
- *
- * 使用 Java 可以把 kotlin 源集删除且不会对项目有影响
- *
- * 在 {@code settings.gradle.kts} 里改构建的插件名称、依赖库和插件版本
- *
- * 在该示例下的 {@link JvmPluginDescription} 修改插件名称,id 和版本等
- *
- * 可以使用 {@code src/test/kotlin/RunMirai.kt} 在 IDE 里直接调试,
- * 不用复制到 mirai-console-loader 或其他启动器中调试
- */
-
-public final class JavaPluginMain extends JavaPlugin {
- public static final JavaPluginMain INSTANCE = new JavaPluginMain();
-
- private JavaPluginMain() {
- super(new JvmPluginDescriptionBuilder("org.example.mirai-example", "0.1.0")
- .info("EG")
- .build());
- }
-
- @Override
- public void onEnable() {
- getLogger().info("日志");
- EventChannel eventChannel = GlobalEventChannel.INSTANCE.parentScope(this);
- eventChannel.subscribeAlways(GroupMessageEvent.class, g -> {
- //监听群消息
- getLogger().info(g.getMessage().contentToString());
-
- });
- eventChannel.subscribeAlways(FriendMessageEvent.class, f -> {
- //监听好友消息
- getLogger().info(f.getMessage().contentToString());
- });
-
- myCustomPermission.getValue(); // 注册权限
- }
-
- // region mirai-console 权限系统示例
- public static final Lazy myCustomPermission = LazyKt.lazy(() -> { // Lazy: Lazy 是必须的, console 不允许提前访问权限系统
- // 注册一条权限节点 org.example.mirai-example:my-permission
- // 并以 org.example.mirai-example:* 为父节点
-
-
- // @param: parent: 父权限
- // 在 Console 内置权限系统中, 如果某人拥有父权限
- // 那么意味着此人也拥有该权限 (org.example.mirai-example:my-permission)
- // @func: PermissionIdNamespace.permissionId: 根据插件 id 确定一条权限 id
- try {
- return PermissionService.getInstance().register(
- INSTANCE.permissionId("my-permission"),
- "一条自定义权限",
- INSTANCE.getParentPermission()
- );
- } catch (PermissionRegistryConflictException e) {
- throw new RuntimeException(e);
- }
- });
-
- public static boolean hasCustomPermission(User usr) {
- PermitteeId pid;
- if (usr instanceof Member) {
- pid = new AbstractPermitteeId.ExactMember(((Member) usr).getGroup().getId(), usr.getId());
- } else {
- pid = new AbstractPermitteeId.ExactUser(usr.getId());
- }
- return PermissionService.hasPermission(pid, myCustomPermission.getValue());
- }
- // endregion
-}
diff --git a/src/main/kotlin/PluginMain.kt b/src/main/kotlin/PluginMain.kt
deleted file mode 100644
index c5fcbab..0000000
--- a/src/main/kotlin/PluginMain.kt
+++ /dev/null
@@ -1,118 +0,0 @@
-package org.example.mirai.plugin
-
-import net.mamoe.mirai.console.permission.AbstractPermitteeId
-import net.mamoe.mirai.console.permission.PermissionService
-import net.mamoe.mirai.console.permission.PermissionService.Companion.hasPermission
-import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
-import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
-import net.mamoe.mirai.contact.Member
-import net.mamoe.mirai.contact.User
-import net.mamoe.mirai.event.GlobalEventChannel
-import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
-import net.mamoe.mirai.event.events.FriendMessageEvent
-import net.mamoe.mirai.event.events.GroupMessageEvent
-import net.mamoe.mirai.event.events.NewFriendRequestEvent
-import net.mamoe.mirai.message.data.Image
-import net.mamoe.mirai.message.data.Image.Key.queryUrl
-import net.mamoe.mirai.message.data.PlainText
-import net.mamoe.mirai.utils.info
-
-/**
- * 使用 kotlin 版请把
- * `src/main/resources/META-INF.services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin`
- * 文件内容改成 `org.example.mirai.plugin.PluginMain` 也就是当前主类全类名
- *
- * 使用 kotlin 可以把 java 源集删除不会对项目有影响
- *
- * 在 `settings.gradle.kts` 里改构建的插件名称、依赖库和插件版本
- *
- * 在该示例下的 [JvmPluginDescription] 修改插件名称,id和版本,etc
- *
- * 可以使用 `src/test/kotlin/RunMirai.kt` 在 ide 里直接调试,
- * 不用复制到 mirai-console-loader 或其他启动器中调试
- */
-
-object PluginMain : KotlinPlugin(
- JvmPluginDescription(
- id = "org.example.mirai-example",
- name = "插件示例",
- version = "0.1.0"
- ) {
- author("作者名称或联系方式")
- info(
- """
- 这是一个测试插件,
- 在这里描述插件的功能和用法等.
- """.trimIndent()
- )
- // author 和 info 可以删除.
- }
-) {
- override fun onEnable() {
- logger.info { "Plugin loaded" }
- //配置文件目录 "${dataFolder.absolutePath}/"
- val eventChannel = GlobalEventChannel.parentScope(this)
- eventChannel.subscribeAlways {
- //群消息
- //复读示例
- if (message.contentToString().startsWith("复读")) {
- group.sendMessage(message.contentToString().replace("复读", ""))
- }
- if (message.contentToString() == "hi") {
- //群内发送
- group.sendMessage("hi")
- //向发送者私聊发送消息
- sender.sendMessage("hi")
- //不继续处理
- return@subscribeAlways
- }
- //分类示例
- message.forEach {
- //循环每个元素在消息里
- if (it is Image) {
- //如果消息这一部分是图片
- val url = it.queryUrl()
- group.sendMessage("图片,下载地址$url")
- }
- if (it is PlainText) {
- //如果消息这一部分是纯文本
- group.sendMessage("纯文本,内容:${it.content}")
- }
- }
- }
- eventChannel.subscribeAlways {
- //好友信息
- sender.sendMessage("hi")
- }
- eventChannel.subscribeAlways {
- //自动同意好友申请
- accept()
- }
- eventChannel.subscribeAlways {
- //自动同意加群申请
- accept()
- }
-
- myCustomPermission // 注册权限
- }
-
- // region console 权限系统示例
- private val myCustomPermission by lazy { // Lazy: Lazy 是必须的, console 不允许提前访问权限系统
- // 注册一条权限节点 org.example.mirai-example:my-permission
- // 并以 org.example.mirai-example:* 为父节点
-
- // @param: parent: 父权限
- // 在 Console 内置权限系统中, 如果某人拥有父权限
- // 那么意味着此人也拥有该权限 (org.example.mirai-example:my-permission)
- // @func: PermissionIdNamespace.permissionId: 根据插件 id 确定一条权限 id
- PermissionService.INSTANCE.register(permissionId("my-permission"), "一条自定义权限", parentPermission)
- }
-
- public fun hasCustomPermission(sender: User): Boolean {
- return when (sender) {
- is Member -> AbstractPermitteeId.ExactMember(sender.group.id, sender.id)
- else -> AbstractPermitteeId.ExactUser(sender.id)
- }.hasPermission(myCustomPermission)
- }
- // endregion
-}
diff --git a/src/main/kotlin/ltd/guimc/lgzbot/utils/CooldownUtils.kt b/src/main/kotlin/ltd/guimc/lgzbot/utils/CooldownUtils.kt
new file mode 100644
index 0000000..eb9f369
--- /dev/null
+++ b/src/main/kotlin/ltd/guimc/lgzbot/utils/CooldownUtils.kt
@@ -0,0 +1,43 @@
+package ltd.guimc.lgzbot.utils
+
+class CooldownUtils(val cooldown: Long) {
+ var cooldownMap: MutableMap = mutableMapOf()
+ var cooldownNoticeMap: MutableMap = mutableMapOf()
+
+ fun flag(target: Any) {
+ cooldownMap[target] = System.currentTimeMillis()
+ }
+
+ fun isTimePassed(target: Any): Boolean {
+ return isTimePassed(target, cooldown)
+ }
+
+ fun isTimePassed(target: Any, time: Long): Boolean {
+ if (cooldownMap.keys.indexOf(target) == -1) return true
+ if (System.currentTimeMillis() - cooldownMap[target]!! >= time) return true
+ return false
+ }
+
+ fun shouldSendCooldownNotice(target: Any): Boolean {
+ if (cooldownNoticeMap.keys.indexOf(target) == -1) return true
+ if (System.currentTimeMillis() - cooldownNoticeMap[target]!! >= 3000) {
+ cooldownNoticeMap[target] = System.currentTimeMillis()
+ return true
+ }
+ return false
+ }
+
+ fun getLeftTime(target: Any): Long {
+ return getLeftTime(target, cooldown)
+ }
+
+ fun getLeftTime(target: Any, time: Long): Long {
+ if (cooldownMap.keys.indexOf(target) == -1) return -1
+ return time - (System.currentTimeMillis() - cooldownMap[target]!!)
+ }
+
+ fun addLeftTime(target: Any, time: Long) {
+ if (cooldownMap.keys.indexOf(target) == -1) return
+ cooldownMap[target] = cooldownMap[target]!! + time
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/ltd/guimc/lgzbot/utils/OverflowUtils.kt b/src/main/kotlin/ltd/guimc/lgzbot/utils/OverflowUtils.kt
new file mode 100644
index 0000000..5a513ad
--- /dev/null
+++ b/src/main/kotlin/ltd/guimc/lgzbot/utils/OverflowUtils.kt
@@ -0,0 +1,24 @@
+/*
+ * THIS FILE IS PART OF lgz-bot PROJECT
+ *
+ * You must disclose the source code of your modified work and the source code you took from this project. This means you are not allowed to use code from this project (even partially) in a closed-source (or even obfuscated) application.
+ * Your modified application must also be licensed under the AGPLv3.
+ *
+ * Copyright (c) 2022 - now Guimc Team.
+ */
+
+package ltd.guimc.lgzbot.utils
+
+import net.mamoe.mirai.Bot
+import top.mrxiaom.overflow.contact.RemoteBot.Companion.asRemoteBot
+
+object OverflowUtils {
+ fun checkOverflowCore(): Boolean {
+ try {
+ Class.forName("top.mrxiaom.overflow.internal.Overflow")
+ return true
+ } catch (ignored: ClassNotFoundException) {
+ return false
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/kotlin/ltd/guimc/plugin/quotly/ImageUtils.kt b/src/main/kotlin/ltd/guimc/plugin/quotly/ImageUtils.kt
new file mode 100644
index 0000000..d098c14
--- /dev/null
+++ b/src/main/kotlin/ltd/guimc/plugin/quotly/ImageUtils.kt
@@ -0,0 +1,21 @@
+package ltd.guimc.plugin.quotly
+
+import cn.hutool.core.codec.Base64
+import net.mamoe.mirai.Bot
+import net.mamoe.mirai.contact.Contact
+import net.mamoe.mirai.message.data.Image
+import net.mamoe.mirai.message.data.Image.Key.isUploaded
+import net.mamoe.mirai.utils.ExternalResource.Companion.toExternalResource
+
+object ImageUtils {
+ suspend fun base642imageMessage(base64: String, bot: Bot, subject: Contact): Image {
+ val inputstream = Base64.decode(base64)
+ if (inputstream != null) {
+ val image = subject.uploadImage(inputstream.toExternalResource())
+ if (image.isUploaded(bot)) {
+ return image
+ }
+ }
+ throw Exception("图片上传失败")
+ }
+}
diff --git a/src/main/kotlin/ltd/guimc/plugin/quotly/PluginMain.kt b/src/main/kotlin/ltd/guimc/plugin/quotly/PluginMain.kt
new file mode 100644
index 0000000..bbe4674
--- /dev/null
+++ b/src/main/kotlin/ltd/guimc/plugin/quotly/PluginMain.kt
@@ -0,0 +1,37 @@
+package ltd.guimc.plugin.quotly
+
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import kotlinx.coroutines.runInterruptible
+import net.mamoe.mirai.console.command.CommandManager
+import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription
+import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin
+import net.mamoe.mirai.console.plugin.name
+import net.mamoe.mirai.console.plugin.version
+import java.io.IOException
+import java.nio.file.Path
+import java.nio.file.StandardWatchEventKinds
+import kotlin.concurrent.thread
+import kotlin.io.path.name
+
+object PluginMain : KotlinPlugin(
+ JvmPluginDescription(
+ "ltd.guimc.plugin.quotly",
+ "0.0.1",
+ "QuotlyBot",
+ ){
+ author("BakaBotTeam")
+ dependsOn("xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin", false)
+ }
+) {
+ override fun onEnable() {
+ logger.info("$name v$version 正在加载喵")
+ CommandManager.registerCommand(QuotLyCommand)
+ logger.info("$name v$version 加载好了喵")
+ }
+
+ override fun onDisable() {
+ logger.info("$name v$version 卸载好了喵")
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/kotlin/ltd/guimc/plugin/quotly/QuotLyCommand.kt b/src/main/kotlin/ltd/guimc/plugin/quotly/QuotLyCommand.kt
new file mode 100644
index 0000000..ee2a060
--- /dev/null
+++ b/src/main/kotlin/ltd/guimc/plugin/quotly/QuotLyCommand.kt
@@ -0,0 +1,104 @@
+package ltd.guimc.plugin.quotly
+
+import cn.hutool.http.HttpUtil
+import kotlinx.coroutines.launch
+import ltd.guimc.lgzbot.utils.CooldownUtils
+import ltd.guimc.lgzbot.utils.OverflowUtils
+import net.mamoe.mirai.console.command.CommandSenderOnMessage
+import net.mamoe.mirai.console.command.SimpleCommand
+import net.mamoe.mirai.console.util.cast
+import net.mamoe.mirai.contact.Group
+import net.mamoe.mirai.contact.nameCardOrNick
+import net.mamoe.mirai.event.events.GroupMessageEvent
+import net.mamoe.mirai.message.data.*
+import org.json.JSONObject
+import top.mrxiaom.overflow.OverflowAPI
+import xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder
+
+
+object QuotLyCommand: SimpleCommand(
+ owner = PluginMain,
+ primaryName = "quotly",
+ description = "QuotLy"
+) {
+ /* example post value
+ {
+ "type": "quote",
+ "format": "png",
+ "backgroundColor": "#1b1429",
+ "width": 512,
+ "height": 768,
+ "scale": 2,
+ "messages": [
+ {
+ "entities": [],
+ "media": {
+ "url": "https://via.placeholder.com/1000"
+ },
+ "avatar": true,
+ "from": {
+ "id": 1,
+ "name": "Mike",
+ "photo": {
+ "url": "https://via.placeholder.com/100"
+ }
+ },
+ "text": "Hey",
+ "replyMessage": {}
+ }
+ ]
+ }
+ */
+ val cooldown = CooldownUtils(10000)
+
+ @Handler
+ fun CommandSenderOnMessage.onHandler() = launch {
+ if (!cooldown.isTimePassed(user!!)) {
+ if (cooldown.shouldSendCooldownNotice(user!!)) sendMessage("你可以在 ${cooldown.getLeftTime(user!!) / 1000} 秒后继续使用该指令")
+ return@launch
+ }
+
+ val quote = fromEvent.message.findIsInstance() ?: return@launch
+ var textMessage = quote.source.originalMessage.contentToString()
+
+ var member = subject.cast().getOrFail(quote.source.fromId)
+
+ val postValue = JSONObject(
+ " {\n" +
+ " \"type\": \"quote\",\n" +
+ " \"format\": \"png\",\n" +
+ " \"backgroundColor\": \"#1b1429\",\n" +
+ " \"width\": 512,\n" +
+ " \"height\": 768,\n" +
+ " \"scale\": 2,\n" +
+ " \"messages\": [\n" +
+ " {\n" +
+ " \"avatar\": true,\n" +
+ " \"from\": {\n" +
+ " \"id\": 1,\n" +
+ " \"name\": \"${member.nameCardOrNick}\",\n" +
+ " \"photo\": {\n" +
+ " \"url\": \"${member.avatarUrl}\"\n" +
+ " }\n" +
+ " },\n" +
+ " \"text\": \"${textMessage.replace("\n", "\\n")}\",\n" +
+ " }\n" +
+ " ]\n" +
+ " }")
+
+ cooldown.flag(user!!)
+ try {
+ val rawResp = JSONObject(HttpUtil.post("http://127.0.0.1:3000/generate", postValue.toString()))
+ val resp = rawResp.getJSONObject("result").getString("image")
+ if (!OverflowUtils.checkOverflowCore()) {
+ sendMessage(ImageUtils.base642imageMessage(resp, bot!!, subject!!))
+ } else {
+ sendMessage(OverflowAPI.get().imageFromFile("base64://"+resp))
+ }
+ } catch (e: Throwable) {
+ sendMessage("Oops, something went wrong.")
+ cooldown.addLeftTime(user!!, -10000L)
+ e.printStackTrace()
+ }
+ }
+}
diff --git a/src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin b/src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin
index 0bed70b..a9fc797 100644
--- a/src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin
+++ b/src/main/resources/META-INF/services/net.mamoe.mirai.console.plugin.jvm.JvmPlugin
@@ -1 +1 @@
-org.example.mirai.plugin.PluginMain
\ No newline at end of file
+ltd.guimc.plugin.quotly.PluginMain
\ No newline at end of file
diff --git a/src/test/kotlin/RunMirai.kt b/src/test/kotlin/RunMirai.kt
deleted file mode 100644
index b4837db..0000000
--- a/src/test/kotlin/RunMirai.kt
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.example.mirai.plugin
-
-import net.mamoe.mirai.alsoLogin
-import net.mamoe.mirai.console.MiraiConsole
-import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.enable
-import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.load
-import net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader
-
-suspend fun main() {
- if (true) {
-
- error("""
- DEPRECATED:
- 此启动方法已经被弃用, 请使用 ./gradlew runConsole 启动测试环境
-
- 详见:
- https://docs.mirai.mamoe.net/console/plugin/JVMPlugin.html#%E8%B0%83%E8%AF%95
- https://github.com/mamoe/mirai/blob/dev/mirai-console/docs/plugin/JVMPlugin.md#%E8%B0%83%E8%AF%95
- """.trimIndent())
- }
-
- MiraiConsoleTerminalLoader.startAsDaemon()
-
- //如果是Kotlin
- PluginMain.load()
- PluginMain.enable()
- //如果是Java
-// JavaPluginMain.INSTANCE.load()
-// JavaPluginMain.INSTANCE.enable()
-
- val bot = MiraiConsole.addBot(123456, "") {
- fileBasedDeviceInfo()
- }.alsoLogin()
-
- MiraiConsole.job.join()
-}
\ No newline at end of file