From e1cc59449b8e8a23411f21a8ec01bc451bc98e99 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Thu, 21 Apr 2022 23:54:26 -0700 Subject: [PATCH] Improved regex --- src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt index 3619ec7..c32f781 100644 --- a/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt +++ b/src/main/kotlin/net/thauvin/erik/mobibot/modules/Dice.kt @@ -43,7 +43,7 @@ class Dice : AbstractModule() { override fun commandResponse(channel: String, cmd: String, args: String, event: GenericMessageEvent) { val arg = if (args.isBlank()) "2d6" else args.trim() - val match = Regex("^([1-9]|[12][0-9]|3[0-2])[dD]([1-9]|[12][0-9]|3[0-2])$").find(arg) + val match = Regex("^([1-9]|[12]\\d|3[0-2])[dD]([1-9]|[12]\\d|3[0-2])$").find(arg) if (match != null) { val (dice, sides) = match.destructured event.respond("you rolled " + roll(dice.toInt(), sides.toInt()))