Skip to content

Commit 2344129

Browse files
committed
Voting processor for herald votes
1 parent 6551cb4 commit 2344129

File tree

6 files changed

+52
-1
lines changed

6 files changed

+52
-1
lines changed

herald/processor/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
= Herald / Processor
2+
3+
link:../../votes/voting-processor/src/main/kotlin/by/jprof/telegram/bot/votes/voting_processor/VotingProcessor.kt[`VotingProcessor`] implementation for this scheduled messages poster.

herald/processor/build.gradle.kts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
kotlin("jvm")
3+
}
4+
5+
dependencies {
6+
api(project.projects.core)
7+
api(project.projects.votes)
8+
api(project.projects.votes.votingProcessor)
9+
implementation(libs.log4j.api)
10+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package by.jprof.telegram.bot.herald.processor
2+
3+
import by.jprof.telegram.bot.core.UpdateProcessor
4+
import by.jprof.telegram.bot.votes.dao.VotesDAO
5+
import by.jprof.telegram.bot.votes.voting_processor.VotingProcessor
6+
import dev.inmo.tgbotapi.bot.RequestsExecutor
7+
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
8+
import dev.inmo.tgbotapi.types.update.abstracts.Update
9+
import org.apache.logging.log4j.LogManager
10+
11+
class HeraldVoteUpdateProcessor(
12+
votesDAO: VotesDAO,
13+
bot: RequestsExecutor,
14+
) : VotingProcessor(
15+
"HERALD",
16+
votesDAO,
17+
{ throw UnsupportedOperationException("Votes should be constructed elsewhere!") },
18+
bot,
19+
), UpdateProcessor {
20+
companion object {
21+
private val logger = LogManager.getLogger(HeraldVoteUpdateProcessor::class.java)!!
22+
}
23+
24+
override suspend fun process(update: Update) {
25+
when (update) {
26+
is CallbackQueryUpdate -> processCallbackQuery(update.data)
27+
}
28+
}
29+
}

runners/lambda/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ dependencies {
2020
implementation(project.projects.pins.dynamodb)
2121
implementation(project.projects.pins.sfn)
2222
implementation(project.projects.currencies)
23+
implementation(project.projects.herald.processor)
2324
}

runners/lambda/src/main/kotlin/by/jprof/telegram/bot/runners/lambda/config/pipeline.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package by.jprof.telegram.bot.runners.lambda.config
33
import by.jprof.telegram.bot.core.UpdateProcessingPipeline
44
import by.jprof.telegram.bot.core.UpdateProcessor
55
import by.jprof.telegram.bot.currencies.CurrenciesUpdateProcessor
6-
import by.jprof.telegram.bot.currencies.parser.MonetaryAmountParsingPipeline
76
import by.jprof.telegram.bot.eval.EvalUpdateProcessor
7+
import by.jprof.telegram.bot.herald.processor.HeraldVoteUpdateProcessor
88
import by.jprof.telegram.bot.jep.JEPUpdateProcessor
99
import by.jprof.telegram.bot.jep.JsoupJEPSummary
1010
import by.jprof.telegram.bot.kotlin.KotlinMentionsUpdateProcessor
@@ -123,4 +123,11 @@ val pipelineModule = module {
123123
bot = get(),
124124
)
125125
}
126+
127+
single<UpdateProcessor>(named("HeraldVoteUpdateProcessor")) {
128+
HeraldVoteUpdateProcessor(
129+
votesDAO = get(),
130+
bot = get(),
131+
)
132+
}
126133
}

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ include(":pins:sfn")
3131
include(":runners:lambda")
3232
include(":currencies")
3333
include(":herald")
34+
include(":herald:processor")

0 commit comments

Comments
 (0)