A simple Lua library for the telegram-cli
.
See wiki for documentation.
luarocks install tdcli.lua
- Import
tdcli.lua
into your bot. - Call the functions.
See example script below.
-- Load tdcli library.
tdcli = require 'tdcli'
-- An alias to sendText
function sendText(chat_id, reply_to_message_id, text, disable_web_page_preview, parse_mode)
local parse_mode = parse_mode or 'HTML'
local disable_web_page_preview = disable_web_page_preview or 1
tdcli.sendText(chat_id, reply_to_message_id, 0, 1, nil, text, disable_web_page_preview, parse_mode)
end
function tdcli_update_callback(data)
if (data.ID == "UpdateNewMessage") then
local msg = data.message_
local input = msg.content_.text_
local chat_id = msg.chat_id_
local user_id = msg.sender_user_id_
-- If the message is text message
if msg.content_.ID == "MessageText" then
-- And the text is...
if input == "ping" then
-- Reply with unformatted text
sendText(chat_id, msg.id_, 'pong')
-- And if the text is...
elseif input == "PING" then
-- Reply with formatted text
sendText(user_id, 0, '*PONG*', 1, 'Markdown')
end
end
elseif (data.ID == "UpdateOption" and data.name_ == "my_id") then
tdcli_function ({
ID="GetChats",
offset_order_="9223372036854775807",
offset_chat_id_=0,
limit_=20
}, dl_cb, nil)
end
end
tdcli.lua
is a Work In Progress. This commit is based on telegram-cli-1222.tl scheme.
Here is a list of functions that's should works, and what left to be tested.
- getAuthState
- setAuthPhoneNumber
- resendAuthCode
- checkAuthCode
- checkAuthPassword
- requestAuthPasswordRecovery
- recoverAuthPassword
- resetAuth
- checkAuthBotToken
- getPasswordState
- setPassword
- getRecoveryEmail
- setRecoveryEmail
- requestPasswordRecovery
- recoverPassword
- getMe
- getUser
- getUserFull
- getGroup
- getGroupFull
- getChannel
- getChannelFull
- getSecretChat
- getChat
- getMessage
- getMessages
- getFile
- getFilePersistent
- getChats
- searchPublicChat
- searchPublicChats
- searchChats
- addRecentlyFoundChat
- deleteRecentlyFoundChat
- deleteRecentlyFoundChats
- getCommonChats
- getChatHistory
- deleteChatHistory
- searchChatMessages
- searchMessages
- sendBotStartMessage
- sendInlineQueryResultMessage
- forwardMessages
- sendChatSetTtlMessage
- deleteMessages
- deleteMessagesFromUser
- editMessageText
- editMessageCaption
- editMessageReplyMarkup
- editInlineMessageText
- editInlineMessageCaption
- editInlineMessageReplyMarkup
- getInlineQueryResults
- answerInlineQuery
- getCallbackQueryAnswer
- answerCallbackQuery
- setGameScore
- setInlineGameScore
- getGameHighScores
- getInlineGameHighScores
- deleteChatReplyMarkup
- sendChatAction
- sendChatScreenshotTakenNotification
- openChat
- closeChat
- viewMessages
- openMessageContent
- createPrivateChat
- createGroupChat
- createChannelChat
- createSecretChat
- createNewGroupChat
- createNewChannelChat
- createNewSecretChat
- migrateGroupChatToChannelChat
- changeChatTitle
- changeChatPhoto
- changeChatDraftMessage
- addChatMember
- addChatMembers
- changeChatMemberStatus
- getChatMember
- downloadFile
- cancelDownloadFile
- setFileGenerationProgress
- finishFileGeneration
- exportChatInviteLink
- checkChatInviteLink
- importChatInviteLink
- blockUser
- unblockUser
- getBlockedUsers
- importContacts
- searchContacts
- deleteContacts
- getUserProfilePhotos
- getStickers
- getStickerSets
- getArchivedStickerSets
- getTrendingStickerSets
- getAttachedStickerSets
- getStickerSet
- searchStickerSet
- updateStickerSet
- viewTrendingStickerSets
- reorderStickerSets
- getRecentStickers
- addRecentSticker
- deleteRecentSticker
- clearRecentStickers
- getStickerEmojis
- getSavedAnimations
- addSavedAnimation
- deleteSavedAnimation
- getRecentInlineBots
- getWebPagePreview
- getNotificationSettings
- setNotificationSettings
- resetAllNotificationSettings
- setProfilePhoto
- deleteProfilePhoto
- changeName
- changeAbout
- changeUsername
- changePhoneNumber
- resendChangePhoneNumberCode
- checkChangePhoneNumberCode
- getActiveSessions
- terminateSession
- terminateAllOtherSessions
- toggleGroupEditors
- changeChannelUsername
- toggleChannelInvites
- toggleChannelSignMessages
- changeChannelAbout
- pinChannelMessage
- unpinChannelMessage
- reportChannelSpam
- getChannelMembers
- deleteChannel
- getCreatedPublicChannels
- closeSecretChat
- getSupportUser
- getWallpapers
- registerDevice
- getDeviceTokens
- setPrivacy
- getPrivacy
- getOption
- setOption
- changeAccountTtl
- getAccountTtl
- deleteAccount
- getChatReportSpamState
- changeChatReportSpamState
- setBotUpdatesStatus
- setAlarm
- sendText
- sendAnimation
- sendAudio
- sendDocument
- sendPhoto
- sendSticker
- sendVideo
- sendVoice
- sendLocation
- sendVenue
- sendContact
- sendGame
- sendForwarded