File tree Expand file tree Collapse file tree 6 files changed +72
-11
lines changed
Expand file tree Collapse file tree 6 files changed +72
-11
lines changed Original file line number Diff line number Diff line change 11<component name =" ProjectRunConfigurationManager" >
22 <configuration default =" false" name =" RunMiraiKt" type =" JetRunConfigurationType" nameIsGenerated =" true" >
3- <module name =" mirai-console-plugin-template.test" />
43 <option name =" VM_PARAMETERS" value =" " />
54 <option name =" PROGRAM_PARAMETERS" value =" " />
65 <option name =" ALTERNATIVE_JRE_PATH_ENABLED" value =" false" />
76 <option name =" ALTERNATIVE_JRE_PATH" />
87 <option name =" PASS_PARENT_ENVS" value =" true" />
9- <option name =" MAIN_CLASS_NAME" value =" org.example.mirai.plugin.RunMiraiKt" />
8+ <option name =" MAIN_CLASS_NAME" value =" net.mamoe.mirai.console.plugins.chat.command.RunMiraiKt" />
9+ <option name =" WORKING_DIRECTORY" value =" file://$PROJECT_DIR$/run" />
10+ <module name =" " />
11+ <method v =" 2" >
12+ <option name =" Make" enabled =" true" />
13+ </method >
14+ </configuration >
15+ <configuration default =" false" name =" RunMiraiKt" type =" JetRunConfigurationType" nameIsGenerated =" true" >
16+ <module name =" chat-command.test" />
17+ <option name =" VM_PARAMETERS" value =" " />
18+ <option name =" PROGRAM_PARAMETERS" value =" " />
19+ <option name =" ALTERNATIVE_JRE_PATH_ENABLED" value =" false" />
20+ <option name =" ALTERNATIVE_JRE_PATH" />
21+ <option name =" PASS_PARENT_ENVS" value =" true" />
22+ <option name =" MAIN_CLASS_NAME" value =" net.mamoe.mirai.console.plugins.chat.command.RunMiraiKt" />
1023 <option name =" WORKING_DIRECTORY" value =" file://$PROJECT_DIR$/run" />
1124 <method v =" 2" >
1225 <option name =" Make" enabled =" true" />
Original file line number Diff line number Diff line change 1+ <component name =" ProjectRunConfigurationManager" >
2+ <configuration default =" false" name =" chat-command [buildPlugin]" type =" GradleRunConfiguration" factoryName =" Gradle" >
3+ <ExternalSystemSettings >
4+ <option name =" executionName" />
5+ <option name =" externalProjectPath" value =" $PROJECT_DIR$" />
6+ <option name =" externalSystemIdString" value =" GRADLE" />
7+ <option name =" scriptParameters" value =" " />
8+ <option name =" taskDescriptions" >
9+ <list />
10+ </option >
11+ <option name =" taskNames" >
12+ <list >
13+ <option value =" buildPlugin" />
14+ </list >
15+ </option >
16+ <option name =" vmOptions" value =" " />
17+ </ExternalSystemSettings >
18+ <GradleScriptDebugEnabled >true</GradleScriptDebugEnabled >
19+ <method v =" 2" />
20+ </configuration >
21+ </component >
Original file line number Diff line number Diff line change 1- # mirai-console-plugin-template
2- Template for Mirai Console plugins
1+ # char-command
2+ 允许在聊天环境执行指令.
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ plugins {
33 kotlin(" jvm" ) version kotlinVersion
44 kotlin(" plugin.serialization" ) version kotlinVersion
55
6- id(" net.mamoe.mirai-console" ) version " 1.0.0-dev-1 "
6+ id(" net.mamoe.mirai-console" ) version " 1.0.0-dev-2 "
77}
88
99group = " net.mamoe"
Original file line number Diff line number Diff line change @@ -78,4 +78,36 @@ object PluginMain : KotlinPlugin(
7878 }
7979
8080 internal lateinit var commandListener: Listener <MessageEvent >
81- }
81+ }
82+
83+ /*
84+
85+ @ConsoleExperimentalApi("This is unstable and might get changed")
86+ override suspend fun catchExecutionException(e: Throwable) {
87+ if (this is CommandSenderOnMessage<*>) {
88+ val cause = e.rootCauseOrSelf
89+
90+ // CommandArgumentParserException 作为 IllegalCommandArgumentException 不会再进入此函数
91+ // 已在
92+ // - [console] CommandManagerImpl.commandListener
93+ // - [terminal] ConsoleThread.kt
94+ // 处理
95+
96+ val message = cause
97+ .takeIf { it is CommandArgumentParserException }?.message
98+ ?: "${cause::class.simpleName.orEmpty()}: ${cause.message}"
99+
100+
101+ sendMessage(message) // \n\n60 秒内发送 stacktrace 查看堆栈信息
102+ this@AbstractCommandSender.launch(CoroutineName("stacktrace delayer from command")) {
103+ if (fromEvent.nextMessageOrNull(60_000) {
104+ it.message.contentEquals("stacktrace") || it.message.contentEquals("stack")
105+ } != null) {
106+ sendMessage(e.stackTraceToString())
107+ }
108+ }
109+ } else {
110+ sendMessage(e.stackTraceToString())
111+ }
112+ }
113+ */
Original file line number Diff line number Diff line change 11package net.mamoe.mirai.console.plugins.chat.command
22
3- import net.mamoe.mirai.alsoLogin
43import net.mamoe.mirai.console.MiraiConsole
54import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.enable
65import net.mamoe.mirai.console.plugin.PluginManager.INSTANCE.load
@@ -12,9 +11,5 @@ suspend fun main() {
1211 PluginMain .load()
1312 PluginMain .enable()
1413
15- val bot = MiraiConsole .addBot(123456 , " " ) {
16- fileBasedDeviceInfo()
17- }.alsoLogin()
18-
1914 MiraiConsole .job.join()
2015}
You can’t perform that action at this time.
0 commit comments