mirror of
https://github.com/jie65535/mirai-console-j24-plugin.git
synced 2025-06-01 17:29:15 +08:00
Update prefix
This commit is contained in:
parent
c3354b2207
commit
2bed56e1b5
@ -19,6 +19,8 @@ object PluginMain : KotlinPlugin(
|
||||
) {
|
||||
private val games: MutableMap<Long, Point24> = mutableMapOf()
|
||||
|
||||
private const val prefix = "="
|
||||
|
||||
override fun onEnable() {
|
||||
logger.info { "Plugin loaded" }
|
||||
PluginCommand.register()
|
||||
@ -29,20 +31,19 @@ object PluginMain : KotlinPlugin(
|
||||
startsWith("24点") and content { PluginConfig.enabledGroups.contains(this.group.id) } quoteReply {
|
||||
val game = Point24()
|
||||
games[this.sender.id] = game
|
||||
"你抽到了 [${game.points[0]}] [${game.points[1]}] [${game.points[2]}] [${game.points[3]}]\n" +
|
||||
"请用以上四组数字组合成结果为24的算式,以“答”开头验证"
|
||||
"请用 [${game.points[0]}] [${game.points[1]}] [${game.points[2]}] [${game.points[3]}] 组成结果为24的算式,以'$prefix'开头验证"
|
||||
}
|
||||
|
||||
startsWith("答") and content { PluginConfig.enabledGroups.contains(this.group.id) } quoteReply {
|
||||
startsWith(prefix) and content { PluginConfig.enabledGroups.contains(this.group.id) } quoteReply {
|
||||
val game = games[sender.id]
|
||||
if (game == null) {
|
||||
"你还没有抽数字哦,说“24点”来开始游戏吧"
|
||||
} else {
|
||||
try {
|
||||
val result = game.evaluate(message.contentToString().removePrefix("答").trim())
|
||||
val result = game.evaluate(message.contentToString().removePrefix(prefix).trim())
|
||||
if (result == 24.0) {
|
||||
games.remove(sender.id)
|
||||
"恭喜你,答对了!"
|
||||
"厉害,答对了!"
|
||||
} else {
|
||||
"答错了,计算结果为 $result"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user