tdcli.lua
tdcli.lua copied to clipboard
A simple Lua library for the telegram-cli
tdcli.lua
A simple Lua library for the telegram-cli
.
See wiki for documentation.
How to Use
-
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
The Functions
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.
- [x] getAuthState
- [ ] setAuthPhoneNumber
- [ ] resendAuthCode
- [ ] checkAuthCode
- [ ] checkAuthPassword
- [ ] requestAuthPasswordRecovery
- [ ] recoverAuthPassword
- [x] resetAuth
- [ ] checkAuthBotToken
- [x] getPasswordState
- [x] setPassword
- [x] getRecoveryEmail
- [x] setRecoveryEmail
- [x] requestPasswordRecovery
- [x] recoverPassword
- [x] getMe
- [x] getUser
- [x] getUserFull
- [x] getGroup
- [x] getGroupFull
- [x] getChannel
- [x] getChannelFull
- [ ] getSecretChat
- [x] getChat
- [x] getMessage
- [x] getMessages
- [x] getFile
- [x] getFilePersistent
- [x] getChats
- [x] searchPublicChat
- [x] searchPublicChats
- [x] searchChats
- [x] addRecentlyFoundChat
- [x] deleteRecentlyFoundChat
- [x] deleteRecentlyFoundChats
- [x] getCommonChats
- [x] getChatHistory
- [x] deleteChatHistory
- [x] searchChatMessages
- [x] searchMessages
- [x] sendBotStartMessage
- [ ] sendInlineQueryResultMessage
- [x] forwardMessages
- [ ] sendChatSetTtlMessage
- [x] deleteMessages
- [x] deleteMessagesFromUser
- [x] editMessageText
- [x] editMessageCaption
- [ ] editMessageReplyMarkup
- [ ] editInlineMessageText
- [ ] editInlineMessageCaption
- [ ] editInlineMessageReplyMarkup
- [ ] getInlineQueryResults
- [ ] answerInlineQuery
- [ ] getCallbackQueryAnswer
- [ ] answerCallbackQuery
- [ ] setGameScore
- [ ] setInlineGameScore
- [ ] getGameHighScores
- [ ] getInlineGameHighScores
- [ ] deleteChatReplyMarkup
- [x] sendChatAction
- [ ] sendChatScreenshotTakenNotification
- [x] openChat
- [x] closeChat
- [x] viewMessages
- [x] openMessageContent
- [x] createPrivateChat
- [x] createGroupChat
- [x] createChannelChat
- [ ] createSecretChat
- [x] createNewGroupChat
- [x] createNewChannelChat
- [ ] createNewSecretChat
- [x] migrateGroupChatToChannelChat
- [x] changeChatTitle
- [x] changeChatPhoto
- [x] changeChatDraftMessage
- [x] addChatMember
- [x] addChatMembers
- [x] changeChatMemberStatus
- [x] getChatMember
- [x] downloadFile
- [x] cancelDownloadFile
- [ ] setFileGenerationProgress
- [ ] finishFileGeneration
- [x] exportChatInviteLink
- [x] checkChatInviteLink
- [x] importChatInviteLink
- [x] blockUser
- [x] unblockUser
- [x] getBlockedUsers
- [x] importContacts
- [x] searchContacts
- [x] deleteContacts
- [x] getUserProfilePhotos
- [x] getStickers
- [x] getStickerSets
- [x] getArchivedStickerSets
- [x] getTrendingStickerSets
- [ ] getAttachedStickerSets
- [x] getStickerSet
- [x] searchStickerSet
- [x] updateStickerSet
- [x] viewTrendingStickerSets
- [ ] reorderStickerSets
- [x] getRecentStickers
- [x] addRecentSticker
- [x] deleteRecentSticker
- [x] clearRecentStickers
- [x] getStickerEmojis
- [x] getSavedAnimations
- [x] addSavedAnimation
- [x] deleteSavedAnimation
- [x] getRecentInlineBots
- [x] getWebPagePreview
- [x] getNotificationSettings
- [x] setNotificationSettings
- [x] resetAllNotificationSettings
- [x] setProfilePhoto
- [x] deleteProfilePhoto
- [x] changeName
- [x] changeAbout
- [x] changeUsername
- [x] changePhoneNumber
- [x] resendChangePhoneNumberCode
- [x] checkChangePhoneNumberCode
- [x] getActiveSessions
- [x] terminateSession
- [x] terminateAllOtherSessions
- [x] toggleGroupEditors
- [x] changeChannelUsername
- [x] toggleChannelInvites
- [x] toggleChannelSignMessages
- [x] changeChannelAbout
- [x] pinChannelMessage
- [x] unpinChannelMessage
- [x] reportChannelSpam
- [x] getChannelMembers
- [x] deleteChannel
- [x] getCreatedPublicChannels
- [ ] closeSecretChat
- [x] getSupportUser
- [x] getWallpapers
- [ ] registerDevice
- [x] getDeviceTokens
- [x] setPrivacy
- [x] getPrivacy
- [x] getOption
- [x] setOption
- [x] changeAccountTtl
- [x] getAccountTtl
- [x] deleteAccount
- [x] getChatReportSpamState
- [x] changeChatReportSpamState
- [ ] setBotUpdatesStatus
- [x] setAlarm
- [x] sendText
- [x] sendAnimation
- [x] sendAudio
- [x] sendDocument
- [x] sendPhoto
- [x] sendSticker
- [x] sendVideo
- [x] sendVoice
- [x] sendLocation
- [x] sendVenue
- [x] sendContact
- [x] sendGame
- [x] sendForwarded