it.netgrid.got.telegram.inject.TelegramConnectorModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of telegram-connector Show documentation
Show all versions of telegram-connector Show documentation
Bauer's stand-alone connector to the Telegram API
package it.netgrid.got.telegram.inject;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import it.netgrid.bauer.Topic;
import it.netgrid.bauer.TopicFactory;
import it.netgrid.got.telegram.TelegramConnector;
import it.netgrid.got.telegram.events.ErrorEvent;
import it.netgrid.got.telegram.events.TextMessage;
import it.netgrid.got.telegram.events.TelegramMessage;
import it.netgrid.got.telegram.properties.TelegramPropertiesConfiguration;
import it.netgrid.got.telegram.properties.TelegramPropertiesConfigurationImplementation;
import me.shib.java.lib.jtelebot.service.TelegramBot;
public class TelegramConnectorModule extends AbstractModule {
@Override
protected void configure() {
}
@Provides
public TelegramConnector getConnector(TelegramBot bot,Topic sendTopic, Topic errorTopic,
Topic getTopic, TelegramPropertiesConfiguration configuration){
return new TelegramConnector(bot, sendTopic, errorTopic, getTopic, configuration);
}
@Singleton
@Provides
public TelegramBot buildTelegramBot(TelegramPropertiesConfiguration config) {
return TelegramBot.getInstance(config.getBotToken());
}
@Singleton
@Provides
public Topic buildSendTopic() {
return TopicFactory.getTopic(buildConfiguration().getSendTopic());
}
@Singleton
@Provides
public Topic buildReceiveTopic() {
return TopicFactory.getTopic(buildConfiguration().getReceiveTopic());
}
@Singleton
@Provides
public Topic buildErrorTopic() {
return TopicFactory.getTopic(buildConfiguration().getErrorTopic());
}
@Singleton
@Provides
public TelegramPropertiesConfiguration buildConfiguration() {
return new TelegramPropertiesConfigurationImplementation();
}
}