A simple LUA Framework for the Telegram Bot API
- Added
disable_notification
argument to all sending methods to enable silent messages - Added
caption
argument tosendDocument()
- Initial release v0.1-alpha
To install this module, place it inside the same folder your bot is located.
This modules requires luasec to work.
You can easily install it with luarocks using luarocks install luasec
.
You will also need a Module for JSON en- and decoding, which can be found here.
Simply place it in the lua-telegram-bot
Folder.
To use this module, import it into your bot like this:
local bot = (require "lua-bot-api").configure(token)
Include your bot token as parameter for configure()
.
At the moment, only getUpdates method (aka polling) is supported, no webhooks.
The bot
Table exports variables and functions which return the following return values:
All functions return a table as received from the server if called successfully as their first return value.
This does not mean the request was successful, for example in case of a bad offset
in getUpdates()
.
A function returns nil
and an error description
if it was wrongly called (missing parameters).
id
username
first_name
getMe()
getUpdates([offset] [,limit] [,timeout])
sendMessage(chat_id, text [,parse_mode] [,disable_web_page_preview] [,disable_notification] [,reply_to_message_id] [,reply_markup])
forwardMessage(chat_id, from_chat_id [,disable_notification], message_id)
sendPhoto(chat_id, photo [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendAudio(chat_id, audio, duration [,performer] [,title] [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendDocument(chat_id, document [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendSticker(chat_id, sticker [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendVideo(chat_id, video [,duration] [,caption] [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendVoice(chat_id, voice [,duration] [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendLocation(chat_id, latitude, longitude [,disable_notification] [,reply_to_message_id] [,reply_markup])
sendChatAction(chat_id, action)
getUserProfilePhotos(user_id [,offset] [,limit])
getFile(file_id)
answerInlineQuery(inline_query_id, results [,cache_time] [,is_personal] [,next_offset])
downloadFile(file_id [,download_path])
- Downloads file from Telegram Servers.
download_path
is an optional path where the file can be saved. If not specified, it will be saved in/downloads/<filenameByTelegram>
. In both cases make sure the path already exists, since LUA can not create folders without additional modules.
generateReplyKeyboardMarkup(keyboard [,resize_keyboard] [,one_time_keyboard] [,selective])
- Generates a
ReplyKeyboardMarkup
of typereply_markup
which can be sent optionally in other functions such assendMessage()
. - Displays the custom
keyboard
on the receivers device.
generateReplyKeyboardHide([hide_keyboard] [,selective])
- Generates a
ReplyKeyboardHide
of typereply_markup
which can be sent optionally in other functions such assendMessage()
. - Forces to hide the custom
keyboard
on the receivers device. hide_keyboard
can be left out, as it is alwaystrue
.
generateForceReply([force_reply] [,selective])
- Generates a
ForceReply
of typereply_markup
which can be sent optionally in other functions such assendMessage()
. - Forces to reply to the corresponding message from the receivers device.
force_reply
can be left out, as it is alwaystrue
.