{"id":31524653,"url":"https://github.com/dehuckakpyt/telegram-bot","last_synced_at":"2026-06-17T14:01:07.235Z","repository":{"id":184376494,"uuid":"670859055","full_name":"DEHuckaKpyT/telegram-bot","owner":"DEHuckaKpyT","description":"Kotlin Telegram Bot Library for creating scalable and expandable applications with helpful features.","archived":false,"fork":false,"pushed_at":"2026-04-15T07:31:59.000Z","size":12087,"stargazers_count":47,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-15T09:27:29.745Z","etag":null,"topics":["bot","coroutines","kotlin","kotlin-bot","kotlin-framework","kotlin-library","kotlin-telegram-bot","ktor","spring","telegram","telegram-bot","telegram-bot-api","telegram-bots"],"latest_commit_sha":null,"homepage":"https://dehuckakpyt.github.io/telegram-bot/starter-topic.html","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEHuckaKpyT.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-07-26T02:21:03.000Z","updated_at":"2026-04-05T13:10:18.000Z","dependencies_parsed_at":"2023-07-28T07:37:07.866Z","dependency_job_id":"b93007ae-5f67-41e9-96a4-23cd9bf2ff1f","html_url":"https://github.com/DEHuckaKpyT/telegram-bot","commit_stats":null,"previous_names":["dehuckakpyt/telegram-bot"],"tags_count":68,"template":false,"template_full_name":null,"purl":"pkg:github/DEHuckaKpyT/telegram-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEHuckaKpyT%2Ftelegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEHuckaKpyT%2Ftelegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEHuckaKpyT%2Ftelegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEHuckaKpyT%2Ftelegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEHuckaKpyT","download_url":"https://codeload.github.com/DEHuckaKpyT/telegram-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEHuckaKpyT%2Ftelegram-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34451342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-17T02:00:05.408Z","response_time":127,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","coroutines","kotlin","kotlin-bot","kotlin-framework","kotlin-library","kotlin-telegram-bot","ktor","spring","telegram","telegram-bot","telegram-bot-api","telegram-bots"],"created_at":"2025-10-03T17:35:07.471Z","updated_at":"2026-06-17T14:01:07.228Z","avatar_url":"https://github.com/DEHuckaKpyT.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin Telegram Bot\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.github.dehuckakpyt.telegrambot/telegram-bot-core?label=Maven%20Central\u0026logo=apache-maven\u0026logoColor=red\u0026color=red)](https://central.sonatype.com/artifact/io.github.dehuckakpyt.telegrambot/telegram-bot-core)\n[![Documentation](https://img.shields.io/badge/Writerside-docs-forest?logo=jetbrains\u0026logoColor=black)](https://dehuckakpyt.github.io/telegram-bot/starter-topic.html)\n\n[![Telegram](https://img.shields.io/badge/Telegram-Join%20Chat-2CA5E0?logo=telegram\u0026logoColor=white)](https://t.me/+8YNQBUvqe-phMzYy)\n\n[![Telegram Bot API version](https://img.shields.io/badge/Bot_Api-10.1-blue?logo=telegram)](https://core.telegram.org/bots/api)\n[![GitHub License](https://img.shields.io/github/license/DEHuckaKpyT/telegram-bot?logo=apache\u0026logoColor=red\u0026label=License\u0026color=orange)](https://github.com/DEHuckaKpyT/telegram-bot/blob/master/LICENSE.txt)\n\nKotlin library for creating Telegram Bots. You can use clean version, with implementation for [Spring](https://spring.io/), [Ktor](https://ktor.io/)+[Koin](https://insert-koin.io/) or create with you own implementation.\nIt have also possibility to save state in database with [Spring JPA](https://spring.io/projects/spring-data-jpa/) or [Exposed](https://github.com/JetBrains/Exposed).\n\n[Full documentation with examples and explanations](https://dehuckakpyt.github.io/telegram-bot/starter-topic.html).\n\nExample of applications in [example-spring](https://github.com/DEHuckaKpyT/telegram-bot/tree/master/example-spring), [example-ktor](https://github.com/DEHuckaKpyT/telegram-bot/tree/master/example-ktor), [example-core](https://github.com/DEHuckaKpyT/telegram-bot/tree/master/example-core) directories.\n\n## Why this library\n- Focused on building a **dialog with the user** (for example, no need to specify `chatId` in dialog chains).\n- Has **many useful utilities** (such as templating, keyboard and button creating and other).\n- Telegram API methods realization have **overloads** for more comfortable usage (like a `chatId` as `String` or `Long`).\n- Working on **coroutines**.\n- Has **clean** version or with **Spring** or **Ktor+Koin** frameworks.\n- Has possibility to **save state in database** with **Spring JPA** or **Exposed**.\n- Easy to **write tests** for your bot.\n\n## Tested with\n\n- JDK 17\n- Kotlin 2.2.21\n\n\n## Quick start\n\nToken/username can be provided from code, `application.*` application config or `telegram-bot.yaml`.\n\n`build.gradle.kts`\n```kotlin\nrepositories {\n    mavenCentral()\n}\ndependencies {\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-core:$telegram_bot_version\")\n}\n```\n\n### Core version\n\nCan be used for integrate with any frameworks manually.\n\n`com/example/myproject/App.kt`\n```kotlin\nfun main(args: Array\u003cString\u003e): Unit {\n    val config = TelegramBotConfig().apply {\n        // token/username can be loaded from resources/telegram-bot.yaml\n        // token = \"\u003cbot token required\u003e\"\n        // username = \"\u003cbot username required\u003e\"\n        \n        receiving {\n            handling {\n                startCommand()\n            }\n        }\n    }\n    val context = TelegramBotFactory.createTelegramBotContext(config)\n    val telegramBotManager = context.telegramBotManager\n    // get telegramBot, templater, buttonFactory and other from created context...\n    \n    // start and stop for example only, use this methods with starting and stopping your application\n    telegramBotManager.start()\n    readlnOrNull()\n    telegramBotManager.stop()\n}\n```\n`resources/telegram-bot.yaml`\n```yaml\ntelegram-bot.token: ${TELEGRAM_BOT_TOKEN}\ntelegram-bot.username: ${TELEGRAM_BOT_USERNAME}\n```\n`com/example/myproject/handler/StartHandler.kt`\n```kotlin\nfun BotHandling.startCommand() {\n    command(\"/start\", next = \"get_name\") {\n        // you don't have to specify a chatId to send messages\n        sendMessage(\"Hello, my name is ${bot.username} :-)\")\n        // but you can do it\n        bot.sendMessage(chatId, \"And what is your name?\")\n    }\n\n    step(\"get_name\") {\n        sendMessage(\"Nice to meet you, $text!\")\n    }\n}\n```\n\n### Spring version\n\nReady-to-use solution for use with Spring.\n\n`build.gradle.kts`\n```kotlin\nrepositories {\n    mavenCentral()\n}\ndependencies {\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-core:$telegram_bot_version\")\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-spring:$telegram_bot_version\")\n}\n```\n`com/example/myproject/config/BotConfig.kt`\n```kotlin\n@EnableTelegramBot\n@Configuration\nclass BotConfig {\n\n    @Bean //optional bean\n    fun telegramBotConfig(): TelegramBotConfig = TelegramBotConfig().apply {\n        //configure..\n    }\n}\n```\n`resources/application.properties`\n```\ntelegram-bot.token=${TELEGRAM_BOT_TOKEN}\ntelegram-bot.username=${TELEGRAM_BOT_USERNAME}\n```\n`com/example/myproject/handler/StartHandler.kt`\n```kotlin\n@HandlerComponent\nclass StartHandler : BotHandler({\n    command(\"/start\") {\n        sendMessage(\"Hello, my name is ${bot.username} :-)\")\n    }\n})\n```\n\n### Ktor+Koin version\n\nReady-to-use solution for use with Ktor+Koin.\n\n`build.gradle.kts`\n```kotlin\nplugins {\n    // Optional plugin for koin\n    id(\"com.google.devtools.ksp\") version \"\u003c\u003e\"\n}\n\nrepositories {\n    mavenCentral()\n}\ndependencies {\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-core:$telegram_bot_version\")\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-ktor:$telegram_bot_version\")\n\n    // Optional dependencies for koin\n    compileOnly(\"io.insert-koin:koin-annotations:\u003c\u003e\")\n    ksp(\"io.insert-koin:koin-ksp-compiler:\u003c\u003e\")\n}\n\nksp {\n    arg(\"KOIN_DEFAULT_MODULE\", \"true\")\n}\n```\n`com/example/myproject/KtorApp.kt`\n```kotlin\nfun Application.module() {\n    install(Koin) {\n        modules(defaultModule)\n    }\n    install(TelegramBot) {\n        //configure..\n    }\n}\n```\n`resources/application.conf`\n```\ntelegram-bot {\n    token = ${TELEGRAM_BOT_TOKEN}\n    username = ${TELEGRAM_BOT_USERNAME}\n}\n```\n`com/example/myproject/handler/StartHandler.kt`\n```kotlin\n@Factory\nclass StartHandler : BotHandler({\n    command(\"/start\") {\n        sendMessage(\"Hello, my name is ${bot.username} :-)\")\n    }\n})\n```\n\n\n## Database integration\n\n\u003e [!WARNING]  \n\u003e And it is \u003cb\u003ehighly recommended\u003c/b\u003e to use with \u003cb\u003esaving states in database\u003c/b\u003e.\n\u003e There are ready-to-use solutions for \u003ca href=\"spring-jpa.md\"\u003eSpring JPA\u003c/a\u003e and \u003ca href=\"exposed.md\"\u003eExposed\u003c/a\u003e.\n\u003e Interfaces to be implemented with saving to the database described \u003ca href=\"sources.md\"\u003ehere\u003c/a\u003e.\n\n### Spring JPA\n\nAll you have to do is add a dependency for `source-jpa`:\n\n#### Spring 3.x\n```kotlin\ndependencies {\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-core:$telegram_bot_version\")\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-spring:$telegram_bot_version\")\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-source-jpa:$telegram_bot_version\")\n}\n```\n\n#### Available properties\n\n| PROPERTY                                                   | DEFAULT | DESCRIPTION                                                          |\n|------------------------------------------------------------|---------|----------------------------------------------------------------------|\n| `telegram-bot.source-jpa.enabled`                          | `true`  | Disable all default sources                                          |\n| `telegram-bot.source-jpa.message-source.enabled`           | `true`  | Disable default message source                                       |\n| `telegram-bot.source-jpa.chain-source.enabled`             | `true`  | Disable default chain source                                         |\n| `telegram-bot.source-jpa.callback-content-source.enabled`  | `true`  | Disable default callback content source                              |\n| `telegram-bot.source-jpa.callback-content-source.per-user` | `20`    | Max count of contents will be saved for every user (`-1` for ignore) |\n\n### Exposed\n\nTo save the state in the database, it is necessary to connect to it using [Exposed](https://github.com/JetBrains/Exposed) ([example](https://github.com/DEHuckaKpyT/telegram-bot/blob/master/example/src/main/kotlin/io/github/dehuckakpyt/telegrambotexample/plugin/DatabaseConnection.kt)).\nThen add the dependency and specify the sources:\n\n```kotlin\ndependencies {\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-core:$telegram_bot_version\")\n    implementation(\"io.github.dehuckakpyt.telegrambot:telegram-bot-source-exposed:$telegram_bot_version\")\n}\n```\n```kotlin\nval config = TelegramBotConfig().apply {\n    messageSource = { MessageSource.inDatabase }\n    receiving {\n        callbackContentSource = {\n            CallbackContentSource.inDatabase(\n                maxCallbackContentsPerUser = 20\n            )\n        }\n        chainSource = { ChainSource.inDatabase }\n    }\n}\n```\n\n[🔗Full documentation with examples and explanations🔗](https://dehuckakpyt.github.io/telegram-bot/starter-topic.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdehuckakpyt%2Ftelegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdehuckakpyt%2Ftelegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdehuckakpyt%2Ftelegram-bot/lists"}