Skip to content

Commit

Permalink
Apply Discord regexes to message addon URLs (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-295 committed Mar 29, 2024
1 parent 12b4ada commit db167af
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,15 @@ public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
}

private boolean handleMessageAddons(GuildMessageReceivedEvent event, DiscordGuildMessagePreProcessEvent preEvent, List<Role> selectedRoles, Role topRole, String url) {
// apply regex filters to url
for (Map.Entry<Pattern, String> entry : DiscordSRV.getPlugin().getDiscordRegexes().entrySet()) {
url = entry.getKey().matcher(url).replaceAll(entry.getValue());
if (StringUtils.isBlank(url)) {
DiscordSRV.debug(Debug.DISCORD_TO_MINECRAFT, "Not processing Discord message addon because its URL was cleared by a filter: " + entry.getKey().pattern());
return false;
}
}

// get the correct format message
String destinationGameChannelNameForTextChannel = DiscordSRV.getPlugin().getDestinationGameChannelNameForTextChannel(event.getChannel());
String placedMessage = MessageFormatResolver.getMessageFormat(selectedRoles, destinationGameChannelNameForTextChannel);
Expand Down

0 comments on commit db167af

Please sign in to comment.