Update prefix

This commit is contained in:
2022-07-08 20:57:00 +08:00
parent c3354b2207
commit 2bed56e1b5

View File

@ -19,6 +19,8 @@ object PluginMain : KotlinPlugin(
) { ) {
private val games: MutableMap<Long, Point24> = mutableMapOf() private val games: MutableMap<Long, Point24> = mutableMapOf()
private const val prefix = "="
override fun onEnable() { override fun onEnable() {
logger.info { "Plugin loaded" } logger.info { "Plugin loaded" }
PluginCommand.register() PluginCommand.register()
@ -29,20 +31,19 @@ object PluginMain : KotlinPlugin(
startsWith("24点") and content { PluginConfig.enabledGroups.contains(this.group.id) } quoteReply { startsWith("24点") and content { PluginConfig.enabledGroups.contains(this.group.id) } quoteReply {
val game = Point24() val game = Point24()
games[this.sender.id] = game games[this.sender.id] = game
"你抽到了 [${game.points[0]}] [${game.points[1]}] [${game.points[2]}] [${game.points[3]}]\n" + "请用 [${game.points[0]}] [${game.points[1]}] [${game.points[2]}] [${game.points[3]}] 组成结果为24的算式以'$prefix'开头验证"
"请用以上四组数字组合成结果为24的算式以“答”开头验证"
} }
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] val game = games[sender.id]
if (game == null) { if (game == null) {
"你还没有抽数字哦说“24点”来开始游戏吧" "你还没有抽数字哦说“24点”来开始游戏吧"
} else { } else {
try { try {
val result = game.evaluate(message.contentToString().removePrefix("").trim()) val result = game.evaluate(message.contentToString().removePrefix(prefix).trim())
if (result == 24.0) { if (result == 24.0) {
games.remove(sender.id) games.remove(sender.id)
"恭喜你,答对了!" "厉害,答对了!"
} else { } else {
"答错了,计算结果为 $result" "答错了,计算结果为 $result"
} }