/tdcli.lua

A simple Lua library for the telegram-cli

Primary LanguageLuaGNU General Public License v3.0GPL-3.0

tdcli.lua

A simple Lua library for the `telegram-cli.

How to Use

See example script below.

  • Place this tdcli.lua file inside the same folder as your bot, or anywhere else as long as you import it properly.
  • Import it into your bot.
  • Call a function.
-- Load tdcli library.
local tdcli = require('tdcli')

function dl_cb(arg, data)
end

function tdcli_update_callback(data)
  if (data.ID == "UpdateNewMessage") then
    local msg = data.message_
    -- If the message is text message
    if msg.content_.ID == "MessageText" then
      -- And the text is...
      if msg.content_.text_ == "ping" then
        -- Reply with unformatted text
        tdcli.sendMessage(msg.chat_id_, msg.id_, 1, 'pong', 1)
      -- And if the text is...
      elseif msg.content_.text_ == "PING" then
        -- Reply with formatted text
        tdcli.sendMessage(msg.chat_id_, 0, 1, '<b>PONG</b>', 1, 'html')
      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-1124.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
  • getChat
  • getMessage
  • getMessages
  • getFile
  • getFilePersistent
  • getChats
  • searchPublicChat
  • searchPublicChats
  • searchChats
  • addRecentlyFoundChat
  • deleteRecentlyFoundChat
  • deleteRecentlyFoundChats
  • getCommonChats
  • getChatHistory
  • deleteChatHistory
  • searchChatMessages
  • searchMessages
  • sendMessage
  • sendBotStartMessage
  • sendInlineQueryResultMessage
  • forwardMessages
  • deleteMessages
  • editMessageText
  • editMessageCaption
  • editMessageReplyMarkup
  • editInlineMessageText
  • editInlineMessageCaption
  • editInlineMessageReplyMarkup
  • getInlineQueryResults
  • answerInlineQuery
  • getCallbackQueryAnswer
  • answerCallbackQuery
  • setGameScore
  • setInlineGameScore
  • getGameHighScores
  • getInlineGameHighScores
  • deleteChatReplyMarkup
  • sendChatAction
  • openChat
  • closeChat
  • viewMessages
  • openMessageContent
  • createPrivateChat
  • createGroupChat
  • createChannelChat
  • createSecretChat
  • createNewGroupChat
  • createNewChannelChat
  • createNewSecretChat
  • migrateGroupChatToChannelChat
  • changeChatTitle
  • changeChatPhoto
  • changeChatDraftMessage
  • addChatMember
  • addChatMembers
  • changeChatMemberStatus
  • getChatMember
  • downloadFile
  • cancelDownloadFile
  • exportChatInviteLink
  • checkChatInviteLink
  • importChatInviteLink
  • blockUser
  • unblockUser
  • getBlockedUsers
  • importContacts
  • searchContacts
  • deleteContacts
  • getUserProfilePhotos
  • getStickers
  • getStickerSets
  • getStickerSet
  • searchStickerSet
  • updateStickerSet
  • getSavedAnimations
  • addSavedAnimation
  • deleteSavedAnimation
  • getRecentInlineBots
  • getWebPagePreview
  • getNotificationSettings
  • setNotificationSettings
  • setProfilePhoto
  • deleteProfilePhoto
  • changeName
  • changeAbout
  • changeUsername
  • changePhoneNumber
  • resendChangePhoneNumberCode
  • checkChangePhoneNumberCode
  • getActiveSessions
  • terminateSession
  • terminateAllOtherSessions
  • toggleGroupEditors
  • changeChannelUsername
  • toggleChannelInvites
  • toggleChannelSignMessages
  • changeChannelAbout
  • pinChannelMessage
  • unpinChannelMessage
  • reportChannelSpam
  • getChannelMembers
  • deleteChannel
  • getSupportUser
  • getWallpapers
  • registerDevice
  • getDeviceTokens
  • setPrivacy
  • getPrivacy
  • getOption
  • setOption
  • changeAccountTtl
  • getAccountTtl
  • deleteAccount
  • getChatReportSpamState
  • changeChatReportSpamState
  • setBotUpdatesStatus
  • setAlarm
  • add_contact
  • channel_get_admins
  • channel_get_bots
  • channel_get_kicked
  • channel_edit
  • chat_change_role
  • chat_del_user
  • chat_info
  • chat_join
  • chat_leave
  • chat_create_broadcast
  • chat_create_group
  • chat_create_supergroup
  • contact_list
  • dialog_list
  • group_upgrade
  • mark_read
  • mute
  • push_button
  • resolve_username
  • reply_file
  • reply_fwd
  • reply_location
  • send_file
  • send_location
  • start_bot
  • timer
  • unmute