TDLightTelegramBots/telegrambots-spring-boot-starter
2022-04-09 20:11:29 +02:00
..
src Java modules 2022-04-09 02:42:41 +02:00
pom.xml Update to jakarta 2022-04-09 20:11:29 +02:00
README.md Api Version 5.7 2022-02-01 23:00:54 +00:00

abilitybots

Build Status Jitpack JavaDoc Telegram ghit.me

Usage

Maven

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

Gradle

    implementation 'org.telegram:telegrambots-spring-boot-starter:5.7.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) {		
		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.