Skip to content

Commit a018539

Browse files
Set up config and create reaction listener
1 parent 2738a98 commit a018539

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

application/config.json.template

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@
9696
"baseUrl": "<put_jshell_rest_api_url_here>",
9797
"rateLimitWindowSeconds": 10,
9898
"rateLimitRequestsInWindow": 3
99+
}
100+
"oofsAndLmaos": {
101+
"oofEmojiName": ":oof:"
102+
"lmaoEmojiName": ":lmao"
103+
"starboardChannelId": <put_channel_id_here>
104+
}
99105
},
100106
"featureBlacklist": {
101107
"normal": [

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public final class Config {
4646
private final RSSFeedsConfig rssFeedsConfig;
4747
private final String selectRolesChannelPattern;
4848
private final String memberCountCategoryPattern;
49+
private final OofsAndLmaosConfig oofsAndLmaos;
4950

5051
@SuppressWarnings("ConstructorWithTooManyParameters")
5152
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
@@ -94,7 +95,8 @@ private Config(@JsonProperty(value = "token", required = true) String token,
9495
required = true) FeatureBlacklistConfig featureBlacklistConfig,
9596
@JsonProperty(value = "rssConfig", required = true) RSSFeedsConfig rssFeedsConfig,
9697
@JsonProperty(value = "selectRolesChannelPattern",
97-
required = true) String selectRolesChannelPattern) {
98+
required = true) String selectRolesChannelPattern,
99+
@JsonProperty(value = "oofsAndLmaos", required = true) OofsAndLmaosConfig oofsAndLmaos) {
98100
this.token = Objects.requireNonNull(token);
99101
this.githubApiKey = Objects.requireNonNull(githubApiKey);
100102
this.databasePath = Objects.requireNonNull(databasePath);
@@ -127,6 +129,7 @@ private Config(@JsonProperty(value = "token", required = true) String token,
127129
this.featureBlacklistConfig = Objects.requireNonNull(featureBlacklistConfig);
128130
this.rssFeedsConfig = Objects.requireNonNull(rssFeedsConfig);
129131
this.selectRolesChannelPattern = Objects.requireNonNull(selectRolesChannelPattern);
132+
this.oofsAndLmaos = Objects.requireNonNull(oofsAndLmaos);
130133
}
131134

132135
/**
@@ -380,6 +383,9 @@ public String getSourceCodeBaseUrl() {
380383
*/
381384
public JShellConfig getJshell() {
382385
return jshell;
386+
}
387+
public OofsAndLmaosConfig getOofsAndLmaos() {
388+
return oofsAndLmaos;
383389
}
384390

385391
/**
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)