All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.netgrid.got.telegram.inject.TelegramConnectorModule Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
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();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy