Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 2 months ago
JSON representation

Idiomatic, fluent and type-safe Kotlin bindings for Telegram Bot API

Awesome Lists containing this project

README

        

# Telegram Bot API in Kotlin

[![Maven Central](https://img.shields.io/maven-central/v/me.alllex.telegram.botkit/tbot-api-jvm.svg?color=success)](https://central.sonatype.com/namespace/me.alllex.telegram.botkit)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Gradle build](https://github.com/alllex/telegram-bot-kit/actions/workflows/check.yml/badge.svg)](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.8.0")
}
```

Using with Maven for JVM projects

```xml

me.alllex.telegram.botkit
tbot-api-jvm
0.8.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 |
|------------------|------------------|
| `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+` |

## 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.