Skip to content

Commit c556a05

Browse files
Set up config and create reaction listener
1 parent ae006d2 commit c556a05

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

application/config.json.template

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,9 @@
9595
"rateLimitWindowSeconds": 10,
9696
"rateLimitRequestsInWindow": 3
9797
}
98+
"oofsAndLmaos": {
99+
"oofEmojiName": ":oof:"
100+
"lmaoEmojiName": ":lmao"
101+
"starboardChannelId": <put_channel_id_here>
102+
}
98103
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public final class Config {
3939
private final String openaiApiKey;
4040
private final String sourceCodeBaseUrl;
4141
private final JShellConfig jshell;
42+
private final OofsAndLmaosConfig oofsAndLmaos;
4243

4344
@SuppressWarnings("ConstructorWithTooManyParameters")
4445
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
@@ -76,7 +77,8 @@ private Config(@JsonProperty(value = "token", required = true) String token,
7677
required = true) String logErrorChannelWebhook,
7778
@JsonProperty(value = "openaiApiKey", required = true) String openaiApiKey,
7879
@JsonProperty(value = "sourceCodeBaseUrl", required = true) String sourceCodeBaseUrl,
79-
@JsonProperty(value = "jshell", required = true) JShellConfig jshell) {
80+
@JsonProperty(value = "jshell", required = true) JShellConfig jshell,
81+
@JsonProperty(value = "oofsAndLmaos", required = true) OofsAndLmaosConfig oofsAndLmaos) {
8082
this.token = Objects.requireNonNull(token);
8183
this.gistApiKey = Objects.requireNonNull(gistApiKey);
8284
this.databasePath = Objects.requireNonNull(databasePath);
@@ -102,6 +104,7 @@ private Config(@JsonProperty(value = "token", required = true) String token,
102104
this.openaiApiKey = Objects.requireNonNull(openaiApiKey);
103105
this.sourceCodeBaseUrl = Objects.requireNonNull(sourceCodeBaseUrl);
104106
this.jshell = Objects.requireNonNull(jshell);
107+
this.oofsAndLmaos = Objects.requireNonNull(oofsAndLmaos);
105108
}
106109

107110
/**
@@ -341,5 +344,8 @@ public String getSourceCodeBaseUrl() {
341344
*/
342345
public JShellConfig getJshell() {
343346
return jshell;
347+
}
348+
public OofsAndLmaosConfig getOofsAndLmaos() {
349+
return oofsAndLmaos;
344350
}
345351
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.togetherjava.tjbot.config;
2+
3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonRootName;
5+
6+
@JsonRootName("oofsAndLmaos")
7+
public final class OofsAndLmaosConfig {
8+
private final String oofEmojiName;
9+
private final String lmaoEmojiName;
10+
private final long starboardChannelId;
11+
12+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
13+
public OofsAndLmaosConfig(String oofEmojiName, String lmaoEmojiName, long starboardChannelId) {
14+
this.oofEmojiName = oofEmojiName;
15+
this.lmaoEmojiName = lmaoEmojiName;
16+
this.starboardChannelId = starboardChannelId;
17+
}
18+
19+
public String getOofEmojiName() {
20+
return oofEmojiName;
21+
}
22+
23+
public String getLmaoEmojiName() {
24+
return lmaoEmojiName;
25+
}
26+
27+
public long getStarboardChannelId() {
28+
return starboardChannelId;
29+
}
30+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.togetherjava.tjbot.features.basic;
2+
3+
import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel;
4+
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
5+
import net.dv8tion.jda.api.hooks.ListenerAdapter;
6+
import org.jetbrains.annotations.NotNull;
7+
8+
import org.togetherjava.tjbot.config.Config;
9+
import org.togetherjava.tjbot.config.OofsAndLmaosConfig;
10+
import org.togetherjava.tjbot.features.EventReceiver;
11+
12+
public class OofsAndLmaosStarboard extends ListenerAdapter implements EventReceiver {
13+
14+
private final OofsAndLmaosConfig config;
15+
16+
public OofsAndLmaosStarboard(Config config) {
17+
this.config = config.getOofsAndLmaos();
18+
}
19+
20+
@Override
21+
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent event) {
22+
String emojiName = event.getReaction().getEmoji().asCustom().getName();
23+
MessageChannel channel = event.getChannel();
24+
// TODO
25+
26+
}
27+
}

0 commit comments

Comments
 (0)