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.EvaluationContextevaluationContext(org.springframework.context.ApplicationContext applicationContext) Creates anEvaluationContextbean for Thymeleaf expressions.helpMessageCommand(TelegramTemplateEngine templateEngine, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient) org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplicationtelegramBotsLongPollingApplication(com.fasterxml.jackson.databind.ObjectMapper objectMapper, ScheduledExecutorService scheduledExecutorService) Creates aTelegramBotsLongPollingApplicationbean for handling long polling updates from the Telegram bot.org.telegram.telegrambots.meta.generics.TelegramClientCreates aTelegramClientbean for interacting with the Telegram API.telegramForwarderBot(org.telegram.telegrambots.longpolling.interfaces.LongPollingUpdateConsumer updateConsumer, org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, TelegramTemplateEngine templateEngine) Creates aTelegramForwarderBotbean that handles updates from the Telegram bot.Creates aScheduledExecutorServicebean for scheduling tasks related to the Telegram bot.
-
Constructor Details
-
TelegramConfiguration
public TelegramConfiguration()
-
-
Method Details
-
telegramScheduledExecutorService
Creates aScheduledExecutorServicebean 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
ScheduledExecutorServiceinstance
-
telegramBotsLongPollingApplication
@Bean public org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplication telegramBotsLongPollingApplication(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Qualifier("telegramScheduledExecutorService") ScheduledExecutorService scheduledExecutorService) Creates aTelegramBotsLongPollingApplicationbean for handling long polling updates from the Telegram bot.- Parameters:
objectMapper- theObjectMapperfor JSON serialization/deserializationscheduledExecutorService- theScheduledExecutorServicefor scheduling tasks- Returns:
- a
TelegramBotsLongPollingApplicationinstance
-
telegramClient
@Bean public org.telegram.telegrambots.meta.generics.TelegramClient telegramClient()Creates aTelegramClientbean for interacting with the Telegram API.- Returns:
- a
TelegramClientinstance
-
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 aTelegramForwarderBotbean that handles updates from the Telegram bot.- Parameters:
updateConsumer- theLongPollingUpdateConsumerfor processing updatestelegramClient- theTelegramClientfor sending messagestemplateEngine- theTelegramTemplateEnginefor processing templates- Returns:
- a
TelegramForwarderBotinstance - 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- theTelegramTemplateEnginefor processing templatestelegramClient- theTelegramClientfor sending messages- Returns:
- a
MessageCommandinstance that handles help and start commands
-
evaluationContext
@Bean public org.springframework.expression.EvaluationContext evaluationContext(org.springframework.context.ApplicationContext applicationContext) Creates anEvaluationContextbean for Thymeleaf expressions.- Parameters:
applicationContext- theApplicationContextfor accessing beans- Returns:
- an
EvaluationContextinstance
-