Telegram API implementation based on Feign http client.
Add the following snippet to any project's pom that depends on telegram-api project:
<repositories>
<repository>
<id>telegram-api</id>
<url>https://raw.github.com/xxlabaza/telegram-api/mvn-repo/</url>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>Then, include dependency to your project:
<dependencies>
...
<dependency>
<groupId>ru.xxlabaza</groupId>
<artifactId>telegram-api</artifactId>
<version>1.0.0</version>
</dependency>
...
</dependencies>Each bot is given a unique authentication token when it is created. The token looks something like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11.
- Getting info about bot:
TelegramService SERVICE = new TelegramService("<bot-api-token>");
User user = SERVICE.getMe().call();
Assert.assertNotNull(user.getId());
Assert.assertNotNull(user.getFirstName());- Sending message:
Message message = SERVICE.sendMessage()
.chat("<chat-id>")
.text("Hello world!")
.call();- Read user's input:
List<Update> updates = SERVICE.getUpdates()
.offset(10)
.limit(50)
.call();For more information - read Telegram API and library's JavaDoc.