[+] Done all the requested changes!

This commit is contained in:
abhiram 2021-04-12 15:44:51 +05:30
parent b852ea1822
commit 385fc77771
2 changed files with 17 additions and 8 deletions

View File

@ -296,9 +296,9 @@
<version>3.8.1</version> <version>3.8.1</version>
<configuration> <configuration>
<outputFileName>TotalFreedomMod.jar</outputFileName> <outputFileName>TotalFreedomMod.jar</outputFileName>
<compilerVersion>1.8</compilerVersion> <compilerVersion>11</compilerVersion>
<source>1.8</source> <source>11</source>
<target>1.8</target> <target>11</target>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -62,7 +62,7 @@ public class Discord extends FreedomService
public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR; public ScheduledThreadPoolExecutor RATELIMIT_EXECUTOR;
public List<CompletableFuture<Message>> sentMessages = new ArrayList<>(); public List<CompletableFuture<Message>> sentMessages = new ArrayList<>();
public Boolean enabled = false; public Boolean enabled = false;
private final Pattern discord_mention_pattern = Pattern.compile("(<@!?([0-9]{16,20})>)"); private final Pattern DISCORD_MENTION_PATTERN = Pattern.compile("(<@!?([0-9]{16,20})>)");
public static String getMD5(String string) public static String getMD5(String string)
{ {
@ -412,11 +412,11 @@ public class Discord extends FreedomService
} }
// Patch FS-191 start // Patch FS-191 start
Matcher mention_matcher = this.discord_mention_pattern.matcher(message); Matcher DISCORD_MENTION_MATCHER = this.DISCORD_MENTION_PATTERN.matcher(message);
while (mention_matcher.find()) { while (DISCORD_MENTION_MATCHER.find()) {
String mention = mention_matcher.group(1); String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, "[UserMention-redacted]"); message = message.replace(mention, mention.replace('@',' '));
} }
// Patch FS-191 end // Patch FS-191 end
@ -445,6 +445,15 @@ public class Discord extends FreedomService
message = StringUtils.remove(message, "§"); message = StringUtils.remove(message, "§");
} }
// Patch FS-191 start
Matcher DISCORD_MENTION_MATCHER = this.DISCORD_MENTION_PATTERN.matcher(message);
while (DISCORD_MENTION_MATCHER.find()) {
String mention = DISCORD_MENTION_MATCHER.group(1);
message = message.replace(mention, mention.replace('@',' '));
}
// Patch FS-191 end
if (enabled && !chat_channel_id.isEmpty()) if (enabled && !chat_channel_id.isEmpty())
{ {
CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true); CompletableFuture<Message> sentMessage = Objects.requireNonNull(bot.getTextChannelById(chat_channel_id)).sendMessage(deformat(message)).submit(true);