diff --git a/commons/src/main/kotlin/tw/waterballsa/utopia/commons/config/WsaDiscordProperties.kt b/commons/src/main/kotlin/tw/waterballsa/utopia/commons/config/WsaDiscordProperties.kt
index f658779e..aebfea6a 100644
--- a/commons/src/main/kotlin/tw/waterballsa/utopia/commons/config/WsaDiscordProperties.kt
+++ b/commons/src/main/kotlin/tw/waterballsa/utopia/commons/config/WsaDiscordProperties.kt
@@ -35,6 +35,7 @@ open class WsaDiscordProperties(properties: Properties) {
val wsaGuideLineChannelId: String
val wsaLongArticleRoleId: String
val wsaTopicMasterRoleId: String
+ val topicPondChannelId: String
init {
properties.run {
@@ -65,6 +66,7 @@ open class WsaDiscordProperties(properties: Properties) {
wsaGuideLineChannelId = getProperty("wsa-guideline-channel-id")
wsaLongArticleRoleId = getProperty("wsa-long-article-role-id")
wsaTopicMasterRoleId = getProperty("wsa-topic-master-role-id")
+ topicPondChannelId = getProperty("topic-pond-channel-id")
}
}
}
diff --git a/main/pom.xml b/main/pom.xml
index 3bc583af..a63fbafc 100644
--- a/main/pom.xml
+++ b/main/pom.xml
@@ -109,6 +109,10 @@
tw.waterballsa.utopia
weekly-messages-volume
+
+ tw.waterballsa.utopia
+ top-post
+
diff --git a/main/src/main/resources/wsa.beta.properties b/main/src/main/resources/wsa.beta.properties
index 8b72f892..f7cd2bb3 100644
--- a/main/src/main/resources/wsa.beta.properties
+++ b/main/src/main/resources/wsa.beta.properties
@@ -24,3 +24,4 @@ water-ball-lose-weight-post-id=1091190313575526400
wsa-guideline-channel-id=1042774419371720715
wsa-long-article-role-id=1163842900933742592
wsa-topic-master-role-id=1163842370018754560
+topic-pond-channel-id=1165545216397295636
diff --git a/main/src/main/resources/wsa.prod.properties b/main/src/main/resources/wsa.prod.properties
index 9ac2e1a3..57cb459c 100644
--- a/main/src/main/resources/wsa.prod.properties
+++ b/main/src/main/resources/wsa.prod.properties
@@ -21,4 +21,5 @@ featured-videos-channel-id=1060728666507726858
flag-post-guide-id=1072845227418714193
water-ball-journal-post-id=1072869148826292234
water-ball-lose-weight-post-id=1091190313575526400
-wsa-guideline-channel-id=1042774419371720715
\ No newline at end of file
+wsa-guideline-channel-id=1042774419371720715
+topic-pond-channel-id=1137770529273683999
diff --git a/pom.xml b/pom.xml
index 4ac7999b..d1760e35 100644
--- a/pom.xml
+++ b/pom.xml
@@ -37,6 +37,7 @@
message-cherry-pick
weekly-messages-volume
utopia-test-kit
+ top-post
@@ -288,6 +289,11 @@
utopia-test-kit
${revision}
+
+ tw.waterballsa.utopia
+ top-post
+ ${revision}
+
diff --git a/top-post/pom.xml b/top-post/pom.xml
new file mode 100644
index 00000000..efe198fe
--- /dev/null
+++ b/top-post/pom.xml
@@ -0,0 +1,24 @@
+
+
+ 4.0.0
+
+ root
+ tw.waterballsa.utopia
+ ${revision}
+
+
+ top-post
+
+
+
+ tw.waterballsa.utopia
+ commons
+
+
+ tw.waterballsa.utopia
+ discord-impl-jda
+
+
+
diff --git a/top-post/src/main/kotlin/tw/waterballsa/utopia/TopPostListener.kt b/top-post/src/main/kotlin/tw/waterballsa/utopia/TopPostListener.kt
new file mode 100644
index 00000000..6c22a61f
--- /dev/null
+++ b/top-post/src/main/kotlin/tw/waterballsa/utopia/TopPostListener.kt
@@ -0,0 +1,31 @@
+package tw.waterballsa.utopia.toppost
+
+import net.dv8tion.jda.api.entities.channel.unions.IThreadContainerUnion
+import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent
+import org.springframework.stereotype.Component
+import tw.waterballsa.utopia.commons.config.WsaDiscordProperties
+import tw.waterballsa.utopia.jda.UtopiaListener
+
+const val likeEmoji = "\uD83D\uDC4D"
+
+
+@Component
+class TopPostListener(private val wsa: WsaDiscordProperties) : UtopiaListener() {
+
+ override fun onMessageReactionAdd(event: MessageReactionAddEvent) {
+ with (event) {
+ val post = channel.asThreadChannel()
+ val forum = post.parentChannel
+ val hasPostLikeEmoji = emoji.name == likeEmoji
+
+ if (forum.isTopicPoolForum() && hasPostLikeEmoji) {
+ channel.sendMessage(likeEmoji).queue {
+ it.delete().queue()
+ }
+ }
+ }
+ }
+
+ private fun IThreadContainerUnion.isTopicPoolForum() = id == wsa.topicPondChannelId
+
+}