开源软件名称(OpenSource Name):ldb/lua-telegram-bot开源软件地址(OpenSource Url):https://github.com/ldb/lua-telegram-bot开源编程语言(OpenSource Language):Lua 100.0%开源软件介绍(OpenSource Introduction):lua-telegram-botA simple LUA Library for the Telegram Bot API ImportantThis library is not under active development anymore. ChangelogMay 26 2016 - v2.1beta
Apr 20 2016 - v2.1alpha
Mar 27 2016 - v2.0
Feb 28 2016 - v1.1
Jan 22 2016 - v1.0
InstallingTo 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 You will also need a Module for JSON en- and decoding, which can be found here.
Simply place it in the UsingTo use this module, import it into your bot like this: local bot, extension = (require "lua-bot-api").configure(token) Include your bot token as parameter for At the moment, only getUpdates method (aka polling) is supported, no webhooks. The Return valuesAll 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 A function returns Available Variablesid username first_name Available FunctionsgetMe() 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) Inline Mode functionsanswerInlineQuery(inline_query_id, results [,cache_time] [,is_personal] [,next_offset]) answerCallbackQuery(callback_query_id, text [, show_alert]) Bot API 2.0 functionskickChatMember(chat_id, user_id) unbanChatMember(chat_id, user_id) editMessageText(chat_id, message_id, inline_message_id, text [, parse_mode] [, disable_web_page_preview] [, reply_markup]) editMessageCaption(chat_id, message_id, inline_message_id, caption [, reply_markup]) editMessageReplyMarkup(chat_id, message_id, inline_message_id [, reply_markup]) Bot API 2.1 functionsgetChat(chat_id) leaveChat(chat_id) getChatAdministrators(chat_id) getChatMembersCount(chat_id) getChatMember(chat_id, user_id) Helper functions:downloadFile(file_id [,download_path])
generateReplyKeyboardMarkup(keyboard [,resize_keyboard] [,one_time_keyboard] [,selective])
generateReplyKeyboardHide([hide_keyboard] [,selective])
generateForceReply([force_reply] [,selective])
Library ExtensionThe Library extension was added to help developers focus on the things that actually matter in a bot: It's logic. It offers serveral callback functions which can be overridden to provide the wanted logic. Available FunctionsTo use the extension, simply add another table variable to the initial local bot, extension = require("lua-bot-api").configure(token) The run()
onUpdateReceive(update)
onTextReceive(message)
onPhotoReceive(message)
onAudioReceive(message)
onDocumentReceive(message)
onStickerReceive(message)
onVideoReceive(message)
onVoiceReceive(message)
onContactReceive(message)
onLocationReceive(message)
onLeftChatParticipant(message)
onNewChatParticipant(message)
onNewChatTitle(message)
onNewChatPhoto(message)
onDeleteChatPhoto(message)
onGroupChatCreated(message)
onSupergroupChatCreated(message) onChannelChatCreated(message) onMigrateToChatId(message)
onMigrateFromChatId(message) onInlineQueryReceive(inlineQuery)
onChosenInlineQueryReceive(chosenInlineQuery)
onUnknownTypeReceive(unknownType)
Using extension functionsIn order to provide your own desired behaviour to these callback functions, you need to override them, like so, for example: local bot, extension = require("lua-bot-api").configure(token)
extension.onTextReceive = function (message)
-- Your own desired behaviour here
end
extension.run(limit, timeout)
You can now use You can even override See bot-example.lua for some examples on how to use extension functions. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论