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 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"
}