mirai/mirai-console/tools/intellij-plugin/resources/fileTemplates/j2ee/RunTerminal.kt.ft

30 lines
986 B
Plaintext
Raw Normal View History

package $PACKAGE_NAME
import java.io.File
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
fun setupWorkingDir() {
// see: net.mamoe.mirai.console.terminal.MiraiConsoleImplementationTerminal
System.setProperty("user.dir", File("debug-sandbox").absolutePath)
}
suspend fun main() {
setupWorkingDir()
MiraiConsoleTerminalLoader.startAsDaemon()
2021-06-07 21:26:57 +08:00
val pluginInstance = ${CLASS_NAME}#if (${LANGUAGE_TYPE} != "Kotlin").INSTANCE #end
2021-06-07 21:26:57 +08:00
pluginInstance.load() // 主动加载插件, Console 会调用 ${CLASS_NAME}.onLoad
pluginInstance.enable() // 主动启用插件, Console 会调用 ${CLASS_NAME}.onEnable
val bot = MiraiConsole.addBot(123456, "").alsoLogin() // 登录一个测试环境的 Bot
MiraiConsole.job.join()
}