Skip to content

Commit 881df72

Browse files
committed
Add message for command "/aqqbot reload"
1 parent b22833c commit 881df72

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=top.alazeprt.aqqbot
2-
version=1.0.5-beta
2+
version=1.0.5
33
kotlin.incremental=true
44
kotlin.incremental.java=true
55
kotlin.caching.enabled=true

src/main/kotlin/top/alazeprt/aqqbot/command/ABotCommand.kt

+8-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import top.alazeprt.aqqbot.AQQBot.messageConfig
1717
import top.alazeprt.aqqbot.AQQBot.oneBotClient
1818
import top.alazeprt.aqqbot.DependencyImpl
1919
import top.alazeprt.aqqbot.qq.BotListener
20+
import top.alazeprt.aqqbot.util.AI18n.get
2021
import java.net.URI
2122

2223
@CommandHeader("aqqbot", ["abot", "qqbot"], permission = "aqqbot.command")
2324
object ABotCommand {
2425
@CommandBody
2526
val reload = subCommand {
2627
execute<CommandSender> { sender, _, _ ->
27-
sender.sendMessage("§a正在重载插件配置文件...")
2828
val s = System.currentTimeMillis()
2929
submit(async = true) {
3030
info("Reloading AQQBot ...")
@@ -50,9 +50,15 @@ object ABotCommand {
5050
oneBotClient = BotClient(URI.create(url))
5151
oneBotClient.connect()
5252
oneBotClient.registerEvent(BotListener())
53-
sender.sendMessage("§a重载完成!耗时 §e${System.currentTimeMillis() - s} ms")
53+
sender.sendMessage(formatString(get("game.reload", mutableMapOf("time" to (System.currentTimeMillis() - s).toString()))))
5454
info("Reloaded AQQBot in ${System.currentTimeMillis() - s} ms")
5555
}
5656
}
5757
}
58+
59+
private fun formatString(input: String): String {
60+
return input.replace(Regex("&([0-9a-fklmnor])")) { matchResult ->
61+
"§" + matchResult.groupValues[1]
62+
}
63+
}
5864
}

src/main/resources/config.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# 存储相关配置
1+
# AQQBot 配置文件
2+
# 可使用 /aqqbot reload 重载
3+
4+
# 存储相关配置 (重启后生效)
25
storage:
36
# 存储方式
47
# 可选方式: file, sqlite, mysql

src/main/resources/messages.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 语言文件
22
# 以${开头, }结尾 (如${name}) 的是占位符, 在实际中会被替换
3+
# 可使用 /aqqbot reload 重载
34

45
# 此部分为发送到Q群的消息
56
qq:
@@ -68,4 +69,5 @@ qq:
6869
# 此部分为发送到游戏/在游戏内提示的消息 (使用&代表颜色符号)
6970
game:
7071
not_bind: "[AQQBot] 你的账号还没有绑定QQ!\n请通过在QQ群发送${command} <游戏名称> 来绑定!" # ${command}为你设置的第一个绑定命令, 如: /bind
71-
chat_from_qq: "&8[&aQQ群(${groupId})&8] &b${userName}: &f${message}"
72+
chat_from_qq: "&8[&aQQ群(${groupId})&8] &b${userName}: &f${message}"
73+
reload: "&a[AQQBot] 重载完成! 耗时 &e${time} ms"

0 commit comments

Comments
 (0)