Class TelegramConfiguration
java.lang.Object
io.github.yvasyliev.forwarder.telegram.bot.configuration.TelegramConfiguration
Configuration class for setting up the Telegram bot and its dependencies.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstartMessageCommand(MessageCommand helpMessageCommand) org.telegram.telegrambots.longpolling.TelegramBotsLongPollingApplicationtelegramBotsLongPollingApplication(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.telegramPropertiesSetter(org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, BotDTOMapper botDTOMapper, TelegramChannelProperties channelProperties) Creates aTemplateContextCustomizerbean that sets Telegram bot properties and channel properties in the Thymeleaf template context.Creates aScheduledExecutorServicebean for scheduling tasks related to the Telegram bot.
-
Constructor Details
-
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(@Qualifier("telegramScheduledExecutorService") ScheduledExecutorService scheduledExecutorService) Creates aTelegramBotsLongPollingApplicationbean for handling long polling updates from the Telegram bot.- Parameters:
scheduledExecutorService- 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
-
startMessageCommand
@Bean("/start") public MessageCommand startMessageCommand(@Qualifier("/help") MessageCommand helpMessageCommand) - Parameters:
helpMessageCommand- theMessageCommandfor the/helpcommand- Returns:
- a
MessageCommandinstance for the/startcommand
-
telegramPropertiesSetter
@Bean public TemplateContextCustomizer telegramPropertiesSetter(org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, BotDTOMapper botDTOMapper, TelegramChannelProperties channelProperties) throws org.telegram.telegrambots.meta.exceptions.TelegramApiException Creates aTemplateContextCustomizerbean that sets Telegram bot properties and channel properties in the Thymeleaf template context.- Parameters:
telegramClient- theTelegramClientfor interacting with the Telegram APIbotDTOMapper- theBotDTOMapperfor mapping bot datachannelProperties- theTelegramChannelPropertiesfor channel configuration- Returns:
- a
TemplateContextCustomizerinstance - Throws:
org.telegram.telegrambots.meta.exceptions.TelegramApiException- if there is an error retrieving bot information
-