mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Merge pull request #48 from AtlasMediaGroup/abhi-fix
Strip role/user mentions (FS-191)
This commit is contained in:
commit
64a4e70c41
@ -13,6 +13,8 @@ import java.util.Objects;
|
|||||||
import java.util.SplittableRandom;
|
import java.util.SplittableRandom;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import javax.security.auth.login.LoginException;
|
import javax.security.auth.login.LoginException;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
@ -60,6 +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})>)");
|
||||||
|
|
||||||
public static String getMD5(String string)
|
public static String getMD5(String string)
|
||||||
{
|
{
|
||||||
@ -408,6 +411,15 @@ public class Discord extends FreedomService
|
|||||||
message = StringUtils.remove(message, "§");
|
message = StringUtils.remove(message, "§");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
|
||||||
|
|
||||||
|
while (DISCORD_MENTION_MATCHER.find())
|
||||||
|
{
|
||||||
|
String mention = DISCORD_MENTION_MATCHER.group(1);
|
||||||
|
message = message.replace(mention, mention.replace("@",""));
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
@ -433,6 +445,15 @@ public class Discord extends FreedomService
|
|||||||
message = StringUtils.remove(message, "§");
|
message = StringUtils.remove(message, "§");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Matcher DISCORD_MENTION_MATCHER = DISCORD_MENTION_PATTERN.matcher(message);
|
||||||
|
|
||||||
|
while (DISCORD_MENTION_MATCHER.find())
|
||||||
|
{
|
||||||
|
String mention = DISCORD_MENTION_MATCHER.group(1);
|
||||||
|
message = message.replace(mention, mention.replace("@",""));
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -72,10 +72,10 @@ public class FUtil
|
|||||||
"c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu
|
"c8e5af82-6aba-4dd7-83e8-474381380cc9", // Paldiu
|
||||||
"38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch
|
"38ea7c82-7bdc-4f48-b7fd-0e93fc26813d", // AwesomePinch
|
||||||
"ba5aafba-9012-418f-9819-a7020d591068", // TFTWPhoenix
|
"ba5aafba-9012-418f-9819-a7020d591068", // TFTWPhoenix
|
||||||
"b051abdf-66d1-48c0-96ef-67fb8af96f2a", // Abhi
|
"d6dd9740-40db-45f5-ab16-4ee16a633009", // Abhi
|
||||||
"2e06e049-24c8-42e4-8bcf-d35372af31e6" // unsuperiordev
|
"2e06e049-24c8-42e4-8bcf-d35372af31e6" // unsuperiordev
|
||||||
);
|
);
|
||||||
public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","Spigot_Abhiram", "unsuperiordev");
|
public static final List<String> DEVELOPER_NAMES = Arrays.asList("Madgeek1450", "Prozza", "WickedGamingUK", "Wild1145", "aggelosQQ", "scripthead", "CoolJWB", "elmon_", "speednt", "SupItsDillon", "Paldiu", "AwesomePinch", "TFTWPhoenix","abhithedev", "unsuperiordev");
|
||||||
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
public static final Map<String, ChatColor> CHAT_COLOR_NAMES = new HashMap<>();
|
||||||
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
public static final List<ChatColor> CHAT_COLOR_POOL = Arrays.asList(
|
||||||
ChatColor.DARK_RED,
|
ChatColor.DARK_RED,
|
||||||
|
Loading…
Reference in New Issue
Block a user