Skip to content

Commit

Permalink
Merge pull request #51 from nicholasgrose/chat_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgrose authored Dec 27, 2022
2 parents 914ecf6 + 1505b39 commit 1b12256
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import io.papermc.paper.event.player.AsyncChatEvent

private val textProcessor = TextProcessor(
listOf(
UserMentionTokenProcessor(),
UserQuoteMentionTokenProcessor(),
RoleMentionTokenProcessor(),
RoleQuoteMentionTokenProcessor(),
TextChannelMentionTokenProcessor(),
VoiceChannelMentionTokenProcessor(),
UrlTokenProcessor(),
VoiceChannelMentionTokenProcessor(),
TextChannelMentionTokenProcessor(),
RoleQuoteMentionTokenProcessor(),
RoleMentionTokenProcessor(),
UserQuoteMentionTokenProcessor(),
UserMentionTokenProcessor(),
TextTokenProcessor()
)
)
Expand Down Expand Up @@ -72,10 +72,11 @@ suspend fun discordMessageWithContent(
contentProvider: (MessageProcessingResult) -> String
): (MessageCreateBuilder.() -> Unit)? {
val result = processMessageText(message)
val discordContent = contentProvider(result)

return if (result.successful) {
{
content = contentProvider(result)
content = discordContent
}
} else null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RoleQuoteMentionTokenProcessor : TokenProcessor<TokenProcessingResult, Uni

override suspend fun process(token: LixyToken, additionalData: Unit): TokenProcessingResult {
val tokenString = token.string
val roleString = tokenString.substring(ROLE_QUOTE_MENTION_START_INDEX until tokenString.length)
val roleString = tokenString.substring(ROLE_QUOTE_MENTION_START_INDEX until tokenString.length - 1)

return MentionResult.role(roleString)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserQuoteMentionTokenProcessor : TokenProcessor<TokenProcessingResult, Uni

override suspend fun process(token: LixyToken, additionalData: Unit): TokenProcessingResult {
val tokenString = token.string
val nameString = tokenString.substring(USER_QUOTE_MENTION_START_INDEX until tokenString.length)
val nameString = tokenString.substring(USER_QUOTE_MENTION_START_INDEX until tokenString.length - 1)

return MentionResult.userMention(nameString)
}
Expand Down

0 comments on commit 1b12256

Please sign in to comment.