Class TelegramConfiguration

java.lang.Object
io.github.yvasyliev.telegramforwarderbot.configuration.TelegramConfiguration

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

    • TelegramConfiguration

      public TelegramConfiguration()
  • 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(com.fasterxml.jackson.databind.ObjectMapper objectMapper, @Qualifier("telegramScheduledExecutorService") ScheduledExecutorService scheduledExecutorService)
      Creates a TelegramBotsLongPollingApplication bean for handling long polling updates from the Telegram bot.
      Parameters:
      objectMapper - the ObjectMapper for JSON serialization/deserialization
      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
    • 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 a TelegramForwarderBot bean that handles updates from the Telegram bot.
      Parameters:
      updateConsumer - the LongPollingUpdateConsumer for processing updates
      telegramClient - the TelegramClient for sending messages
      templateEngine - the TelegramTemplateEngine 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)
      Creates a MessageCommand bean for handling the /help and /start commands.
      Parameters:
      templateEngine - the TelegramTemplateEngine for processing templates
      telegramClient - the TelegramClient 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 an EvaluationContext bean for Thymeleaf expressions.
      Parameters:
      applicationContext - the ApplicationContext for accessing beans
      Returns:
      an EvaluationContext instance