Idiomatic, fluent and type-safe Kotlin bindings for Telegram Bot API.
val poller = TelegramBotApiPoller(TelegramBotApiClient(botApiToken))
poller.start(TelegramBotUpdateListener(
onMessage = { message ->
message.reply(
text = "Hello, *${message.from?.firstName ?: "stranger"}*!",
parseMode = ParseMode.MARKDOWN,
replyMarkup = inlineKeyboard {
buttonLink("Telegram", "https://telegram.org")
row {
button("Bot", "bot")
button("API", "api")
}
}
)
},
onCallbackQuery = { callbackQuery ->
when (callbackQuery.data) {
"bot" -> callbackQuery.answer("🤖")
"api" -> callbackQuery.answer("🚀")
else -> callbackQuery.answer("🤷")
}
}
))
Using with Gradle for JVM projects
dependencies {
implementation("me.alllex.telegram.botkit:tbot-api-jvm:0.8.0")
}
Using with Maven for JVM projects
<dependency>
<groupId>me.alllex.telegram.botkit</groupId>
<artifactId>tbot-api-jvm</artifactId>
<version>0.8.0</version>
</dependency>
The bindings are generated directly from the source-of-truth Bot API spec.
Telegram Bot API | tbot-api library |
---|---|
7.9 |
0.8.0 |
7.7 |
0.7.0 |
7.4 |
0.6.1 |
7.3 |
0.5.0 |
6.9 |
0.4.0 |
tbot-api library | Requirement |
---|---|
0.4.0 + |
Kotlin 1.9.0+ , JVM 8+ |
./gradlew rollNextApi check
- Error handling
- Cleaner package structure
- Strict library member visibility
- Forward compatibility: published versions of the library should not break with new API versions (union types and enums)
- Support for integration tests bots
Distributed under the MIT License. See LICENSE
for more information.