From 5f17956e12dd92879557257b0ea9d36c1946b026 Mon Sep 17 00:00:00 2001 From: Matt Hesketh Date: Mon, 16 Feb 2026 23:46:25 +0000 Subject: [PATCH 1/2] chore: fix rockspec source URLs to use HTTPS tarball GitHub deprecated the git:// protocol. Use archive tarball URLs instead. --- telegram-bot-lua-3.0-0.rockspec | 5 ++--- telegram-bot-lua-3.1-0.rockspec | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/telegram-bot-lua-3.0-0.rockspec b/telegram-bot-lua-3.0-0.rockspec index e18f2bf..30158c3 100644 --- a/telegram-bot-lua-3.0-0.rockspec +++ b/telegram-bot-lua-3.0-0.rockspec @@ -1,9 +1,8 @@ package = "telegram-bot-lua" version = "3.0-0" source = { - url = "git://github.com/wrxck/telegram-bot-lua.git", - dir = "telegram-bot-lua", - tag = "v3.0" + url = "https://github.com/wrxck/telegram-bot-lua/archive/refs/tags/v3.0.tar.gz", + dir = "telegram-bot-lua-3.0" } description = { summary = "A feature-filled Telegram bot API library", diff --git a/telegram-bot-lua-3.1-0.rockspec b/telegram-bot-lua-3.1-0.rockspec index 3ed7721..5c58ef1 100644 --- a/telegram-bot-lua-3.1-0.rockspec +++ b/telegram-bot-lua-3.1-0.rockspec @@ -1,9 +1,8 @@ package = "telegram-bot-lua" version = "3.1-0" source = { - url = "git://github.com/wrxck/telegram-bot-lua.git", - dir = "telegram-bot-lua", - tag = "v3.1" + url = "https://github.com/wrxck/telegram-bot-lua/archive/refs/tags/v3.1.tar.gz", + dir = "telegram-bot-lua-3.1" } description = { summary = "A feature-filled Telegram bot API library", From 424db530116754adcb43427c800bd78c8bbc6841 Mon Sep 17 00:00:00 2001 From: Matt Hesketh Date: Fri, 20 Feb 2026 23:45:21 +0000 Subject: [PATCH 2/2] fix(module): rename init.lua to main.lua for LuaRocks compatibility LuaRocks builtin type installs init.lua as a directory module (telegram-bot-lua/init.lua) instead of a flat file (telegram-bot-lua.lua). This breaks require("telegram-bot-lua") on Lua 5.1 environments where ?/init.lua is not in the default package.path. Renaming to main.lua forces LuaRocks to install as a flat file, which resolves via the universal ?.lua pattern on all Lua versions. Closes #35 --- spec/module_spec.lua | 149 ++++++++++++++++++++++++++++++++ spec/test_helper.lua | 2 +- src/{init.lua => main.lua} | 4 +- telegram-bot-lua-3.2-0.rockspec | 65 ++++++++++++++ 4 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 spec/module_spec.lua rename src/{init.lua => main.lua} (99%) create mode 100644 telegram-bot-lua-3.2-0.rockspec diff --git a/spec/module_spec.lua b/spec/module_spec.lua new file mode 100644 index 0000000..8c1842e --- /dev/null +++ b/spec/module_spec.lua @@ -0,0 +1,149 @@ +local api = require('spec.test_helper') + +describe('module structure', function() + describe('require("telegram-bot-lua")', function() + it('returns a table', function() + assert.is_table(api) + end) + + it('has a version string', function() + assert.is_string(api.version) + assert.truthy(api.version:match('%d+%.%d+%-%d+')) + end) + + it('has configure function', function() + assert.is_function(api.configure) + end) + + it('has request function', function() + assert.is_function(api.request) + end) + + it('has get_me function', function() + assert.is_function(api.get_me) + end) + end) + + describe('require("telegram-bot-lua.core") deprecated shim', function() + it('returns the same api table as the main module', function() + local core = require('telegram-bot-lua.core') + assert.are.equal(api, core) + end) + + it('is cached in package.loaded', function() + assert.is_not_nil(package.loaded['telegram-bot-lua.core']) + end) + end) + + describe('rockspec module map', function() + local rockspec_modules = { + ['telegram-bot-lua'] = 'src/main.lua', + ['telegram-bot-lua.config'] = 'src/config.lua', + ['telegram-bot-lua.handlers'] = 'src/handlers.lua', + ['telegram-bot-lua.builders'] = 'src/builders.lua', + ['telegram-bot-lua.helpers'] = 'src/helpers.lua', + ['telegram-bot-lua.tools'] = 'src/tools.lua', + ['telegram-bot-lua.utils'] = 'src/utils.lua', + ['telegram-bot-lua.compat'] = 'src/compat.lua', + ['telegram-bot-lua.core'] = 'src/core.lua', + ['telegram-bot-lua.polyfill'] = 'src/polyfill.lua', + ['telegram-bot-lua.async'] = 'src/async.lua', + ['telegram-bot-lua.b64url'] = 'src/b64url.lua', + ['telegram-bot-lua.methods.updates'] = 'src/methods/updates.lua', + ['telegram-bot-lua.methods.messages'] = 'src/methods/messages.lua', + ['telegram-bot-lua.methods.chat'] = 'src/methods/chat.lua', + ['telegram-bot-lua.methods.members'] = 'src/methods/members.lua', + ['telegram-bot-lua.methods.forum'] = 'src/methods/forum.lua', + ['telegram-bot-lua.methods.stickers'] = 'src/methods/stickers.lua', + ['telegram-bot-lua.methods.inline'] = 'src/methods/inline.lua', + ['telegram-bot-lua.methods.payments'] = 'src/methods/payments.lua', + ['telegram-bot-lua.methods.games'] = 'src/methods/games.lua', + ['telegram-bot-lua.methods.passport'] = 'src/methods/passport.lua', + ['telegram-bot-lua.methods.bot'] = 'src/methods/bot.lua', + ['telegram-bot-lua.methods.gifts'] = 'src/methods/gifts.lua', + ['telegram-bot-lua.methods.checklists'] = 'src/methods/checklists.lua', + ['telegram-bot-lua.methods.stories'] = 'src/methods/stories.lua', + ['telegram-bot-lua.methods.suggested_posts'] = 'src/methods/suggested_posts.lua', + ['telegram-bot-lua.adapters'] = 'src/adapters/init.lua', + ['telegram-bot-lua.adapters.db'] = 'src/adapters/db.lua', + ['telegram-bot-lua.adapters.redis'] = 'src/adapters/redis.lua', + ['telegram-bot-lua.adapters.llm'] = 'src/adapters/llm.lua', + ['telegram-bot-lua.adapters.email'] = 'src/adapters/email.lua', + } + + for mod_name, file_path in pairs(rockspec_modules) do + it('source file exists for ' .. mod_name, function() + local f = io.open(file_path, 'r') + assert.is_not_nil(f, 'missing file: ' .. file_path) + if f then f:close() end + end) + end + + for mod_name, _ in pairs(rockspec_modules) do + it('can require ' .. mod_name, function() + assert.is_not_nil(package.loaded[mod_name] or package.preload[mod_name], + 'module not loadable: ' .. mod_name) + end) + end + end) + + describe('main module entry point', function() + it('is NOT named init.lua (avoids LuaRocks init.lua directory install)', function() + local f = io.open('src/init.lua', 'r') + assert.is_nil(f, 'src/init.lua should not exist; use src/main.lua so LuaRocks installs as flat file') + if f then f:close() end + end) + + it('main.lua exists as the entry point', function() + local f = io.open('src/main.lua', 'r') + assert.is_not_nil(f, 'src/main.lua must exist as the main entry point') + if f then f:close() end + end) + end) + + describe('all submodules loaded into api', function() + it('has handler methods (on_message etc)', function() + assert.is_not_nil(api.on_message) + end) + + it('has builder methods', function() + assert.is_function(api.inline_result) + end) + + it('has message methods (send_message etc)', function() + assert.is_function(api.send_message) + end) + + it('has chat methods', function() + assert.is_function(api.get_chat) + end) + + it('has member methods', function() + assert.is_function(api.get_chat_member) + end) + + it('has sticker methods', function() + assert.is_function(api.send_sticker) + end) + + it('has inline methods', function() + assert.is_function(api.answer_inline_query) + end) + + it('has payment methods', function() + assert.is_function(api.send_invoice) + end) + + it('has game methods', function() + assert.is_function(api.send_game) + end) + + it('has bot methods', function() + assert.is_function(api.set_my_commands) + end) + + it('has utility methods', function() + assert.is_function(api.input_text_message_content) + end) + end) +end) diff --git a/spec/test_helper.lua b/spec/test_helper.lua index aa691b1..484749a 100644 --- a/spec/test_helper.lua +++ b/spec/test_helper.lua @@ -6,7 +6,7 @@ package.path = './src/?.lua;./src/?/init.lua;' .. package.path -- Pre-register our module names to match rockspec mappings local module_map = { - ['telegram-bot-lua'] = 'src/init.lua', + ['telegram-bot-lua'] = 'src/main.lua', ['telegram-bot-lua.config'] = 'src/config.lua', ['telegram-bot-lua.handlers'] = 'src/handlers.lua', ['telegram-bot-lua.builders'] = 'src/builders.lua', diff --git a/src/init.lua b/src/main.lua similarity index 99% rename from src/init.lua rename to src/main.lua index 4af71b6..521e604 100644 --- a/src/init.lua +++ b/src/main.lua @@ -9,7 +9,7 @@ __/ | |___/ - Version 3.0-0 + Version 3.2-0 Copyright (c) 2017-2026 Matthew Hesketh See LICENSE for details @@ -20,7 +20,7 @@ local ltn12 = require('ltn12') local json = require('dkjson') local config = require('telegram-bot-lua.config') -api.version = '3.1-0' +api.version = '3.2-0' function api.configure(token, debug) if not token or type(token) ~= 'string' then diff --git a/telegram-bot-lua-3.2-0.rockspec b/telegram-bot-lua-3.2-0.rockspec new file mode 100644 index 0000000..7fd6202 --- /dev/null +++ b/telegram-bot-lua-3.2-0.rockspec @@ -0,0 +1,65 @@ +package = "telegram-bot-lua" +version = "3.2-0" +source = { + url = "https://github.com/wrxck/telegram-bot-lua/archive/refs/tags/v3.2.tar.gz", + dir = "telegram-bot-lua-3.2" +} +description = { + summary = "A feature-filled Telegram bot API library", + detailed = "A feature-filled Telegram bot API library written in Lua, with Bot API 9.4 support.", + homepage = "https://github.com/wrxck/telegram-bot-lua", + maintainer = "Matthew Hesketh ", + license = "GPL-3" +} +supported_platforms = { + "linux", + "macosx", + "unix", + "bsd" +} +dependencies = { + "lua >= 5.1", + "dkjson >= 2.5-2", + "luasec >= 0.6-1", + "luasocket >= 3.0rc1-2", + "multipart-post >= 1.1-1", + "luautf8 >= 0.1.1-1", + "copas >= 4.0" +} +build = { + type = "builtin", + modules = { + ["telegram-bot-lua"] = "src/main.lua", + ["telegram-bot-lua.config"] = "src/config.lua", + ["telegram-bot-lua.handlers"] = "src/handlers.lua", + ["telegram-bot-lua.builders"] = "src/builders.lua", + ["telegram-bot-lua.helpers"] = "src/helpers.lua", + ["telegram-bot-lua.tools"] = "src/tools.lua", + ["telegram-bot-lua.utils"] = "src/utils.lua", + ["telegram-bot-lua.compat"] = "src/compat.lua", + ["telegram-bot-lua.core"] = "src/core.lua", + ["telegram-bot-lua.polyfill"] = "src/polyfill.lua", + ["telegram-bot-lua.async"] = "src/async.lua", + ["telegram-bot-lua.b64url"] = "src/b64url.lua", + ["telegram-bot-lua.methods.updates"] = "src/methods/updates.lua", + ["telegram-bot-lua.methods.messages"] = "src/methods/messages.lua", + ["telegram-bot-lua.methods.chat"] = "src/methods/chat.lua", + ["telegram-bot-lua.methods.members"] = "src/methods/members.lua", + ["telegram-bot-lua.methods.forum"] = "src/methods/forum.lua", + ["telegram-bot-lua.methods.stickers"] = "src/methods/stickers.lua", + ["telegram-bot-lua.methods.inline"] = "src/methods/inline.lua", + ["telegram-bot-lua.methods.payments"] = "src/methods/payments.lua", + ["telegram-bot-lua.methods.games"] = "src/methods/games.lua", + ["telegram-bot-lua.methods.passport"] = "src/methods/passport.lua", + ["telegram-bot-lua.methods.bot"] = "src/methods/bot.lua", + ["telegram-bot-lua.methods.gifts"] = "src/methods/gifts.lua", + ["telegram-bot-lua.methods.checklists"] = "src/methods/checklists.lua", + ["telegram-bot-lua.methods.stories"] = "src/methods/stories.lua", + ["telegram-bot-lua.methods.suggested_posts"] = "src/methods/suggested_posts.lua", + ["telegram-bot-lua.adapters"] = "src/adapters/init.lua", + ["telegram-bot-lua.adapters.db"] = "src/adapters/db.lua", + ["telegram-bot-lua.adapters.redis"] = "src/adapters/redis.lua", + ["telegram-bot-lua.adapters.llm"] = "src/adapters/llm.lua", + ["telegram-bot-lua.adapters.email"] = "src/adapters/email.lua" + } +}