-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathQuoteBoardConfig.java
More file actions
43 lines (38 loc) · 1.65 KB
/
QuoteBoardConfig.java
File metadata and controls
43 lines (38 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.togetherjava.tjbot.config;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import org.apache.logging.log4j.LogManager;
import org.togetherjava.tjbot.features.basic.QuoteBoardForwarder;
import java.util.Objects;
/**
* Configuration for the quote board feature, see {@link QuoteBoardForwarder}.
*/
@JsonRootName("quoteBoardConfig")
public record QuoteBoardConfig(
@JsonProperty(value = "minimumReactionsToTrigger", required = true) int minimumReactions,
@JsonProperty(required = true) String channel,
@JsonProperty(value = "reactionEmoji", required = true) String reactionEmoji) {
/**
* Creates a QuoteBoardConfig.
*
* @param minimumReactions the minimum amount of reactions
* @param channel the pattern for the board channel
* @param reactionEmoji the emoji with which users should react to
*/
public QuoteBoardConfig {
if (minimumReactions <= 0) {
throw new IllegalArgumentException("minimumReactions must be greater than zero");
}
Objects.requireNonNull(channel);
if (channel.isBlank()) {
throw new IllegalArgumentException("channel must not be empty or blank");
}
Objects.requireNonNull(reactionEmoji);
if (reactionEmoji.isBlank()) {
throw new IllegalArgumentException("reactionEmoji must not be empty or blank");
}
LogManager.getLogger(QuoteBoardConfig.class)
.debug("Quote-Board configs loaded: minimumReactions={}, channel='{}', reactionEmoji='{}'",
minimumReactions, channel, reactionEmoji);
}
}