2018-04-17 13:52:08 +04:00
|
|
|
<div align="center">
|
|
|
|
<img src="https://github.com/addo37/AbilityBots/blob/gh-pages/images/API%20BOT-03.png?raw=true" alt="abilitybots" width="200" height="200"/>
|
|
|
|
|
|
|
|
[](https://travis-ci.org/rubenlagus/TelegramBots)
|
|
|
|
[](https://jitpack.io/#rubenlagus/TelegramBots)
|
|
|
|
[](https://addo37.github.io/AbilityBots/)
|
|
|
|
[](https://telegram.me/JavaBotsApi)
|
|
|
|
[](https://ghit.me/repo/rubenlagus/TelegramBots)
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
**Maven**
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.telegram</groupId>
|
|
|
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
2020-11-08 16:19:38 +00:00
|
|
|
<version>5.0.1</version>
|
2018-04-17 13:52:08 +04:00
|
|
|
</dependency>
|
|
|
|
```
|
|
|
|
|
|
|
|
**Gradle**
|
|
|
|
|
|
|
|
```gradle
|
2020-11-08 16:19:38 +00:00
|
|
|
compile "org.telegram:telegrambots-spring-boot-starter:5.0.1"
|
2018-04-17 13:52:08 +04:00
|
|
|
```
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
|
|
|
```java
|
|
|
|
@SpringBootApplication
|
|
|
|
public class YourApplicationMainClass {
|
|
|
|
|
2020-11-03 21:09:02 +00:00
|
|
|
public static void main(String[] args) {
|
2020-06-15 11:53:37 +03:00
|
|
|
SpringApplication.run(YourApplicationMainClass.class, args);
|
2018-04-17 13:52:08 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
After that your bot will look like:
|
|
|
|
```java
|
2018-08-30 14:31:26 +02:00
|
|
|
//Standard Spring component annotation
|
2018-04-17 13:52:08 +04:00
|
|
|
@Component
|
2018-04-19 15:51:30 +04:00
|
|
|
public class YourBotName extends TelegramLongPollingBot {
|
2018-04-17 13:52:08 +04:00
|
|
|
//Bot body.
|
|
|
|
}
|
|
|
|
```
|
2018-08-30 14:31:26 +02:00
|
|
|
Also you could just implement LongPollingBot or WebHookBot interfaces. All this bots will be registered in context and connected to Telegram api.
|