Skip to content

Commit 9f8b67a

Browse files
committed
Added ModAuditLogRoutine
* this version is based on active polling the audit log in a schedule
1 parent c56704f commit 9f8b67a

File tree

5 files changed

+416
-1
lines changed

5 files changed

+416
-1
lines changed

application/src/main/java/org/togetherjava/tjbot/Application.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.togetherjava.tjbot.commands.system.CommandSystem;
99
import org.togetherjava.tjbot.config.Config;
1010
import org.togetherjava.tjbot.db.Database;
11+
import org.togetherjava.tjbot.routines.ModAuditLogRoutine;
1112

1213
import javax.security.auth.login.LoginException;
1314
import java.io.IOException;
@@ -81,6 +82,10 @@ public static void runBot(String token, Path databasePath) {
8182
jda.awaitReady();
8283
logger.info("Bot is ready");
8384

85+
// TODO This should be moved into some proper command system instead (see GH issue #235
86+
// which adds support for routines)
87+
new ModAuditLogRoutine(jda, database).start();
88+
8489
Runtime.getRuntime().addShutdownHook(new Thread(Application::onShutdown));
8590
} catch (LoginException e) {
8691
logger.error("Failed to login", e);

application/src/main/java/org/togetherjava/tjbot/config/Config.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@ public final class Config {
2323
private final String databasePath;
2424
private final String projectWebsite;
2525
private final String discordGuildInvite;
26+
private final String modAuditLogChannelPattern;
27+
private final String mutedRolePattern;
2628

2729
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
2830
private Config(@JsonProperty("token") String token,
2931
@JsonProperty("databasePath") String databasePath,
3032
@JsonProperty("projectWebsite") String projectWebsite,
31-
@JsonProperty("discordGuildInvite") String discordGuildInvite) {
33+
@JsonProperty("discordGuildInvite") String discordGuildInvite,
34+
@JsonProperty("modAuditLogChannelPattern") String modAuditLogChannelPattern,
35+
@JsonProperty("mutedRolePattern") String mutedRolePattern) {
3236
this.token = token;
3337
this.databasePath = databasePath;
3438
this.projectWebsite = projectWebsite;
3539
this.discordGuildInvite = discordGuildInvite;
40+
this.modAuditLogChannelPattern = modAuditLogChannelPattern;
41+
this.mutedRolePattern = mutedRolePattern;
3642
}
3743

3844
/**
@@ -59,6 +65,25 @@ public static Config getInstance() {
5965
"can not get the configuration before it has been loaded");
6066
}
6167

68+
/**
69+
* Gets the REGEX pattern used to identify the role assigned to muted users.
70+
*
71+
* @return the role name pattern
72+
*/
73+
public String getMutedRolePattern() {
74+
return mutedRolePattern;
75+
}
76+
77+
/**
78+
* Gets the REGEX pattern used to identify the channel that is supposed to contain all mod audit
79+
* logs.
80+
*
81+
* @return the channel name pattern
82+
*/
83+
public String getModAuditLogChannelPattern() {
84+
return modAuditLogChannelPattern;
85+
}
86+
6287
/**
6388
* Gets the token of the Discord bot to connect this application to.
6489
*

0 commit comments

Comments
 (0)