From 8035804324a6718a9f80a8cc809d21368a66a915 Mon Sep 17 00:00:00 2001 From: michael Date: Sun, 17 Dec 2023 17:35:16 +0800 Subject: [PATCH] feat:top-post --- .../commons/config/WsaDiscordProperties.kt | 2 ++ main/pom.xml | 4 ++++ main/src/main/resources/wsa.beta.properties | 1 + main/src/main/resources/wsa.prod.properties | 3 ++- pom.xml | 6 +++++ top-post/pom.xml | 24 +++++++++++++++++++ .../tw/waterballsa/utopia/TopPostListener.kt | 24 +++++++++++++++++++ 7 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 top-post/pom.xml create mode 100644 top-post/src/main/kotlin/tw/waterballsa/utopia/TopPostListener.kt 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..0ff0f356 --- /dev/null +++ b/top-post/src/main/kotlin/tw/waterballsa/utopia/TopPostListener.kt @@ -0,0 +1,24 @@ +package tw.waterballsa.utopia.toppost + +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 goodEmoji = "\uD83D\uDC4D" + + +@Component +class TopPostListener(private val wsa: WsaDiscordProperties) : UtopiaListener() { + + override fun onMessageReactionAdd(event: MessageReactionAddEvent) { + val channel = event.channel + val parentChannel = channel.asThreadChannel().parentChannel + if (wsa.topicPondChannelId == parentChannel.id && goodEmoji == (event.emoji.name)) { + channel.sendMessage(goodEmoji).queue { + it.delete().queue() + } + } + } + +}