{"id":15041011,"url":"https://github.com/insanusmokrassar/ktgbotapi","last_synced_at":"2026-01-05T06:24:58.130Z","repository":{"id":37450938,"uuid":"163152024","full_name":"InsanusMokrassar/ktgbotapi","owner":"InsanusMokrassar","description":"Type-safe library for work with Telegram Bot API","archived":false,"fork":false,"pushed_at":"2025-09-29T10:10:10.000Z","size":210761,"stargazers_count":411,"open_issues_count":23,"forks_count":34,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-10-02T12:08:19.942Z","etag":null,"topics":["dev-inmo-tgbotapi","hacktoberfest","kotlin","kotlin-js","kotlin-jvm","kotlin-library","kotlin-multiplatform","ktgbotapi","telegram","telegram-bot-api","telegram-bots-api","telegrambotapi","tgbotapi"],"latest_commit_sha":null,"homepage":"https://docs.inmo.dev/tgbotapi/index.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/InsanusMokrassar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"custom":["https://tonscan.org/address/UQAtuSLJ76Zehc3qP-eRYMR98fPIu_oOp_atcpVX55zxHwTU"]}},"created_at":"2018-12-26T07:45:11.000Z","updated_at":"2025-09-25T09:07:13.000Z","dependencies_parsed_at":"2023-09-23T12:36:33.818Z","dependency_job_id":"e0ccf704-6d9f-4775-af88-b7fcf0aae8da","html_url":"https://github.com/InsanusMokrassar/ktgbotapi","commit_stats":{"total_commits":2774,"total_committers":19,"mean_commits":146.0,"dds":0.03460706560922855,"last_synced_commit":"191e4cff00fa5b9539e86cd29c165d1299a32f07"},"previous_names":["insanusmokrassar/telegrambotapi"],"tags_count":208,"template":false,"template_full_name":null,"purl":"pkg:github/InsanusMokrassar/ktgbotapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InsanusMokrassar%2Fktgbotapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InsanusMokrassar%2Fktgbotapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InsanusMokrassar%2Fktgbotapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InsanusMokrassar%2Fktgbotapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/InsanusMokrassar","download_url":"https://codeload.github.com/InsanusMokrassar/ktgbotapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/InsanusMokrassar%2Fktgbotapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001894,"owners_count":26083226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["dev-inmo-tgbotapi","hacktoberfest","kotlin","kotlin-js","kotlin-jvm","kotlin-library","kotlin-multiplatform","ktgbotapi","telegram","telegram-bot-api","telegram-bots-api","telegrambotapi","tgbotapi"],"created_at":"2024-09-24T20:45:24.102Z","updated_at":"2025-10-09T18:36:18.244Z","avatar_url":"https://github.com/InsanusMokrassar.png","language":"Kotlin","funding_links":["https://tonscan.org/address/UQAtuSLJ76Zehc3qP-eRYMR98fPIu_oOp_atcpVX55zxHwTU"],"categories":[],"sub_categories":[],"readme":"# TelegramBotAPI [![Maven Central Version](https://img.shields.io/maven-central/v/dev.inmo/tgbotapi)](https://central.sonatype.com/artifact/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-9.2-blue)](https://core.telegram.org/bots/api-changelog#august-15-2025)\n\n|          Docs          |                                   [![KDocs](https://img.shields.io/static/v1?label=Dokka\u0026message=KDocs\u0026color=blue\u0026logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Mk\u0026message=Docs\u0026color=blue\u0026logo=mkdocs)](https://docs.inmo.dev/tgbotapi/index.html)                                    |\n|:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|\n|      Useful repos      |                           [![Create bot](https://img.shields.io/static/v1?label=Github\u0026message=Template\u0026color=blue\u0026logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [![Examples](https://img.shields.io/static/v1?label=Github\u0026message=Examples\u0026color=blue\u0026logo=github)](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/)                           |\n|          Misc          |                              [![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin) [![Small survey](https://img.shields.io/static/v1?label=Google\u0026message=Survey\u0026color=blue\u0026logo=google-sheets)](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link)                               |\n|       Platforms        |                                                                                                      ![JVM](https://img.shields.io/badge/JVM-red?style=plastic\u0026logo=openjdk\u0026logoColor=white) ![Js](https://img.shields.io/badge/JavaScript-323330?style=plastic\u0026logo=javascript\u0026logoColor=F7DF1E)                                                                                                       |\n| Experimental Platforms |                                                                                                [![Linux x64](https://img.shields.io/badge/LinuxX64-FCC624?style=plastic\u0026logo=linux\u0026logoColor=black)](https://kotlinlang.org/docs/native-target-support.html#tier-1) [![MinGW x64](https://img.shields.io/badge/MinGWX64-black?style=plastic\u0026logo=windows\u0026logoColor=green)](https://kotlinlang.org/docs/native-target-support.html#tier-1)                                                                                                 |\n\n\u003c!--- [![Telegram Channel](./resources/tg_channel_qr.jpg)](https://t.me/ktgbotapi) ---\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://t.me/ktgbotapi\"\u003e\n    \u003cimg src=\"./resources/tg_channel_qr.jpg\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\nHello! This is a set of libraries for working with Telegram Bot API.\n\n## Examples\n\nThere are several things you need to do to launch examples below:\n\n* Add `mavenCentral()` to your project repositories\n    * [Maven variant](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#pomxml)\n* Add dependency `implementation \"dev.inmo:tgbotapi:$tgbotapi_version\"` \n    * Replace `tgbotapi_version` with exact version (see last one in the table above) or put variable with this name in project\n    * Alternative variant for maven [here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project#telegrambotapi)\n\nMore including instructions [available here](https://github.com/InsanusMokrassar/TelegramBotAPI/wiki/Including-in-your-project).\nOther configuration examples:\n\n* [For multiplatform](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/tree/master/ResenderBot)\n* [For JVM](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/blob/master/GetMeBot/build.gradle)\n\n### Most common example\n\n```kotlin\nsuspend fun main() {\n  val bot = telegramBot(TOKEN)\n\n  bot.buildBehaviourWithLongPolling {\n    println(getMe())\n  \n    onCommand(\"start\") {\n      reply(it, \"Hi:)\")\n    }\n  }.join()\n}\n```\n\nIn this example you will see information about this bot at the moment of starting and answer with `Hi:)` every time it\ngets message `/start`\n\n### Handling only last messages\n\n```kotlin\nsuspend fun main() {\n  val bot = telegramBot(TOKEN)\n\n  val flowsUpdatesFilter = FlowsUpdatesFilter()\n  bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) {\n    println(getMe())\n  \n    onCommand(\"start\") {\n      reply(it, \"Hi:)\")\n    }\n\n    retrieveAccumulatedUpdates(this).join()\n  }\n}\n```\n\nThe main difference with the previous example is that bot will get only last updates (accumulated before bot launch\nand maybe some updates it got after launch)\n\n### Build a little bit more complex behaviour\n\n```kotlin\nsuspend fun main() {\n  val bot = telegramBot(TOKEN)\n\n  bot.buildBehaviourWithLongPolling {\n    println(getMe())\n\n    val nameReplyMarkup = ReplyKeyboardMarkup(\n      matrix {\n        row {\n          +SimpleKeyboardButton(\"nope\")\n        }\n      }\n    )\n    onCommand(\"start\") {\n      val photo = waitPhoto(\n        SendTextMessage(it.chat.id, \"Send me your photo please\")\n      ).first()\n\n      val name = waitText(\n        SendTextMessage(\n          it.chat.id,\n          \"Send me your name or choose \\\"nope\\\"\",\n          replyMarkup = nameReplyMarkup\n        )\n      ).first().text.takeIf { it != \"nope\" }\n\n      sendPhoto(\n        it.chat,\n        photo.mediaCollection,\n        entities = buildEntities {\n          if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)\n        }\n      )\n    }\n  }.join()\n}\n```\n\n### More examples\n\nYou may find examples in [this project](https://github.com/InsanusMokrassar/TelegramBotAPI-examples). Besides, you are\nalways welcome in our [docs](https://docs.inmo.dev/tgbotapi/index.html) and\n[chat](https://t.me/InMoTelegramBotAPIChat).\n\n### Bot API Server Notice\n\nUnder the hood, default bots realizations will try to use links\n([PathedFile](tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/types/files/PathedFile.kt)#filePath) as files each\ntime you are trying to download file from telegram in any way - via saving to file, use stream or download as byte array.\nTo let bot correctly download files from bot api server, you must:\n\n* Run bot api server locally\nto proxy requests for files to the server where bot api server has been hosted\n  * In case of local bot api server (shared one host machine) you must ensure that access to bot api server has been\n  granted for your bot. For example, [aiogram/telegram-bot-api](https://hub.docker.com/r/aiogram/telegram-bot-api) image\n  use `101` UID/GID in linux for user and group as owners. So, your bot must run under user included in `101` group\n  (like `systemd-journal`) or be `101` UID user (like `systemd-resolve`)\n* **OR** Use some reverse proxy (like nginx). It will allow you to broadcast your bots files without linux rights problems\n  * Set [TelegramAPIUrlsKeeper](tgbotapi.core/src/commonMain/kotlin/dev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper.kt)#fileLinkUrlMapper\n  to map urls to let bot execute requests to your nginx proxy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsanusmokrassar%2Fktgbotapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsanusmokrassar%2Fktgbotapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsanusmokrassar%2Fktgbotapi/lists"}