{"id":13896369,"url":"https://github.com/ldb/lua-telegram-bot","last_synced_at":"2025-10-06T08:12:11.133Z","repository":{"id":45355686,"uuid":"49819939","full_name":"ldb/lua-telegram-bot","owner":"ldb","description":"Lua Library for the Telegram Bot API","archived":false,"fork":false,"pushed_at":"2019-10-08T18:38:48.000Z","size":75,"stargazers_count":120,"open_issues_count":1,"forks_count":36,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-05T03:29:08.570Z","etag":null,"topics":["bot","lua","lua-library","telegram"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ldb.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}},"created_at":"2016-01-17T14:11:46.000Z","updated_at":"2025-03-14T14:56:54.000Z","dependencies_parsed_at":"2022-07-13T21:34:15.905Z","dependency_job_id":null,"html_url":"https://github.com/ldb/lua-telegram-bot","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ldb/lua-telegram-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldb%2Flua-telegram-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldb%2Flua-telegram-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldb%2Flua-telegram-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldb%2Flua-telegram-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ldb","download_url":"https://codeload.github.com/ldb/lua-telegram-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ldb%2Flua-telegram-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278577929,"owners_count":26009703,"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-06T02:00:05.630Z","response_time":65,"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","lua","lua-library","telegram"],"created_at":"2024-08-06T18:02:52.092Z","updated_at":"2025-10-06T08:12:11.115Z","avatar_url":"https://github.com/ldb.png","language":"Lua","readme":"# lua-telegram-bot\nA simple LUA Library for the [Telegram Bot API](https://core.telegram.org/bots/api)\n\n## Important\n**This library is not under active development anymore.**\n\n## Changelog\n\n### May 26 2016 - v2.1beta\n\n* Finally finished changes of [Telegram Bot API 2.0](https://core.telegram.org/bots/2-0-intro)\n* Implemented changes of Bot API 2.1 (also why I stayed with 2.1 version tag)\n* Code is still completely untested, but proper tests should be coming soon\n\n### Apr 20 2016 - v2.1alpha\n\n* Added changes of [Telegram Bot API 2.0](https://core.telegram.org/bots/2-0-intro)\n* This update is still not ready, hence the alpha tag\n* `editMessageText`, `editMessageCaption`, `editMessageReplyMarkup` are *not* yet fully ready.\n* *Important:* Renamed `onMessageReceive` to `onTextReceive`\n* Created a discussion[group](https://telegram.me/luatelegrambot) you can join to ask questions.\n\n### Mar 27 2016 - v2.0\n\n* Added [Library Extension](https://github.com/cosmonawt/lua-telegram-bot#Library-extension) which includes an internal update and callback handler and several callback functions which can be overridden.\n* Added file `bot-example.lua` with examples on how to use the new [Library Extension](https://github.com/cosmonawt/lua-telegram-bot#Library-extension).\n* Minor bug fixes\n\n### Feb 28 2016 - v1.1\n\n* Added `disable_notification` argument to all sending methods to enable [silent messages](https://telegram.org/blog/channels-2-0#silent-messages)\n* Added `caption` argument to `sendDocument()`\n\n### Jan 22 2016 - v1.0\n\n* Initial release v1.0-alpha\n\n\n## Installing\n\nTo install this module, place it inside the same folder your bot is located.\n\nThis modules requires [luasec](https://github.com/brunoos/luasec) to work.\nYou can easily install it with luarocks using `luarocks install luasec`.\n\n\nYou will also need a Module for JSON en- and decoding, which can be found [here](http://regex.info/code/JSON.lua).\nSimply place it in the `lua-telegram-bot` Folder.\n\n\n## Using\n\nTo use this module, import it into your bot like this:\n```lua\nlocal bot, extension = (require \"lua-bot-api\").configure(token)\n```\nInclude your bot token as parameter for `configure()`.\n\nAt the moment, only getUpdates method (aka polling) is supported, no webhooks.\n\nThe `bot` Table exports variables and functions which return the following return values.\nThe `extension` Table exports several callback functions as well as an update handler. Check [Library Extension](https://github.com/cosmonawt/lua-telegram-bot#Library-extension) for more information.\n\n### Return values\n\nAll functions return a table as received from the server if called successfully as their first return value.\nThis does *not* mean the request was successful, for example in case of a bad `offset` in `getUpdates()`.\n\nA function returns `nil` and an `error description` if it was wrongly called (missing parameters).\n\n### Available Variables\n\n```lua\nid\n```\n```lua\nusername\n```\n```lua\nfirst_name\n```\n\n### Available Functions\n\n```lua\ngetMe()\n```\n```lua\ngetUpdates([offset] [,limit] [,timeout])\n```\n```lua\nsendMessage(chat_id, text [,parse_mode] [,disable_web_page_preview] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nforwardMessage(chat_id, from_chat_id [,disable_notification], message_id)\n```\n```lua\nsendPhoto(chat_id, photo [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendAudio(chat_id, audio, duration [,performer] [,title] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendDocument(chat_id, document [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendSticker(chat_id, sticker [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendVideo(chat_id, video [,duration] [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendVoice(chat_id, voice [,duration] [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendLocation(chat_id, latitude, longitude [,disable_notification] [,reply_to_message_id] [,reply_markup])\n```\n```lua\nsendChatAction(chat_id, action)\n```\n```lua\ngetUserProfilePhotos(user_id [,offset] [,limit])\n```\n```lua\ngetFile(file_id)\n```\n\n#### Inline Mode functions\n\n```lua\nanswerInlineQuery(inline_query_id, results [,cache_time] [,is_personal] [,next_offset])\n```\n\n```lua\nanswerCallbackQuery(callback_query_id, text [, show_alert])\n```\n\n#### Bot API 2.0 functions\n\n```lua\nkickChatMember(chat_id, user_id)\n```\n\n```lua\nunbanChatMember(chat_id, user_id)\n```\n\n```lua\neditMessageText(chat_id, message_id, inline_message_id, text [, parse_mode] [, disable_web_page_preview] [, reply_markup])\n```\n\n```lua\neditMessageCaption(chat_id, message_id, inline_message_id, caption [, reply_markup])\n```\n\n```lua\neditMessageReplyMarkup(chat_id, message_id, inline_message_id [, reply_markup])\n```\n\n#### Bot API 2.1 functions\n\n```lua\ngetChat(chat_id)\n```\n\n```lua\nleaveChat(chat_id)\n```\n\n```lua\ngetChatAdministrators(chat_id)\n```\n\n```lua\ngetChatMembersCount(chat_id)\n```\n\n```lua\ngetChatMember(chat_id, user_id)\n```\n\n### Helper functions:\n\n\n```lua\ndownloadFile(file_id [,download_path])\n```\n- Downloads file from Telegram Servers.\n- `download_path` is an optional path where the file can be saved. If not specified, it will be saved in `/downloads/\u003cfilenameByTelegram\u003e`. In both cases make sure the path already exists, since LUA can not create folders without additional modules.\n\n```lua\ngenerateReplyKeyboardMarkup(keyboard [,resize_keyboard] [,one_time_keyboard] [,selective])\n```\n- Generates a `ReplyKeyboardMarkup` of type `reply_markup` which can be sent optionally in other functions such as `sendMessage()`.\n- Displays the custom `keyboard` on the receivers device.\n\n```lua\ngenerateReplyKeyboardHide([hide_keyboard] [,selective])\n```\n- Generates a `ReplyKeyboardHide` of type `reply_markup` which can be sent optionally in other functions such as `sendMessage()`.\n- Forces to hide the custom `keyboard` on the receivers device.\n- `hide_keyboard` can be left out, as it is always `true`.\n\n```lua\ngenerateForceReply([force_reply] [,selective])\n```\n- Generates a `ForceReply` of type `reply_markup` which can be sent optionally in other functions such as `sendMessage()`.\n- Forces to reply to the corresponding message from the receivers device.\n- `force_reply` can be left out, as it is always `true`.\n\n## Library Extension\n\nThe Library extension was added to help developers focus on the things that actually matter in a bot: It's logic.\nIt offers serveral callback functions which can be overridden to provide the wanted logic.\n\n### Available Functions\n\nTo use the extension, simply add another table variable to the initial `require` call like so:\n\n```lua\nlocal bot, extension = require(\"lua-bot-api\").configure(token)\n```\n\nThe `extension` Table now stores the following functions:\n\n```lua\nrun()\n```\n- Provides an update handler which automatically fetches new updates from the server and calls the respective callback functions.\n\n```lua\nonUpdateReceive(update)\n```\n- Is called every time an update, no matter of what type, is received.\n\n```lua\nonTextReceive(message)\n```\n- Is called every time a text message is received.\n\n```lua\nonPhotoReceive(message)\n```\n- Is called every time a photo is received.\n\n```lua\nonAudioReceive(message)\n```\n- Is called every time audio is received.\n\n```lua\nonDocumentReceive(message)\n```\n- Is called every time a document is received.\n\n```lua\nonStickerReceive(message)\n```\n- Is called every time a sticker is received.\n\n```lua\nonVideoReceive(message)\n```\n- Is called every time a video is received.\n\n```lua\nonVoiceReceive(message)\n```\n- Is called every time a voice message is received.\n\n```lua\nonContactReceive(message)\n```\n- Is called every time a contact is received.\n\n```lua\nonLocationReceive(message)\n```\n- Is called every time a location is received.\n\n```lua\nonLeftChatParticipant(message)\n```\n- Is called every time a member or the bot itself leaves the chat.\n\n```lua\nonNewChatParticipant(message)\n```\n- Is called when a member joins a chat or the bot itself is added.\n\n```lua\nonNewChatTitle(message)\n```\n- Is called every time the chat title is changed.\n\n```lua\nonNewChatPhoto(message)\n```\n- Is called every time the chat photo is changed.\n\n```lua\nonDeleteChatPhoto(message)\n```\n- Is called every time the chat photo is deleted.\n\n```lua\nonGroupChatCreated(message)\n```\n- Is called every time a group chat is created directly with the bot.\n\n```lua\nonSupergroupChatCreated(message)\n```\n\n```lua\nonChannelChatCreated(message)\n```\n\n```lua\nonMigrateToChatId(message)\n```\n- Is called every time a group is upgraded to a supergroup.\n\n```lua\nonMigrateFromChatId(message)\n```\n\n```lua\nonInlineQueryReceive(inlineQuery)\n```\n- Is called every time an inline query is received.\n\n```lua\nonChosenInlineQueryReceive(chosenInlineQuery)\n```\n- Is called every time a chosen inline query result is received.\n\n```lua\nonUnknownTypeReceive(unknownType)\n```\n- Is called every time when an unknown type is received.\n\n### Using extension functions\n\nIn order to provide your own desired behaviour to these callback functions, you need to override them, like so, for example:\n\n```lua\nlocal bot, extension = require(\"lua-bot-api\").configure(token)\n\nextension.onTextReceive = function (message)\n\t-- Your own desired behaviour here\nend\n\nextension.run(limit, timeout)\n\n```\n\nYou can now use `extension.run()` to use the internal update handler to fetch new updates from the server and call the representive functions.\nIt lets you pass the same `limit` and `timeout` parameters as in `getUpdates()` to control the handlers behaviour without rewriting it.\n\nYou can even override `extension.run()` with your own update handler.\n\nSee bot-example.lua for some examples on how to use extension functions.\n","funding_links":[],"categories":["Lua"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldb%2Flua-telegram-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fldb%2Flua-telegram-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fldb%2Flua-telegram-bot/lists"}