A simple wrapper for using telegram api with java (Telegram Api). Bot API version: 5.0
Moved to: https://gitlab.com/artfable-public/telegram-bot-api/telegram-api-java
Requirements:
- Java 11
Note! Kotlin 1.5.21 used as well. However, you can don't care about it, if you don't want to modify.
repositories {
maven(url = "https://artfable.jfrog.io/artifactory/default-maven-local")
}
dependencies {
implementation("com.artfable.telegram:telegram-api:1.0.1")
}
For start create instance of LongPollingTelegramBot or WebhookTelegramBot. Both types require set of Behaviours - services that handling updates and do logic of the bot.
For Spring use starter
Should be implemented sending logic. URL template provided in the interface.
Get updates by requesting them. All requests will be done through taskExecutor.
Setup a webhook (proper configuration should be provided). Note! You can set up webhook only for https and 443, 80, 88, 8443 ports! (requirement by Telegram)
For generating self-signed certificate see Telegram Bot FAQ. Note! CN must be a domain name or ip address.
It represents actions that can be done by the bot in response to user actions. Will not process actions that were already handled by CallbackBehaviours. However, all others actions will be handled by all of registered Behaviours.
It represents actions that can be done in response to click on the bot's buttons by user. All that behaviours should have base class AbstractCallbackBehaviour.
To set up bots commands, provide an inputStream with json with commands description.
Example:
[
{
"command": "start",
"description": "Start bot process"
}
]