4 Commits

Author SHA1 Message Date
907a30b654 Update Regex 2023-02-02 10:02:10 +00:00
52b61d41d1 Update version to 0.1.1 2023-02-02 09:57:37 +00:00
0975e7e49c Update Regex to \b(\d*)[dD](\d+)\b 2023-02-02 17:40:35 +08:00
f631218c0c Fix value bounds 2023-01-31 22:32:32 +08:00
3 changed files with 6 additions and 6 deletions

View File

@@ -5,4 +5,4 @@
`d20` 表示投出`1``20`面骰子。
匹配的正则表达式如下`(\d*)[dD](\d+)`
匹配的正则表达式如下`\b(\d*)[dD](\d+)\b`

View File

@@ -7,7 +7,7 @@ plugins {
}
group = "top.jie65535"
version = "0.1.0"
version = "0.1.1"
repositories {
maven("https://maven.aliyun.com/repository/public")

View File

@@ -12,12 +12,12 @@ object JDice : KotlinPlugin(
JvmPluginDescription(
id = "top.jie65535.dice",
name = "J Dice",
version = "0.1.0",
version = "0.1.1",
) {
author("jie65535")
}
) {
private val regex = Regex("""(\d*)[dD](\d+)""")
private val regex = Regex("""\b(\d*)[dD](\d+)\b""")
private val random = Random(System.currentTimeMillis())
override fun onEnable() {
@@ -28,7 +28,7 @@ object JDice : KotlinPlugin(
val count = if (c.isEmpty()) 1 else c.toInt()
val top = d.toInt()
if (count > 0 && top > 1) {
val value = random.nextInt(count, count * top) + 1
val value = random.nextInt(count, count * top + 1)
subject.sendMessage(message.quote() + value.toString())
}
}
@@ -36,4 +36,4 @@ object JDice : KotlinPlugin(
logger.info { "Plugin loaded. https://github.com/jie65535/JDice" }
}
}
}