Class TelegramConfiguration
java.lang.Object
io.github.yvasyliev.telegramforwarderbot.configuration.TelegramConfiguration
Configuration class for setting up the Telegram bot and its dependencies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.expression.EvaluationContext
evaluationContext
(org.springframework.context.ApplicationContext applicationContext) Creates anEvaluationContext
bean for Thymeleaf expressions.helpMessageCommand
(TelegramTemplateEngine templateEngine, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient) org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplication
telegramBotsLongPollingApplication
(com.fasterxml.jackson.databind.ObjectMapper objectMapper, ScheduledExecutorService scheduledExecutorService) Creates aTelegramBotsLongPollingApplication
bean for handling long polling updates from the Telegram bot.org.telegram.telegrambots.meta.generics.TelegramClient
Creates aTelegramClient
bean for interacting with the Telegram API.telegramForwarderBot
(org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsumer updateConsumer, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, TelegramTemplateEngine templateEngine) Creates aTelegramForwarderBot
bean that handles updates from the Telegram bot.Creates aScheduledExecutorService
bean for scheduling tasks related to the Telegram bot.
-
Constructor Details
-
TelegramConfiguration
public TelegramConfiguration()
-
-
Method Details
-
telegramScheduledExecutorService
Creates aScheduledExecutorService
bean for scheduling tasks related to the Telegram bot. This bean is not a default candidate, meaning it won't be picked up automatically by Spring.- Returns:
- a
ScheduledExecutorService
instance
-
telegramBotsLongPollingApplication
@Bean public org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplication telegramBotsLongPollingApplication(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Qualifier("telegramScheduledExecutorService") ScheduledExecutorService scheduledExecutorService) Creates aTelegramBotsLongPollingApplication
bean for handling long polling updates from the Telegram bot.- Parameters:
objectMapper
- theObjectMapper
for JSON serialization/deserializationscheduledExecutorService
- theScheduledExecutorService
for scheduling tasks- Returns:
- a
TelegramBotsLongPollingApplication
instance
-
telegramClient
@Bean public org.telegram.telegrambots.meta.generics.TelegramClient telegramClient()Creates aTelegramClient
bean for interacting with the Telegram API.- Returns:
- a
TelegramClient
instance
-
telegramForwarderBot
@Bean public TelegramForwarderBot telegramForwarderBot(org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsumer updateConsumer, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, TelegramTemplateEngine templateEngine) throws org.telegram.telegrambots.meta.exceptions.TelegramApiException Creates aTelegramForwarderBot
bean that handles updates from the Telegram bot.- Parameters:
updateConsumer
- theLongPollingUpdateConsumer
for processing updatestelegramClient
- theTelegramClient
for sending messagestemplateEngine
- theTelegramTemplateEngine
for processing templates- Returns:
- a
TelegramForwarderBot
instance - Throws:
org.telegram.telegrambots.meta.exceptions.TelegramApiException
- if an error occurs while getting bot information
-
helpMessageCommand
@Bean({"/help","/start"}) public MessageCommand helpMessageCommand(TelegramTemplateEngine templateEngine, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient) - Parameters:
templateEngine
- theTelegramTemplateEngine
for processing templatestelegramClient
- theTelegramClient
for sending messages- Returns:
- a
MessageCommand
instance that handles help and start commands
-
evaluationContext
@Bean public org.springframework.expression.EvaluationContext evaluationContext(org.springframework.context.ApplicationContext applicationContext) Creates anEvaluationContext
bean for Thymeleaf expressions.- Parameters:
applicationContext
- theApplicationContext
for accessing beans- Returns:
- an
EvaluationContext
instance
-