File tree Expand file tree Collapse file tree 11 files changed +185
-0
lines changed
src/main/kotlin/by/jprof/telegram/bot/launchers/lambda/config
pins/src/main/kotlin/by/jprof/telegram/bot/pins/utils
src/main/kotlin/by/jprof/telegram/bot/shop Expand file tree Collapse file tree 11 files changed +185
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ Official Telegram bot of Java Professionals BY community.
1212* Converts some currencies to EUR and USD
1313* Posts scheduled messages from this repo's `posts` branch
1414* Expand LeetCode links
15+ * Tell users' local times
16+ * Sell pins and custom statuses 🤑
1517
1618So, it just brings some fun and interactivity in our chat.
1719
Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ dependencies {
2424 implementation(project.projects.leetcode)
2525 implementation(project.projects.times.timezones.dynamodb)
2626 implementation(project.projects.times)
27+ implementation(project.projects.shop)
2728}
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ import by.jprof.telegram.bot.quizoji.QuizojiOptionUpdateProcessor
1717import by.jprof.telegram.bot.quizoji.QuizojiQuestionUpdateProcessor
1818import by.jprof.telegram.bot.quizoji.QuizojiStartCommandUpdateProcessor
1919import by.jprof.telegram.bot.quizoji.QuizojiVoteUpdateProcessor
20+ import by.jprof.telegram.bot.shop.PinsShopCommandUpdateProcessor
21+ import by.jprof.telegram.bot.shop.RichCommandUpdateProcessor
22+ import by.jprof.telegram.bot.shop.SupportCommandUpdateProcessor
23+ import by.jprof.telegram.bot.shop.TitleCommandUpdateProcessor
2024import by.jprof.telegram.bot.times.TimeCommandUpdateProcessor
2125import by.jprof.telegram.bot.times.TimeZoneCommandUpdateProcessor
2226import by.jprof.telegram.bot.youtube.YouTubeUpdateProcessor
@@ -153,4 +157,28 @@ val pipelineModule = module {
153157 bot = get(),
154158 )
155159 }
160+
161+ single<UpdateProcessor >(named(" PinsShopCommandUpdateProcessor" )) {
162+ PinsShopCommandUpdateProcessor (
163+ bot = get(),
164+ )
165+ }
166+
167+ single<UpdateProcessor >(named(" RichCommandUpdateProcessor" )) {
168+ RichCommandUpdateProcessor (
169+ bot = get(),
170+ )
171+ }
172+
173+ single<UpdateProcessor >(named(" TitleCommandUpdateProcessor" )) {
174+ TitleCommandUpdateProcessor (
175+ bot = get(),
176+ )
177+ }
178+
179+ single<UpdateProcessor >(named(" SupportCommandUpdateProcessor" )) {
180+ SupportCommandUpdateProcessor (
181+ bot = get(),
182+ )
183+ }
156184}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package by.jprof.telegram.bot.pins.utils
33import java.text.ChoiceFormat
44import java.text.MessageFormat
55
6+ // TODO: Add a link to the `/pinshop` command here when it's ready
67private val helpMessages = listOf (
78 """ Эту команду нужно вызывать реплаем на какое\-нибудь сообщение\.
89 |
Original file line number Diff line number Diff line change @@ -35,4 +35,5 @@ include(":leetcode")
3535include(" :times:timezones" )
3636include(" :times:timezones:dynamodb" )
3737include(" :times" )
38+ include(" :shop" )
3839include(" :launchers:lambda" )
Original file line number Diff line number Diff line change 1+ = Shop
2+
3+ This feature allows users to buy link:../pins[pins] and custom titles.
Original file line number Diff line number Diff line change 1+ plugins {
2+ kotlin(" jvm" )
3+ }
4+
5+ dependencies {
6+ api(project.projects.core)
7+ api(libs.tgbotapi.core)
8+ implementation(libs.tgbotapi.extensions.api)
9+ implementation(libs.tgbotapi.extensions.utils)
10+ implementation(libs.log4j.api)
11+
12+ testImplementation(libs.junit.jupiter.api)
13+ testImplementation(libs.junit.jupiter.params)
14+ testImplementation(libs.mockk)
15+ testRuntimeOnly(libs.junit.jupiter.engine)
16+ testRuntimeOnly(libs.log4j.core)
17+ }
Original file line number Diff line number Diff line change 1+ package by.jprof.telegram.bot.shop
2+
3+ import by.jprof.telegram.bot.core.UpdateProcessor
4+ import dev.inmo.tgbotapi.bot.RequestsExecutor
5+ import dev.inmo.tgbotapi.extensions.api.send.reply
6+ import dev.inmo.tgbotapi.extensions.utils.asBaseMessageUpdate
7+ import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
8+ import dev.inmo.tgbotapi.extensions.utils.asContentMessage
9+ import dev.inmo.tgbotapi.extensions.utils.asTextContent
10+ import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2ParseMode
11+ import dev.inmo.tgbotapi.types.update.abstracts.Update
12+ import dev.inmo.tgbotapi.utils.PreviewFeature
13+
14+ @OptIn(PreviewFeature ::class )
15+ class PinsShopCommandUpdateProcessor (
16+ private val bot : RequestsExecutor ,
17+ ) : UpdateProcessor {
18+ override suspend fun process (update : Update ) {
19+ @Suppress(" NAME_SHADOWING" ) val update = update.asBaseMessageUpdate() ? : return
20+ val message = update.data.asContentMessage() ? : return
21+ val text = message.content.asTextContent() ? : return
22+
23+ if (text.textSources.mapNotNull { it.asBotCommandTextSource() }.none { it.command == " pinsshop" || it.command == " pinshop" }) {
24+ return
25+ }
26+
27+ val reply = """
28+ TODO: Sell pins
29+ """ .trimIndent().trim()
30+
31+ bot.reply(to = message, text = reply, parseMode = MarkdownV2ParseMode )
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package by.jprof.telegram.bot.shop
2+
3+ import by.jprof.telegram.bot.core.UpdateProcessor
4+ import dev.inmo.tgbotapi.bot.RequestsExecutor
5+ import dev.inmo.tgbotapi.extensions.api.send.reply
6+ import dev.inmo.tgbotapi.extensions.utils.asBaseMessageUpdate
7+ import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
8+ import dev.inmo.tgbotapi.extensions.utils.asContentMessage
9+ import dev.inmo.tgbotapi.extensions.utils.asTextContent
10+ import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2ParseMode
11+ import dev.inmo.tgbotapi.types.update.abstracts.Update
12+ import dev.inmo.tgbotapi.utils.PreviewFeature
13+
14+ @OptIn(PreviewFeature ::class )
15+ class RichCommandUpdateProcessor (
16+ private val bot : RequestsExecutor ,
17+ ) : UpdateProcessor {
18+ override suspend fun process (update : Update ) {
19+ @Suppress(" NAME_SHADOWING" ) val update = update.asBaseMessageUpdate() ? : return
20+ val message = update.data.asContentMessage() ? : return
21+ val text = message.content.asTextContent() ? : return
22+
23+ if (text.textSources.mapNotNull { it.asBotCommandTextSource() }.none { it.command == " rich" || it.command == " vip" }) {
24+ return
25+ }
26+
27+ val reply = """
28+ TODO: Sell "I AM RICH" \/ "V\.I\.P\." custom titles
29+ """ .trimIndent().trim()
30+
31+ bot.reply(to = message, text = reply, parseMode = MarkdownV2ParseMode )
32+ }
33+ }
Original file line number Diff line number Diff line change 1+ package by.jprof.telegram.bot.shop
2+
3+ import by.jprof.telegram.bot.core.UpdateProcessor
4+ import dev.inmo.tgbotapi.bot.RequestsExecutor
5+ import dev.inmo.tgbotapi.extensions.api.send.reply
6+ import dev.inmo.tgbotapi.extensions.utils.asBaseMessageUpdate
7+ import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
8+ import dev.inmo.tgbotapi.extensions.utils.asContentMessage
9+ import dev.inmo.tgbotapi.extensions.utils.asTextContent
10+ import dev.inmo.tgbotapi.types.ParseMode.MarkdownV2ParseMode
11+ import dev.inmo.tgbotapi.types.update.abstracts.Update
12+ import dev.inmo.tgbotapi.utils.PreviewFeature
13+
14+ @OptIn(PreviewFeature ::class )
15+ class SupportCommandUpdateProcessor (
16+ private val bot : RequestsExecutor ,
17+ ) : UpdateProcessor {
18+ override suspend fun process (update : Update ) {
19+ @Suppress(" NAME_SHADOWING" ) val update = update.asBaseMessageUpdate() ? : return
20+ val message = update.data.asContentMessage() ? : return
21+ val text = message.content.asTextContent() ? : return
22+
23+ if (text.textSources.mapNotNull { it.asBotCommandTextSource() }.none { it.command == " support" }) {
24+ return
25+ }
26+
27+ val reply = """
28+ TODO: Sell "Supporter" custom title
29+ """ .trimIndent().trim()
30+
31+ bot.reply(to = message, text = reply, parseMode = MarkdownV2ParseMode )
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments