Class TelegramConfiguration

java.lang.Object
io.github.yvasyliev.forwarder.telegram.bot.configuration.TelegramConfiguration

@Configuration public class TelegramConfiguration extends Object
Configuration class for setting up the Telegram bot and its dependencies.
  • Constructor Details

  • Method Details

    • telegramScheduledExecutorService

      @Bean(defaultCandidate=false) public ScheduledExecutorService telegramScheduledExecutorService()
      Creates a ScheduledExecutorService 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(@Qualifier("telegramScheduledExecutorService") ScheduledExecutorService scheduledExecutorService)
      Creates a TelegramBotsLongPollingApplication bean for handling long polling updates from the Telegram bot.
      Parameters:
      scheduledExecutorService - the ScheduledExecutorService for scheduling tasks
      Returns:
      a TelegramBotsLongPollingApplication instance
    • telegramClient

      @Bean public org.telegram.telegrambots.meta.generics.TelegramClient telegramClient()
      Creates a TelegramClient bean for interacting with the Telegram API.
      Returns:
      a TelegramClient instance
    • startMessageCommand

      @Bean("/start") public MessageCommand startMessageCommand(@Qualifier("/help") MessageCommand helpMessageCommand)
      Creates a MessageCommand bean for the /start command that delegates to the /help command.
      Parameters:
      helpMessageCommand - the MessageCommand for the /help command
      Returns:
      a MessageCommand instance for the /start command
    • telegramPropertiesSetter

      @Bean public TemplateContextCustomizer telegramPropertiesSetter(org.telegram.telegrambots.meta.generics.TelegramClient telegramClient, BotDTOMapper botDTOMapper, TelegramChannelProperties channelProperties) throws org.telegram.telegrambots.meta.exceptions.TelegramApiException
      Creates a TemplateContextCustomizer bean that sets Telegram bot properties and channel properties in the Thymeleaf template context.
      Parameters:
      telegramClient - the TelegramClient for interacting with the Telegram API
      botDTOMapper - the BotDTOMapper for mapping bot data
      channelProperties - the TelegramChannelProperties for channel configuration
      Returns:
      a TemplateContextCustomizer instance
      Throws:
      org.telegram.telegrambots.meta.exceptions.TelegramApiException - if there is an error retrieving bot information