2018-04-17 11:52:08 +02: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"/>
|
|
|
|
|
|
|
|
[![Build Status](https://travis-ci.org/rubenlagus/TelegramBots.svg?branch=master)](https://travis-ci.org/rubenlagus/TelegramBots)
|
|
|
|
[![Jitpack](https://jitpack.io/v/rubenlagus/TelegramBots.svg)](https://jitpack.io/#rubenlagus/TelegramBots)
|
|
|
|
[![JavaDoc](http://svgur.com/i/1Ex.svg)](https://addo37.github.io/AbilityBots/)
|
|
|
|
[![Telegram](http://trellobot.doomdns.org/telegrambadge.svg)](https://telegram.me/JavaBotsApi)
|
|
|
|
[![ghit.me](https://ghit.me/badge.svg?repo=rubenlagus/TelegramBots)](https://ghit.me/repo/rubenlagus/TelegramBots)
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
Usage
|
|
|
|
-----
|
|
|
|
|
|
|
|
**Maven**
|
|
|
|
|
|
|
|
```xml
|
|
|
|
<dependency>
|
|
|
|
<groupId>org.telegram</groupId>
|
|
|
|
<artifactId>telegrambots-spring-boot-starter</artifactId>
|
2023-08-19 19:40:14 +02:00
|
|
|
<version>6.8.0</version>
|
2018-04-17 11:52:08 +02:00
|
|
|
</dependency>
|
|
|
|
```
|
|
|
|
|
|
|
|
**Gradle**
|
|
|
|
|
|
|
|
```gradle
|
2023-08-19 19:40:14 +02:00
|
|
|
implementation 'org.telegram:telegrambots-spring-boot-starter:6.8.0'
|
2018-04-17 11:52:08 +02: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 22:09:02 +01:00
|
|
|
public static void main(String[] args) {
|
2020-06-15 10:53:37 +02:00
|
|
|
SpringApplication.run(YourApplicationMainClass.class, args);
|
2018-04-17 11:52:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
After that your bot will look like:
|
|
|
|
```java
|
2018-08-30 14:31:26 +02:00
|
|
|
//Standard Spring component annotation
|
2018-04-17 11:52:08 +02:00
|
|
|
@Component
|
2018-04-19 13:51:30 +02:00
|
|
|
public class YourBotName extends TelegramLongPollingBot {
|
2018-04-17 11:52:08 +02: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.
|