{"id":19820714,"url":"https://github.com/dgarrodc/ltb","last_synced_at":"2026-06-09T02:09:52.211Z","repository":{"id":139673348,"uuid":"194450248","full_name":"dgarroDC/ltb","owner":"dgarroDC","description":"LDPL Telegram Bot - Write simple Telegram bots in LDPL!","archived":false,"fork":false,"pushed_at":"2019-12-02T03:56:22.000Z","size":320,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-28T20:24:53.399Z","etag":null,"topics":["ldpl","telegram","telegram-bot","telegram-bot-api"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgarroDC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2019-06-29T21:34:19.000Z","updated_at":"2019-12-02T03:56:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"0a8375d4-8e08-4d51-985d-e554a502632b","html_url":"https://github.com/dgarroDC/ltb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dgarroDC/ltb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarroDC%2Fltb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarroDC%2Fltb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarroDC%2Fltb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarroDC%2Fltb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgarroDC","download_url":"https://codeload.github.com/dgarroDC/ltb/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgarroDC%2Fltb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34088109,"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-09T02:00:06.510Z","response_time":63,"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":["ldpl","telegram","telegram-bot","telegram-bot-api"],"created_at":"2024-11-12T10:24:26.836Z","updated_at":"2026-06-09T02:09:52.182Z","avatar_url":"https://github.com/dgarroDC.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"![The LDPL Telegram Bot Library](images/ldpl-telegram-logo.png)\n\n**The LDPL Telegram Bot Library** is a simple LDPL library lets you create a Telegram bot that can receive and send text messages.\n\nIt provides some new statements:\n* `TG BOT INIT WITH TOKEN \u003cTEXT or TEXT-VAR\u003e`\n* `TG BOT SEND MESSAGE \u003cTEXT or TEXT-VAR\u003e TO \u003cNUMBER or NUMBER-VAR\u003e [WITH INLINE KEYBOARD \u003cTEXT or TEX-VAR\u003e]`\n* `TG BOT CREATE INLINE KEYBOARD IN \u003cTEXT-VAR\u003e`\n* `TG BOT ADD ROW TO INLINE KEYBOARD \u003cTEXT-VAR\u003e`\n* `TG BOT ADD BUTTON WITH TEXT \u003cTEXT or TEXT-VAR\u003e AND {URL | CALLBACK DATA} \u003cTEXT or TEXT-VAR\u003e TO INLINE KEYBOARD \u003cTEXT-VAR\u003e`\n\nAnd it announces you about new updates via the following sub-procedures that you must implement so you can handle them if you want:\n* `ltb.onMessage`\n* `ltb.onJoin`\n* `ltb.onDeparture`\n* `ltb.onCallbackQuery`\n\n## Installation\n\nYou can install this library **by hand** or **using [LPM](https://github.com/Lartu/ldpl#-libraries)**.\n\n### 📦 Installing using LPM\n\nOpen a terminal and write `lpm install ltb`. Once downloaded, include it in your LDPL project by adding the line:\n\n```coffeescript\nusing package ltb\n```\n\nbefore the `data` and `procedure` sections of your source file. The library is ready to be used.\n\n### ✋🏻 Installing by hand\n\nInclude the library into your LDPL project by copying the file *ltb.ldpl* and the folders *extensions* and *thirdparty* to your project directory and then adding the line:\n\n```coffeescript\ninclude \"ltb.ldpl\"\n```\n\nbefore the `data` and `procedure` sections of your source file. The library is\nready to be used.\n\n### ⚠️ Note\n\nThis library requires [LDPL 4.3](http://github.com/lartu/ldpl).\n\nYou also need [libcurl](https://curl.haxx.se/libcurl/) with OpenSSL. For example, in Debian, Ubuntu or similar you can install it with:\n\n`$ sudo apt-get install libcurl4-openssl-dev`\n\n## Using ltb\n\nTo use `ltb`, you must download this repo and in your LDPL program `IMPORT` the path to `ltb.ldpl`.\n\nTo start your bot, use this custom statement passing your bot's [token](https://core.telegram.org/bots#6-botfather):\n\n`TG BOT INIT WITH TOKEN \u003cTEXT or TEXT-VAR\u003e`\n\nThis statement will block your main code execution, unless there is a problem initializing the bot (network problem, invalid token, etc.), in which case it will set `ERRORCODE` in `1`, `ERRORTEXT` with the error description and return.\n\nAfter the bot is successfully initialized, `ltb` will process each update that your bot receives and calls a sub-procedure passing information about the new update. There are four of them, and you must implement it in your code:\n\n### `ltb.onMessage`\n```coffeescript\n# This sub-procedure is called each time a new text message arrives.\n# Captions in animation, audio, document, photo, video or voice are captured too.\nsub ltb.onMessage\nparameters:\n    messageId is number     # id of the sent message\n    chatId is number        # id of the chat where is was sent\n    userData is text map    # user data from sender\n    messageText is text     # content of the message\nprocedure:\n    # Your code here\nend sub\n```\n\n### `ltb.onJoin`\n```coffeescript\n# This sub-procedure is called each time a user joins a chat.\nsub ltb.onJoin\nparameters:\n    messageId is number     # id of the sent message announcing the user join\n    chatId is number        # id of the chat the user joined\n    userData is text map    # user data from the user who joined the chat\nprocedure:\n    # Your code here\nend sub\n```\n\n### `ltb.onDeparture`\n```coffeescript\n# This sub-procedure is called each time a user leaves a chat.\nsub ltb.onDeparture\nparameters:\n    messageId is number     # id of the sent message announcing the user departure\n    chatId is number        # id of the chat the user left\n    userData is text map    # user data from the user who left the chat\nprocedure:\n    # Your code here\nend sub\n```\n\n### `ltb.onCallbackQuery`\n```coffeescript\n# This sub-procedure is called each time a user press a button with callback data.\nsub ltb.onCallbackQuery\nparameters:\n    chatId is number        # id of the chat from the message of the button that was pressed\n    userData is text map    # user data from the user who pressed the button\n    callbackData is text    # callback data from the pressed button\n    answerText is text      # store a text here to display a notification to the user\n    answerAlert is number   # store 1 here to show answerText as an alert instead of a notification at the top of the chat screen\nprocedure:\n    # Your code here\nend sub\n```\n\nAll of the three sub-procedures must be declared with all the parameters specified above, but you may leave a `procedure:` subsection empty if you don't want to do anything on some updates.\n\nThe `userData` `TEXT MAP` contains the following information about the user:\n\n|    Key     |          Description          |\n|------------|-------------------------------|\n| id         | Unique identifier of the user |\n| first_name | User's first name             |\n| last_name  | User's last name              |\n| username   | User's username               |\n\nBear in mind that some of this elements may be empty (`\"\"`), a message from a channel has no user information for example, and there are users without `last_name` or `username` (but they all have `id` and `first_name`).\n\nYou can send messages with this statement:\n\n`TG BOT SEND MESSAGE \u003cTEXT or TEXT-VAR\u003e TO \u003cNUMBER or NUMBER-VAR\u003e [WITH INLINE KEYBOARD \u003cTEXT or TEX-VAR\u003e]`\n\nIt takes the message text and the chat id where you want to send it. You must use it after you `INIT` the bot. If there is a problem delivering the message (network problem, invalid chat id, etc.), `ltb` will set `ERRORCODE` in `1` and `ERRORTEXT` with the error description.\n\nYou can also optionally send the message with an inline keyboard. The `TEXT` you pass here must be a serialized JSON of a [InlineKeyboardMarkup object](https://core.telegram.org/bots/api#inlinekeyboardmarkup), but don't worry, you can construct it with `ltb` statements:\n\n`TG BOT CREATE INLINE KEYBOARD IN \u003cTEXT-VAR\u003e`\n\nThis statement stores in the variable an inline keyboard with an empty row.\n\n`TG BOT ADD ROW TO INLINE KEYBOARD \u003cTEXT-VAR\u003e`\n\nThis statement modifies the inline keyboard appending an empty row at the end\n\n`TG BOT ADD BUTTON WITH TEXT \u003cTEXT or TEXT-VAR\u003e AND {URL | CALLBACK DATA} \u003cTEXT or TEXT-VAR\u003e TO INLINE KEYBOARD \u003cTEXT-VAR\u003e`\n\nThis statement modifies thee inline keyboard appending a button at the end of its last row. You must specify the the text of the button's label and:\n* an URL that will be opened when an user press the button, or\n* callback data that will be send to `ltb.onCallbackQuery` and lets you handle and answering it.\n\n**Warning**: The last two statements are only guaranteed to work with inline keyboards that you created and modified with `ltb` statements. That means that if you pass some `InlineKeyboardMarkup` that you made manually or with some other tools, the statements may modify them in such a way that the text becomes an invalid `InlineKeyboardMarkup`.\n\nAll `ltb` errors are logged to the *standard error*.\n\nSee the [examples](examples) to learn more on how to use `ltb`. If you want to test them, paste your bot's token in [token.ldpl](examples/token.ldpl).\n\n## License\n\n`ltb` is released under the MIT license. It uses the [JSON for Modern C++](https://github.com/nlohmann/json) library by Niels Lohmann, released also under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgarrodc%2Fltb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgarrodc%2Fltb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgarrodc%2Fltb/lists"}