package
0.1.6
Repository: https://github.com/alexjx/gopher-lua-libs.git
Documentation: pkg.go.dev

# README

telegram GoDoc

Usage


local http = require("http")
local telegram = require("telegram")
local inspect = require("inspect")

local client = http.client({proxy="http://192.168.184.28:3128", insecure_ssl=true})
local bot = telegram.bot("token", client)

-- getUpdates
local updates, err = bot:getUpdates()
if err then error(err) end

for _, upd in pairs(updates) do
    print(inspect(upd))
    if upd.callback_query then
        bot:sendMessage({
            chat_id = upd.callback_query.message.chat.id,
            reply_to_message_id = upd.callback_query.message.message_id,
            text = "callback query data: "..upd.callback_query.data,
        })
    else
        bot:sendMessage({
            chat_id = upd.message.chat.id,
            reply_to_message_id = upd.message.message_id,
            text = "this is a reply!",
        })
    end
end

-- sendMessage
local reply_markup_message, err = bot:sendMessage({
    chat_id = XXX,
    text = "do u like panda?",
    reply_markup={
        inline_keyboard = {
            {
                { text="ok", callback_data="1" }, { text="no", callback_data="2" }
            },
            {
                { text="good", callback_data="3" }, { text="bad", callback_data="4" }
            }
        }
    }
})
if err then error(err) end

-- sendPhoto
local msg, err = bot:sendPhoto({chat_id = XXX, caption="panda", photo="./test/panda.jpg"})
if err then error(err) end

-- deletePhoto
bot:deleteMessage({chat_id=XXX, message_id=msg.message_id})

-- editReplyMarkup
local _, err = bot:editMessageReplyMarkup({
    chat_id = reply_markup_message.chat.id,
    message_id = reply_markup_message.message_id,
    reply_markup = {
        inline_keyboard = {
            {
                { text="ok (-1)", callback_data="1" }, { text="no", callback_data="2" }
            },
            {
                { text="good (1)", callback_data="3" }, { text="bad", callback_data="4" }
            }
        }
    }
})
if err then error(err) end

# Functions

EditMessageReplyMarkup lua telegram_bot_ud:deleteMessage(table) returns (bool, err).
EditMessageCaption lua telegram_bot_ud:editMessageCaption(table) returns (bool, err).
EditMessageReplyMarkup lua telegram_bot_ud:editMessageReplyMarkup(table) returns (bool, err).
EditMessageText lua telegram_bot_ud:editMessageText(table) returns (bool, err).
ForwardMessage lua telegram_bot_ud:forward(table) returns (table, err).
GetOffset lua telegram_bot_ud:getOffset() returns int.
GetUpdates lua telegram_bot_ud:get_updates() returns (table, err).
Loader is the module loader function.
NewBot lua telegram.bot(tocken, http_ud.client) return telegram_bot_ud.
Preload adds telegram to the given Lua state's package.preload table.
SendMessage lua telegram_bot_ud:message(table) returns (table, err).
SendPhoto lua telegram_bot_ud:photo(table) returns (table, err).

# Constants

APIEndpoint is the endpoint for all API methods, with formatting for Sprintf.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
Constant values for ChatActions.
ErrAPIForbidden happens when a token is bad.
ErrBadFileType happens when you pass an unknown type.
Library errors.
FileEndpoint is the endpoint for downloading a file from Telegram.
Constant values for ParseMode in MessageConfig.
Constant values for ParseMode in MessageConfig.

# Structs

Animation is a GIF animation demonstrating the game.
AnimationConfig contains information about a SendAnimation request.
APIResponse is a response from the Telegram API with the result stored raw.
Audio contains information about audio.
AudioConfig contains information about a SendAudio request.
BaseChat is base type for all chat config types.
BaseEdit is base type of all chat edits.
BaseFile is a base type for all file config types.
CallbackConfig contains information on making a CallbackQuery response.
CallbackGame is for starting a game in an inline keyboard button.
CallbackQuery is data sent when a keyboard button with callback data is clicked.
Chat contains information about the place a message was sent.
ChatActionConfig contains information about a SendChatAction request.
ChatAnimation contains information about an animation.
ChatConfig contains information about getting information on a chat.
ChatConfigWithUser contains information about getting information on a specific user within a chat.
ChatMember is information about a member in a chat.
ChatMemberConfig contains information about a user in a chat for use with administrative functions such as kicking or unbanning a user.
ChatPhoto represents a chat photo.
ChosenInlineResult is an inline query result chosen by a User.
Contact contains information about a contact.
ContactConfig allows you to send a contact.
No description provided by the author
No description provided by the author
DeleteChatPhotoConfig contains information for delete chat photo.
DeleteMessageConfig contains information of a message in a chat to delete.
Document contains information about a document.
DocumentConfig contains information about a SendDocument request.
EditMessageCaptionConfig allows you to modify the caption of a message.
EditMessageReplyMarkupConfig allows you to modify the reply markup of a message.
EditMessageTextConfig allows you to modify the text in a message.
No description provided by the author
No description provided by the author
Error is an error containing extra information returned by the Telegram API.
File contains information about a file to download from Telegram.
FileBytes contains information about a set of bytes to upload as a File.
FileConfig has information about a file hosted on Telegram.
No description provided by the author
FileReader contains information about a reader to upload as a File.
ForceReply allows the Bot to have users directly reply to it without additional interaction.
ForwardConfig contains information about a ForwardMessage request.
Game is a game within Telegram.
GameConfig allows you to send a game.
GameHighScore is a user's score and position on the leaderboard.
GetGameHighScoresConfig allows you to fetch the high scores for a game.
GroupChat is a group chat.
No description provided by the author
InlineConfig contains information on making an InlineQuery response.
InlineKeyboardButton is a button within a custom keyboard for inline query responses.
InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
InlineQuery is a Query from Telegram for an inline request.
InlineQueryResultArticle is an inline query response article.
InlineQueryResultAudio is an inline query response audio.
InlineQueryResultDocument is an inline query response document.
InlineQueryResultGame is an inline query response game.
InlineQueryResultGIF is an inline query response GIF.
InlineQueryResultLocation is an inline query response location.
InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
InlineQueryResultPhoto is an inline query response photo.
InlineQueryResultVideo is an inline query response video.
InlineQueryResultVoice is an inline query response voice.
InputContactMessageContent contains a contact for displaying as an inline query result.
InputLocationMessageContent contains a location for displaying as an inline query result.
InputMediaPhoto contains a photo for displaying as part of a media group.
InputMediaVideo contains a video for displaying as part of a media group.
InputTextMessageContent contains text for displaying as an inline query result.
InputVenueMessageContent contains a venue for displaying as an inline query result.
Invoice contains basic information about an invoice.
InvoiceConfig contains information for sendInvoice request.
KeyboardButton is a button within a custom keyboard.
KickChatMemberConfig contains extra fields to kick user.
LabeledPrice represents a portion of the price for goods or services.
Location contains information about a place.
LocationConfig contains information about a SendLocation request.
MediaGroupConfig contains information about a sendMediaGroup request.
Message is returned by almost every request, and contains data about almost anything.
MessageConfig contains information about a SendMessage request.
MessageEntity contains information about data in a Message.
OrderInfo represents information about an order.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PassportRequestInfoConfig allows you to request passport info.
PassportScope is the requested scopes of data.
PassportScopeElementOne requires the specified element be provided.
PassportScopeElementOneOfSeveral allows you to request any one of the requested documents.
No description provided by the author
PhotoConfig contains information about a SendPhoto request.
PhotoSize contains information about photos.
PinChatMessageConfig contains information of a message in a chat to pin.
PreCheckoutConfig contains information for answerPreCheckoutQuery request.
PreCheckoutQuery contains information about an incoming pre-checkout query.
PromoteChatMemberConfig contains fields to promote members of chat.
ReplyKeyboardHide allows the Bot to hide a custom keyboard.
ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
ResponseParameters are various errors that can be returned in APIResponse.
RestrictChatMemberConfig contains fields to restrict members of chat.
No description provided by the author
SetChatDescriptionConfig contains information for change chat description.
SetChatPhotoConfig contains information for change chat photo.
SetChatTitleConfig contains information for change chat title.
SetGameScoreConfig allows you to update the game score in a chat.
ShippingAddress represents a shipping address.
ShippingConfig contains information for answerShippingQuery request.
ShippingOption represents one shipping option.
ShippingQuery contains information about an incoming shipping query.
Sticker contains information about a sticker.
StickerConfig contains information about a SendSticker request.
SuccessfulPayment contains basic information about a successful payment.
UnpinChatMessageConfig contains information of chat to unpin.
Update is an update response, from GetUpdates.
UpdateConfig contains information about a GetUpdates request.
User is a user on Telegram.
UserProfilePhotos contains a set of user profile photos.
UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
Venue contains information about a venue, including its Location.
VenueConfig contains information about a SendVenue request.
Video contains information about a video.
VideoConfig contains information about a SendVideo request.
VideoNote contains information about a video.
VideoNoteConfig contains information about a SendVideoNote request.
Voice contains information about a voice.
VoiceConfig contains information about a SendVoice request.
WebhookConfig contains information about a SetWebhook request.
WebhookInfo is information about a currently set webhook.

# Interfaces

Chattable is any config type that can be sent.
Fileable is any config type that can be sent that includes a file.
No description provided by the author
PassportScopeElement supports using one or one of several elements.

# Type aliases

No description provided by the author