https://github.com/alllex/telegram-bot-kit
Idiomatic, fluent and type-safe Kotlin bindings for Telegram Bot API
https://github.com/alllex/telegram-bot-kit
kotlin telegram telegram-bot-api wrapper
Last synced: 12 months ago
JSON representation
Idiomatic, fluent and type-safe Kotlin bindings for Telegram Bot API
- Host: GitHub
- URL: https://github.com/alllex/telegram-bot-kit
- Owner: alllex
- License: mit
- Created: 2023-06-30T10:41:59.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-08-18T15:00:57.000Z (almost 2 years ago)
- Last Synced: 2025-03-19T00:12:54.412Z (over 1 year ago)
- Topics: kotlin, telegram, telegram-bot-api, wrapper
- Language: Kotlin
- Homepage:
- Size: 1.25 MB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Telegram Bot API in Kotlin
[](https://central.sonatype.com/namespace/me.alllex.telegram.botkit)
[](https://opensource.org/licenses/MIT)
[](https://github.com/alllex/telegram-bot-kit/actions/workflows/check.yml)
Idiomatic, fluent and type-safe Kotlin bindings for [Telegram Bot API](https://core.telegram.org/bots/api).
```kotlin
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("🤷")
}
}
)
)
```
## Usage
Using with Gradle for JVM projects
```kotlin
dependencies {
implementation("me.alllex.telegram.botkit:tbot-api-jvm:0.9.0")
}
```
Using with Maven for JVM projects
```xml
me.alllex.telegram.botkit
tbot-api-jvm
0.9.0
```
## Compatibility
The bindings are generated directly from the source-of-truth [Bot API spec](https://core.telegram.org/bots/api).
| Telegram Bot API | tbot-api library |
|------------------|------------------|
| `9.0` | `0.9.0` |
| `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.9.0` | Kotlin `2.0.0`, JVM `11` |
| `0.4.0` | Kotlin `1.9.0`, JVM `8` |
## Developing
### Updating API to a new version of Telegram Bot API
```
./gradlew rollNextApi check
```
## Roadmap
### Alpha
- [ ] Error handling
### Beta
- [ ] 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
## License
Distributed under the MIT License. See `LICENSE` for more information.