-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into oofs_and_lmaos
- Loading branch information
Showing
17 changed files
with
192 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
application/src/main/java/org/togetherjava/tjbot/config/FeatureBlacklist.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.togetherjava.tjbot.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* Blacklist of features, use {@link FeatureBlacklist#isEnabled(T)} to test if a feature is enabled. | ||
* If a feature is blacklisted, it won't be enabled by the bot, and so will be ignored. | ||
* | ||
* @param <T> the type of the feature identifier | ||
*/ | ||
public class FeatureBlacklist<T> { | ||
private final Set<T> featureIdentifierBlacklist; | ||
|
||
/** | ||
* Creates a feature blacklist | ||
* | ||
* @param featureIdentifierBlacklist a set of identifiers which are blacklisted | ||
*/ | ||
@JsonCreator | ||
public FeatureBlacklist(Set<T> featureIdentifierBlacklist) { | ||
this.featureIdentifierBlacklist = Set.copyOf(featureIdentifierBlacklist); | ||
} | ||
|
||
/** | ||
* Returns if a feature is enabled or not. | ||
* | ||
* @param featureId the identifier of the feature | ||
* @return true if a feature is enabled, false otherwise | ||
*/ | ||
public boolean isEnabled(T featureId) { | ||
return !featureIdentifierBlacklist.contains(featureId); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
application/src/main/java/org/togetherjava/tjbot/config/FeatureBlacklistConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.togetherjava.tjbot.config; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* Configuration of the feature blacklist, any feature present here will be disabled. | ||
* | ||
* @param normal the normal features, which are present in | ||
* {@link org.togetherjava.tjbot.features.Features} | ||
* @param special the special features, which require special code | ||
*/ | ||
public record FeatureBlacklistConfig( | ||
@JsonProperty(value = "normal", required = true) FeatureBlacklist<Class<?>> normal, | ||
@JsonProperty(value = "special", required = true) FeatureBlacklist<String> special) { | ||
|
||
/** | ||
* Creates a FeatureBlacklistConfig. | ||
* | ||
* @param normal the list of normal features, must be not null | ||
* @param special the list of special features, must be not null | ||
*/ | ||
public FeatureBlacklistConfig { | ||
Objects.requireNonNull(normal); | ||
Objects.requireNonNull(special); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
application/src/main/java/org/togetherjava/tjbot/config/HelperPruneConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.togetherjava.tjbot.config; | ||
|
||
|
||
/** | ||
* Config for automatic pruning of helper roles, see | ||
* {@link org.togetherjava.tjbot.features.help.AutoPruneHelperRoutine}. | ||
* | ||
* @param roleFullLimit if a helper role contains that many users, it is considered full and pruning | ||
* must occur | ||
* @param roleFullThreshold if a helper role contains that many users, pruning will start to occur | ||
* to prevent reaching the limit | ||
* @param pruneMemberAmount amount of users to remove from helper roles during a prune | ||
* @param inactivateAfterDays after how many days of inactivity a user is eligible for pruning | ||
* @param recentlyJoinedDays if a user is with the server for just this amount of days, they are | ||
* protected from pruning | ||
*/ | ||
public record HelperPruneConfig(int roleFullLimit, int roleFullThreshold, int pruneMemberAmount, | ||
int inactivateAfterDays, int recentlyJoinedDays) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.