TDLightTelegramBots/telegrambots-spring-boot-starter
Ruben Bermudez 427f1ee8d2
Merge pull request #761 from b1sar/master
Update README.md
2020-07-11 15:50:37 +01:00
..
src Version 4.8.1 2020-04-26 02:11:41 +01:00
pom.xml Update version 4.9 2020-06-04 22:18:36 +01:00
README.md Merge pull request #761 from b1sar/master 2020-07-11 15:50:37 +01:00

abilitybots

Build Status Jitpack JavaDoc Telegram ghit.me

Usage

Maven

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

Gradle

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

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(YourApplicationMainClass.class, args);
	}
}

After that your bot will look like:

  //Standard 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.