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.
12
12
* Converts some currencies to EUR and USD
13
13
* Posts scheduled messages from this repo's `posts` branch
14
14
* Expand LeetCode links
15
+ * Tell users' local times
16
+ * Sell pins and custom statuses 🤑
15
17
16
18
So, it just brings some fun and interactivity in our chat.
17
19
Original file line number Diff line number Diff line change @@ -24,4 +24,5 @@ dependencies {
24
24
implementation(project.projects.leetcode)
25
25
implementation(project.projects.times.timezones.dynamodb)
26
26
implementation(project.projects.times)
27
+ implementation(project.projects.shop)
27
28
}
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ import by.jprof.telegram.bot.quizoji.QuizojiOptionUpdateProcessor
17
17
import by.jprof.telegram.bot.quizoji.QuizojiQuestionUpdateProcessor
18
18
import by.jprof.telegram.bot.quizoji.QuizojiStartCommandUpdateProcessor
19
19
import 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
20
24
import by.jprof.telegram.bot.times.TimeCommandUpdateProcessor
21
25
import by.jprof.telegram.bot.times.TimeZoneCommandUpdateProcessor
22
26
import by.jprof.telegram.bot.youtube.YouTubeUpdateProcessor
@@ -153,4 +157,28 @@ val pipelineModule = module {
153
157
bot = get(),
154
158
)
155
159
}
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
+ }
156
184
}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package by.jprof.telegram.bot.pins.utils
3
3
import java.text.ChoiceFormat
4
4
import java.text.MessageFormat
5
5
6
+ // TODO: Add a link to the `/pinshop` command here when it's ready
6
7
private val helpMessages = listOf (
7
8
""" Эту команду нужно вызывать реплаем на какое\-нибудь сообщение\.
8
9
|
Original file line number Diff line number Diff line change @@ -35,4 +35,5 @@ include(":leetcode")
35
35
include(" :times:timezones" )
36
36
include(" :times:timezones:dynamodb" )
37
37
include(" :times" )
38
+ include(" :shop" )
38
39
include(" :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