PpomppuNotifier/receiver/src/main/java/com/myoa/engineering/crawl/ppomppu/receiver/configuration/TelegramBotConfiguration.java

38 lines
1.3 KiB
Java

package com.myoa.engineering.crawl.ppomppu.receiver.configuration;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.telegram.telegrambots.meta.TelegramBotsApi;
import org.telegram.telegrambots.meta.exceptions.TelegramApiException;
import org.telegram.telegrambots.updatesreceivers.DefaultBotSession;
import com.myoa.engineering.crawl.ppomppu.receiver.handler.message.MessageHandler;
import com.myoa.engineering.crawl.ppomppu.receiver.dispatch.MessageDispatcher;
/**
* TelegramBotConfiguration
* @author Shin Woo-jin (woo-jin.shin@linecorp.com)
* @since 2021-08-21
*
*/
@Configuration
public class TelegramBotConfiguration {
private static final String BOT_TOKEN = "bottoken"; // TODO extract to property
private static final String BOT_NAME = "nthfuncx_SoundHoundFoundBot"; // TODO extract to property
@Bean
public TelegramBotsApi telegramBotsApi(MessageDispatcher messageDispatcher) throws TelegramApiException {
TelegramBotsApi api = new TelegramBotsApi(DefaultBotSession.class);
api.registerBot(messageDispatcher);
return api;
}
@Bean
public MessageDispatcher messageDispatcher(List<MessageHandler> messageHandlers) {
return new MessageDispatcher(messageHandlers, BOT_TOKEN, BOT_NAME);
}
}