Skip to content

TRIGONIM/ggram

Repository files navigation

ggram – Lua Telegram Bot Framework

Create Telegram bots of any complexity in Lua

local ggram = require("ggram")
local bot = ggram("token")

require("ggram.polling").start(bot) -- enables getUpdates loop

bot.command("start", function(ctx)
	ctx.reply.text("Hello @" .. ctx.from.username)
end)

Additional examples can be found in /examples


✨ Features

  • Can work both on pure Lua, and on the Garry's Mod server
  • Does NOT require any third-party .dll or WEB scripts
  • Very minimalistic and easily expandable
  • If Telegram adds methods that are not already in the bot, they are very easy to add with a 3-line module
  • Possibility for sending animations, documents, images

🛠️ Installation

Docker

Download this repository and go to the downloaded folder. You can take a look at the contents of the Dockerfile. It does not contain ggram itself. It installs the dependencies to make it work.

# create image. You can choose any Dockerfile from this repo
docker build -t ggramenv:latest -f Dockerfile_tarantool .

# run example bot (echo.lua)
# dont forget to change bot token in the file
docker run -it \
	-e "LUA_PATH=/app/lua/?.lua;/app/lua/?/init.lua;;" \
	-v $PWD:/app ggramenv \
	lua app/examples/echo.lua

# 🎉

Linux / Mac

Install luarocks (package manager like apt but for lua)

sudo apt install luarocks # linux
# or
brew install luarocks # mac

Install ggram

luarocks install ggram

🚀 Creating and launching a bot

  1. Create bot.lua file. You can choose any name for the file.
  2. Paste the contents of /examples/echo.lua into the file.
  3. Run file with lua bot.lua. If you want to run a bot on a Garry's Mod server, then read this.
  4. Check out other examples in the /examples folder.

If any error was occur, check the troubleshooting guide

📚 Docs

All the docs are collected here and useful info here