From 5ffc295fa7f3d29d04f8f0c561d7906a86869348 Mon Sep 17 00:00:00 2001 From: Devoxin Date: Sat, 6 Apr 2019 21:47:58 +0100 Subject: [PATCH] lit --- src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt | 2 +- .../kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt b/src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt index 69c7530..1b86bb4 100644 --- a/src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt +++ b/src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt @@ -22,7 +22,7 @@ class EmojiParser : Parser { } companion object { - public val EMOJI_REGEX = Pattern.compile("<(a)?:(\\w+):(\\d{17,21})") + public val EMOJI_REGEX = Pattern.compile("<(a)?:(\\w+):(\\d{17,21})")!! } } \ No newline at end of file diff --git a/src/main/kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt b/src/main/kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt index 7725c73..6b6107b 100644 --- a/src/main/kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt +++ b/src/main/kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt @@ -9,15 +9,16 @@ class SnowflakeParser : Parser { override fun parse(ctx: Context, param: String): Optional { val match = snowflakeMatch.matcher(param) - if (match.matches()) { // TODO: Monitor this, revert to .find() if issues. - return Optional.of(match.group().toLong()) + if (match.matches()) { + val id = match.group("sid") ?: match.group("id") + return Optional.of(id.toLong()) } return Optional.empty() } companion object { - private val snowflakeMatch = Pattern.compile("[0-9]{17,21}") + private val snowflakeMatch = Pattern.compile("^(?:<(?:@!?|@&|#)(?[0-9]{17,21})>|(?[0-9]{17,21}))$") } } \ No newline at end of file