feat: middleware, MCP server, and CLI tool for v3.4#41
Merged
Conversation
Middleware: api.use(fn) for global middleware, api.middleware.on_message.use(fn) for scoped middleware. Onion model with (ctx, next) signature. Zero overhead when no middleware registered. MCP: JSON-RPC 2.0 server over stdio with 23 curated Telegram Bot API tools (send_message, ban_chat_member, etc.) and telegram://bot/info resource. Compatible with Claude Code, Cursor, and other MCP clients. CLI: bin/tgbot with subcommands (send, info, updates, chat, ban, unban, mcp, run). Reads BOT_TOKEN from env. Includes 45 new tests and v3.4-0 rockspec.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
api.use(fn)for global middleware,api.middleware.on_message.use(fn)for scoped. Onion model with(ctx, next). Zero overhead when none registered.telegram://bot/inforesource. Works with Claude Code, Cursor, and other MCP clients.bin/tgbotwith subcommands:send,info,updates,chat,ban,unban,mcp,run. ReadsBOT_TOKENfrom env. Installed via LuaRocks.New files
src/middleware.luasrc/mcp.luabin/tgbotspec/middleware_spec.luaspec/mcp_spec.luaspec/cli_spec.luatelegram-bot-lua-3.4-0.rockspecModified files
src/main.lua— version bump, loads middleware + mcp modulessrc/handlers.lua— refactoredprocess_update()to route through middleware chainspec/test_helper.lua— added module mappings for middleware + mcpTest plan