TelegramBots/telegrambots-spring-boot-starter
chase ad195d8d59 Add annotation to allow bot to get botSession
A method annotated with @AfterBotRegistration will be invoked after
the bot is registered.

Optionally the method can have a parameter of
type BotSession to get passed the BotSession the bot was created with.
2018-12-19 22:19:22 +01:00
..
src Add annotation to allow bot to get botSession 2018-12-19 22:19:22 +01:00
pom.xml Update version 2018-08-09 02:50:04 +02:00
README.md Update version 2018-08-09 02:50:04 +02:00

abilitybots

Build Status Jitpack JavaDoc Telegram ghit.me

Usage

Maven

    <dependency>
        <groupId>org.telegram</groupId>
        <artifactId>telegrambots-spring-boot-starter</artifactId>
        <version>4.0.1</version>
    </dependency>

Gradle

    compile "org.telegram:telegrambots-spring-boot-starter:4.0.1"

Motivation

If you are spring boot user it`s better to be in touch with spring starters. This module allows to register bots in spring context automatically and also use them as standard spring beans.

How to use

Your main spring boot class should look like this:

@SpringBootApplication
public class YourApplicationMainClass {

	public static void main(String[] args) {
	    //Add this line to initialize bots context
		ApiContextInitializer.init();
		
		SpringApplication.run(MusicUploaderApplication.class, args);
	}
}

After that your bot will look like:

  //Standart Spring component annotation
  @Component
  public class YourBotName extends TelegramLongPollingBot {
    //Bot body.
  }

Also you could just implement LongPollingBot or WebHookBot interfaces. All this bots will be registered in context and connected to Telegram api.