Skip to content

Commit

Permalink
lit
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Apr 6, 2019
1 parent b281c2b commit 5ffc295
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/me/devoxin/flight/parsers/EmojiParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EmojiParser : Parser<Emoji> {
}

companion object {
public val EMOJI_REGEX = Pattern.compile("<(a)?:(\\w+):(\\d{17,21})")
public val EMOJI_REGEX = Pattern.compile("<(a)?:(\\w+):(\\d{17,21})")!!
}

}
7 changes: 4 additions & 3 deletions src/main/kotlin/me/devoxin/flight/parsers/SnowflakeParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ class SnowflakeParser : Parser<Long> {
override fun parse(ctx: Context, param: String): Optional<Long> {
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("^(?:<(?:@!?|@&|#)(?<sid>[0-9]{17,21})>|(?<id>[0-9]{17,21}))$")
}

}

0 comments on commit 5ffc295

Please sign in to comment.