Skip to content

Commit f44aec9

Browse files
author
NathanealV
committed
Added NSA category blacklist
1 parent f64e920 commit f44aec9

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

bot-example.env

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ SENSITIVE_ROLES=
4444
# Separated by ;
4545
OPT_CATEGORIES=
4646

47-
# A list of explicitly opt-blacklisted channel IDs .
47+
# A list of explicitly opt-blacklisted channel IDs.
4848
# Separated by ;
49-
OPT_BLACKLIST=
49+
OPT_BLACKLIST=
50+
51+
# A list of category IDs in which NSA is disabled.
52+
# Separated by ;
53+
NSA_CATEGORIES=
54+

src/main/java/com/ibdiscord/data/LocalConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ public final class LocalConfig {
103103
*/
104104
@Getter private final List<Long> optBlacklist;
105105

106+
/**
107+
* NSA_CATEGORIES
108+
*/
109+
@Getter private final List<Long> nsaCategories;
110+
106111
/**
107112
* Constructor for the local configuration object.
108113
* Sets all of the class properties to their corresponding environment
@@ -134,6 +139,7 @@ public LocalConfig() {
134139
this.sensitiveRoles = getEnvironment("SENSITIVE_ROLES", lambdaMapId, new ArrayList<>());
135140
this.optCategories = getEnvironment("OPT_CATEGORIES", lambdaMapId, new ArrayList<>());
136141
this.optBlacklist = getEnvironment("OPT_BLACKLIST", lambdaMapId, new ArrayList<>());
142+
this.nsaCategories = getEnvironment("NSA_CATEGORIES", lambdaMapId, new ArrayList<>());
137143
}
138144

139145
/**

src/main/java/com/ibdiscord/listeners/FilterListener.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public void handleFilter(Message messageObject) {
7373
if (author.getId().equals(guild.getSelfMember().getId())) {
7474
return;
7575
}
76+
GuildChannel guildChannel = guild.getGuildChannelById(messageObject.getChannel().getIdLong());
77+
if(guildChannel.getParent() != null
78+
&& IBai.INSTANCE.getConfig().getNsaCategories().contains(guildChannel.getParent().getIdLong())) {
79+
return;
80+
}
7681
String message = messageObject.getContentRaw();
7782
String prefix = UDatabase.getPrefix(guild);
7883

src/main/java/com/ibdiscord/listeners/MonitorListener.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
import de.arraying.gravity.Gravity;
2929
import de.arraying.gravity.data.property.Property;
3030
import net.dv8tion.jda.api.EmbedBuilder;
31-
import net.dv8tion.jda.api.entities.ChannelType;
32-
import net.dv8tion.jda.api.entities.Message;
33-
import net.dv8tion.jda.api.entities.MessageEmbed;
34-
import net.dv8tion.jda.api.entities.TextChannel;
31+
import net.dv8tion.jda.api.entities.*;
3532
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
3633
import net.dv8tion.jda.api.hooks.ListenerAdapter;
3734

@@ -51,12 +48,17 @@ public final class MonitorListener extends ListenerAdapter {
5148
*/
5249
@Override
5350
public void onMessageReceived(MessageReceivedEvent event) {
51+
GuildChannel guildChannel = event.getGuild().getGuildChannelById(event.getChannel().getIdLong());
5452
if(event.getAuthor().isBot()) {
5553
return;
5654
}
5755
if(event.getChannelType() != ChannelType.TEXT) {
5856
return;
5957
}
58+
if(guildChannel.getParent() != null
59+
&& IBai.INSTANCE.getConfig().getNsaCategories().contains(guildChannel.getParent().getIdLong())) {
60+
return;
61+
}
6062
Message message = event.getMessage();
6163
Gravity gravity = DataContainer.INSTANCE.getGravity();
6264
MonitorData monitorData = gravity.load(new MonitorData(message.getGuild().getId()));

0 commit comments

Comments
 (0)