Module: TD::ClientMethods

Included in:
Client
Defined in:
lib/tdlib/client_methods.rb

Overview

This is a generated module from current TDLib scheme It contains all available TDLib methods

Instance Method Summary collapse

Instance Method Details

#accept_call(call_id, protocol) ⇒ TD::Types::Ok

Accepts an incoming call.

Parameters:

  • call_id (Integer)

    Call identifier.

  • protocol (TD::Types::CallProtocol)

    Description of the call protocols supported by the client.

Returns:



9
10
11
12
13
# File 'lib/tdlib/client_methods.rb', line 9

def accept_call(call_id, protocol)
  broadcast('@type'    => 'acceptCall',
            'call_id'  => call_id,
            'protocol' => protocol)
end

#accept_terms_of_service(terms_of_service_id) ⇒ TD::Types::Ok

Accepts Telegram terms of services.

Parameters:

  • terms_of_service_id (String)

    Terms of service identifier.

Returns:



19
20
21
22
# File 'lib/tdlib/client_methods.rb', line 19

def accept_terms_of_service(terms_of_service_id)
  broadcast('@type'               => 'acceptTermsOfService',
            'terms_of_service_id' => terms_of_service_id)
end

#add_chat_member(chat_id, user_id, forward_limit: 300) ⇒ TD::Types::Ok

Adds a new member to a chat. Members can't be added to private or secret chats. Members will not be added until the chat state has been synchronized with the server.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • user_id (Integer)

    Identifier of the user.

  • forward_limit (Integer) (defaults to: 300)

    The number of earlier messages from the chat to be forwarded to the new member; up to 300. Ignored for supergroups and channels.

Returns:



34
35
36
37
38
39
# File 'lib/tdlib/client_methods.rb', line 34

def add_chat_member(chat_id, user_id, forward_limit: 300)
  broadcast('@type'         => 'addChatMember',
            'chat_id'       => chat_id,
            'user_id'       => user_id,
            'forward_limit' => forward_limit)
end

#add_chat_members(chat_id, user_ids) ⇒ TD::Types::Ok

Adds multiple new members to a chat. Currently this option is only available for supergroups and channels. This option can't be used to join a chat. Members can't be added to a channel if it has more than 200 members. Members will not be added until the chat state has been synchronized with the server.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • user_ids (Array<Integer>)

    Identifiers of the users to be added to the chat.

Returns:



50
51
52
53
54
# File 'lib/tdlib/client_methods.rb', line 50

def add_chat_members(chat_id, user_ids)
  broadcast('@type'    => 'addChatMembers',
            'chat_id'  => chat_id,
            'user_ids' => user_ids)
end

#add_favorite_sticker(sticker) ⇒ TD::Types::Ok

Adds a new sticker to the list of favorite stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set can be added to this list.

Parameters:

Returns:



63
64
65
66
# File 'lib/tdlib/client_methods.rb', line 63

def add_favorite_sticker(sticker)
  broadcast('@type'   => 'addFavoriteSticker',
            'sticker' => sticker)
end

#add_local_message(chat_id, input_message_content, sender_user_id: 0, reply_to_message_id: 0, disable_notification: false) ⇒ TD::Types::Message

Adds a local message to a chat. The message is persistent across application restarts only if the message database is used.

Parameters:

  • chat_id (Integer)

    Target chat.

  • sender_user_id (Integer) (defaults to: 0)

    Identifier of the user who will be shown as the sender of the message; may be 0 for channel posts.

  • reply_to_message_id (Integer) (defaults to: 0)

    Identifier of the message to reply to or 0.

  • disable_notification (Boolean) (defaults to: false)

    Pass true to disable notification for the message.

  • input_message_content (TD::Types::InputMessageContent)

    The content of the message to be added.

Returns:



78
79
80
81
82
83
84
85
86
# File 'lib/tdlib/client_methods.rb', line 78

def add_local_message(chat_id, input_message_content,
                      sender_user_id: 0, reply_to_message_id: 0, disable_notification: false)
  broadcast('@type'                 => 'addLocalMessage',
            'chat_id'               => chat_id,
            'sender_user_id'        => sender_user_id,
            'reply_to_message_id'   => reply_to_message_id,
            'disable_notification'  => disable_notification,
            'input_message_content' => input_message_content)
end

#add_network_statistics(entry) ⇒ TD::Types::Ok

Adds the specified data to data usage statistics. Can be called before authorization.

Parameters:

Returns:



94
95
96
97
# File 'lib/tdlib/client_methods.rb', line 94

def add_network_statistics(entry)
  broadcast('@type' => 'addNetworkStatistics',
            'entry' => entry)
end

#add_proxy(server, port, type, enable = false) ⇒ TD::Types::Proxy

Adds a proxy server for network requests. Can be called before authorization.

Parameters:

  • server (String)

    Proxy server IP address.

  • port (Integer)

    Proxy server port.

  • enable (Boolean) (defaults to: false)

    True, if the proxy should be enabled.

  • type (TD::Types::ProxyType)

    Proxy type.

Returns:



107
108
109
110
111
112
113
# File 'lib/tdlib/client_methods.rb', line 107

def add_proxy(server, port, type, enable = false)
  broadcast('@type'  => 'addProxy',
            'server' => server,
            'port'   => port,
            'enable' => enable,
            'type'   => type)
end

#add_recent_sticker(sticker, is_attached: false) ⇒ TD::Types::Stickers

Manually adds a new sticker to the list of recently used stickers. The new sticker is added to the top of the list. If the sticker was already in the list, it is removed from the list first. Only stickers belonging to a sticker set can be added to this list.

Parameters:

  • is_attached (Boolean) (defaults to: false)

    Pass true to add the sticker to the list of stickers recently attached to photo or video files; pass false to add the sticker to the list of recently sent stickers.

  • sticker (TD::Types::InputFile)

    Sticker file to add.

Returns:



124
125
126
127
128
# File 'lib/tdlib/client_methods.rb', line 124

def add_recent_sticker(sticker, is_attached: false)
  broadcast('@type'       => 'addRecentSticker',
            'is_attached' => is_attached,
            'sticker'     => sticker)
end

#add_recently_found_chat(chat_id) ⇒ TD::Types::Ok

Adds a chat to the list of recently found chats. The chat is added to the beginning of the list. If the chat is already in the list, it will be removed from the list first.

Parameters:

  • chat_id (Integer)

    Identifier of the chat to add.

Returns:



136
137
138
139
# File 'lib/tdlib/client_methods.rb', line 136

def add_recently_found_chat(chat_id)
  broadcast('@type'   => 'addRecentlyFoundChat',
            'chat_id' => chat_id)
end

#add_saved_animation(animation) ⇒ TD::Types::Ok

Manually adds a new animation to the list of saved animations. The new animation is added to the beginning of the list. If the animation was already in the list, it is removed first. Only non-secret video animations with MIME type "video/mp4" can be added to the list.

Parameters:

  • animation (TD::Types::InputFile)

    The animation file to be added. Only animations known to the server (i.e. successfully sent via a message) can be added to the list.

Returns:



149
150
151
152
# File 'lib/tdlib/client_methods.rb', line 149

def add_saved_animation(animation)
  broadcast('@type'     => 'addSavedAnimation',
            'animation' => animation)
end

#add_sticker_to_set(user_id, name, sticker) ⇒ TD::Types::StickerSet

Adds a new sticker to a set; for bots only.

Parameters:

  • user_id (Integer)

    Sticker set owner.

  • name (String)

    Sticker set name.

  • sticker (TD::Types::InputSticker)

    Sticker to add to the set.

Returns:



160
161
162
163
164
165
# File 'lib/tdlib/client_methods.rb', line 160

def add_sticker_to_set(user_id, name, sticker)
  broadcast('@type'   => 'addStickerToSet',
            'user_id' => user_id,
            'name'    => name,
            'sticker' => sticker)
end

#answer_callback_query(callback_query_id, text, show_alert, url, cache_time) ⇒ TD::Types::Ok

Sets the result of a callback query; for bots only.

Parameters:

  • callback_query_id (Integer)

    Identifier of the callback query.

  • text (String)

    Text of the answer.

  • show_alert (Boolean)

    If true, an alert should be shown to the user instead of a toast notification.

  • url (String)

    URL to be opened.

  • cache_time (Integer)

    Time during which the result of the query can be cached, in seconds.

Returns:



175
176
177
178
179
180
181
182
# File 'lib/tdlib/client_methods.rb', line 175

def answer_callback_query(callback_query_id, text, show_alert, url, cache_time)
  broadcast('@type'             => 'answerCallbackQuery',
            'callback_query_id' => callback_query_id,
            'text'              => text,
            'show_alert'        => show_alert,
            'url'               => url,
            'cache_time'        => cache_time)
end

#answer_custom_query(custom_query_id, data) ⇒ TD::Types::Ok

Answers a custom query; for bots only.

Parameters:

  • custom_query_id (Integer)

    Identifier of a custom query.

  • data (String)

    JSON-serialized answer to the query.

Returns:



189
190
191
192
193
# File 'lib/tdlib/client_methods.rb', line 189

def answer_custom_query(custom_query_id, data)
  broadcast('@type'           => 'answerCustomQuery',
            'custom_query_id' => custom_query_id,
            'data'            => data)
end

#answer_inline_query(inline_query_id, is_personal, results, cache_time, next_offset, switch_pm_text, switch_pm_parameter) ⇒ TD::Types::Ok

Sets the result of an inline query; for bots only.

Parameters:

  • inline_query_id (Integer)

    Identifier of the inline query.

  • is_personal (Boolean)

    True, if the result of the query can be cached for the specified user.

  • results (Array<TD::Types::InputInlineQueryResult>)

    The results of the query.

  • cache_time (Integer)

    Allowed time to cache the results of the query, in seconds.

  • next_offset (String)

    Offset for the next inline query; pass an empty string if there are no more results.

  • switch_pm_text (String)

    If non-empty, this text should be shown on the button that opens a private chat with the bot and sends a start message to the bot with the parameter switch_pm_parameter.

  • switch_pm_parameter (String)

    The parameter for the bot start message.

Returns:



206
207
208
209
210
211
212
213
214
215
216
# File 'lib/tdlib/client_methods.rb', line 206

def answer_inline_query(inline_query_id, is_personal, results, cache_time, next_offset, switch_pm_text,
                        switch_pm_parameter)
  broadcast('@type'               => 'answerInlineQuery',
            'inline_query_id'     => inline_query_id,
            'is_personal'         => is_personal,
            'results'             => results,
            'cache_time'          => cache_time,
            'next_offset'         => next_offset,
            'switch_pm_text'      => switch_pm_text,
            'switch_pm_parameter' => switch_pm_parameter)
end

#answer_pre_checkout_query(pre_checkout_query_id, error_message: nil) ⇒ TD::Types::Ok

Sets the result of a pre-checkout query; for bots only.

Parameters:

  • pre_checkout_query_id (Integer)

    Identifier of the pre-checkout query.

  • error_message (String, nil) (defaults to: nil)

    An error message, empty on success.

Returns:



223
224
225
226
227
# File 'lib/tdlib/client_methods.rb', line 223

def answer_pre_checkout_query(pre_checkout_query_id, error_message: nil)
  broadcast('@type'                 => 'answerPreCheckoutQuery',
            'pre_checkout_query_id' => pre_checkout_query_id,
            'error_message'         => error_message)
end

#answer_shipping_query(shipping_query_id, shipping_options, error_message: nil) ⇒ TD::Types::Ok

Sets the result of a shipping query; for bots only.

Parameters:

  • shipping_query_id (Integer)

    Identifier of the shipping query.

  • shipping_options (Array<TD::Types::ShippingOption>)

    Available shipping options.

  • error_message (String, nil) (defaults to: nil)

    An error message, empty on success.

Returns:



235
236
237
238
239
240
# File 'lib/tdlib/client_methods.rb', line 235

def answer_shipping_query(shipping_query_id, shipping_options, error_message: nil)
  broadcast('@type'             => 'answerShippingQuery',
            'shipping_query_id' => shipping_query_id,
            'shipping_options'  => shipping_options,
            'error_message'     => error_message)
end

#block_user(user_id) ⇒ TD::Types::Ok

Adds a user to the blacklist.

Parameters:

  • user_id (Integer)

    User identifier.

Returns:



246
247
248
249
# File 'lib/tdlib/client_methods.rb', line 246

def block_user(user_id)
  broadcast('@type'   => 'blockUser',
            'user_id' => user_id)
end

#cancel_download_file(file_id, only_if_pending: false) ⇒ TD::Types::Ok

Stops the downloading of a file. If a file has already been downloaded, does nothing.

Parameters:

  • file_id (Integer)

    Identifier of a file to stop downloading.

  • only_if_pending (Boolean) (defaults to: false)

    Pass true to stop downloading only if it hasn't been started, i.e. request hasn't been sent to server.

Returns:



258
259
260
261
262
# File 'lib/tdlib/client_methods.rb', line 258

def cancel_download_file(file_id, only_if_pending: false)
  broadcast('@type'           => 'cancelDownloadFile',
            'file_id'         => file_id,
            'only_if_pending' => only_if_pending)
end

#cancel_upload_file(file_id) ⇒ TD::Types::Ok

Stops the uploading of a file. Supported only for files uploaded by using #upload_file. For other files the behavior is undefined.

Parameters:

  • file_id (Integer)

    Identifier of the file to stop uploading.

Returns:



270
271
272
273
# File 'lib/tdlib/client_methods.rb', line 270

def cancel_upload_file(file_id)
  broadcast('@type'   => 'cancelUploadFile',
            'file_id' => file_id)
end

#change_chat_report_spam_state(chat_id, is_spam_chat) ⇒ TD::Types::Ok

Used to let the server know whether a chat is spam or not. Can be used only if Types::ChatReportSpamState#can_report_spam is true. After this request, Types::ChatReportSpamState#can_report_spam becomes false forever.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • is_spam_chat (Boolean)

    If true, the chat will be reported as spam; otherwise it will be marked as not spam.

Returns:



282
283
284
285
286
# File 'lib/tdlib/client_methods.rb', line 282

def change_chat_report_spam_state(chat_id, is_spam_chat)
  broadcast('@type'        => 'changeChatReportSpamState',
            'chat_id'      => chat_id,
            'is_spam_chat' => is_spam_chat)
end

#change_imported_contacts(contacts) ⇒ TD::Types::ImportedContacts

Changes imported contacts using the list of current user contacts saved on the device. Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts. Query result depends on the result of the previous query, so only one query is possible at the same time.

Parameters:

  • contacts (Array<TD::Types::Contact>)

    The new list of contacts, contact's vCard are ignored and are not imported.

Returns:



295
296
297
298
# File 'lib/tdlib/client_methods.rb', line 295

def change_imported_contacts(contacts)
  broadcast('@type'    => 'changeImportedContacts',
            'contacts' => contacts)
end

#change_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false) ⇒ TD::Types::AuthenticationCodeInfo

Changes the phone number of the user and sends an authentication code to the user's new phone number.

Parameters:

  • phone_number (String)

    The new phone number of the user in international format.

  • allow_flash_call (Boolean) (defaults to: false)

    Pass true if the code can be sent via flash call to the specified phone number.

  • is_current_phone_number (Boolean) (defaults to: false)

    Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false.

Returns:



307
308
309
310
311
312
# File 'lib/tdlib/client_methods.rb', line 307

def change_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false)
  broadcast('@type'                   => 'changePhoneNumber',
            'phone_number'            => phone_number,
            'allow_flash_call'        => allow_flash_call,
            'is_current_phone_number' => is_current_phone_number)
end

#change_sticker_set(set_id, is_installed, is_archived) ⇒ TD::Types::Ok

Installs/uninstalls or activates/archives a sticker set.

Parameters:

  • set_id (Integer)

    Identifier of the sticker set.

  • is_installed (Boolean)

    The new value of is_installed.

  • is_archived (Boolean)

    The new value of is_archived. A sticker set can't be installed and archived simultaneously.

Returns:



321
322
323
324
325
326
# File 'lib/tdlib/client_methods.rb', line 321

def change_sticker_set(set_id, is_installed, is_archived)
  broadcast('@type'        => 'changeStickerSet',
            'set_id'       => set_id,
            'is_installed' => is_installed,
            'is_archived'  => is_archived)
end

#check_authentication_bot_token(token) ⇒ TD::Types::Ok

Checks the authentication token of a bot; to log in as a bot. Works only when the current authorization state is Types::AuthorizationState::WaitPhoneNumber. Can be used instead of #set_authentication_phone_number and #check_authentication_code to log in.

Parameters:

  • token (String)

    The bot token.

Returns:



334
335
336
337
# File 'lib/tdlib/client_methods.rb', line 334

def check_authentication_bot_token(token)
  broadcast('@type' => 'checkAuthenticationBotToken',
            'token' => token)
end

#check_authentication_code(code, first_name = nil, last_name = nil) ⇒ TD::Types::Ok

Checks the authentication code. Works only when the current authorization state is Types::AuthorizationState::WaitCode.

Parameters:

  • code (String)

    The verification code received via SMS, Telegram message, phone call, or flash call.

  • first_name (String, nil) (defaults to: nil)

    If the user is not yet registered, the first name of the user; 1-255 characters.

  • last_name (String, nil) (defaults to: nil)

    If the user is not yet registered; the last name of the user; optional; 0-255 characters.

Returns:



347
348
349
350
351
352
# File 'lib/tdlib/client_methods.rb', line 347

def check_authentication_code(code, first_name = nil, last_name = nil)
  broadcast('@type'      => 'checkAuthenticationCode',
            'code'       => code,
            'first_name' => first_name,
            'last_name'  => last_name)
end

#check_authentication_password(password) ⇒ TD::Types::Ok

Checks the authentication password for correctness. Works only when the current authorization state is Types::AuthorizationState::WaitPassword.

Parameters:

  • password (String)

    The password to check.

Returns:



359
360
361
362
# File 'lib/tdlib/client_methods.rb', line 359

def check_authentication_password(password)
  broadcast('@type'    => 'checkAuthenticationPassword',
            'password' => password)
end

#check_change_phone_number_code(code) ⇒ TD::Types::Ok

Checks the authentication code sent to confirm a new phone number of the user.

Parameters:

  • code (String)

    Verification code received by SMS, phone call or flash call.

Returns:



368
369
370
371
# File 'lib/tdlib/client_methods.rb', line 368

def check_change_phone_number_code(code)
  broadcast('@type' => 'checkChangePhoneNumberCode',
            'code'  => code)
end

Checks the validity of an invite link for a chat and returns information about the corresponding chat.

Parameters:

Returns:



378
379
380
381
# File 'lib/tdlib/client_methods.rb', line 378

def check_chat_invite_link(invite_link)
  broadcast('@type'       => 'checkChatInviteLink',
            'invite_link' => invite_link)
end

#check_chat_username(chat_id, username) ⇒ TD::Types::CheckChatUsernameResult

Checks whether a username can be set for a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a private chat with self, or zero if chat is being created.

  • username (String)

    Username to be checked.

Returns:



389
390
391
392
393
# File 'lib/tdlib/client_methods.rb', line 389

def check_chat_username(chat_id, username)
  broadcast('@type'    => 'checkChatUsername',
            'chat_id'  => chat_id,
            'username' => username)
end

#check_database_encryption_key(encryption_key) ⇒ TD::Types::Ok

Checks the database encryption key for correctness. Works only when the current authorization state is Types::AuthorizationState::WaitEncryptionKey.

Parameters:

  • encryption_key (String)

    Encryption key to check or set up.

Returns:



400
401
402
403
# File 'lib/tdlib/client_methods.rb', line 400

def check_database_encryption_key(encryption_key)
  broadcast('@type'          => 'checkDatabaseEncryptionKey',
            'encryption_key' => encryption_key)
end

#check_email_address_verification_code(code) ⇒ TD::Types::Ok

Checks the email address verification code for Telegram Passport.

Parameters:

  • code (String)

    Verification code.

Returns:



409
410
411
412
# File 'lib/tdlib/client_methods.rb', line 409

def check_email_address_verification_code(code)
  broadcast('@type' => 'checkEmailAddressVerificationCode',
            'code'  => code)
end

#check_phone_number_confirmation_code(code) ⇒ TD::Types::Ok

Checks phone number confirmation code.

Parameters:

  • code (String)

    The phone number confirmation code.

Returns:



418
419
420
421
# File 'lib/tdlib/client_methods.rb', line 418

def check_phone_number_confirmation_code(code)
  broadcast('@type' => 'checkPhoneNumberConfirmationCode',
            'code'  => code)
end

#check_phone_number_verification_code(code) ⇒ TD::Types::Ok

Checks the phone number verification code for Telegram Passport.

Parameters:

  • code (String)

    Verification code.

Returns:



427
428
429
430
# File 'lib/tdlib/client_methods.rb', line 427

def check_phone_number_verification_code(code)
  broadcast('@type' => 'checkPhoneNumberVerificationCode',
            'code'  => code)
end

#clean_file_name(file_name) ⇒ TD::Types::Text

Removes potentially dangerous characters from the name of a file. The encoding of the file name is supposed to be UTF-8. Returns an empty string on failure. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

  • file_name (String)

    File name or path to the file.

Returns:



441
442
443
444
# File 'lib/tdlib/client_methods.rb', line 441

def clean_file_name(file_name)
  broadcast('@type'     => 'cleanFileName',
            'file_name' => file_name)
end

#clear_all_draft_messages(exclude_secret_chats) ⇒ TD::Types::Ok

Clears draft messages in all chats.

Parameters:

  • exclude_secret_chats (Boolean)

    If true, local draft messages in secret chats will not be cleared.

Returns:



450
451
452
453
# File 'lib/tdlib/client_methods.rb', line 450

def clear_all_draft_messages(exclude_secret_chats)
  broadcast('@type'                => 'clearAllDraftMessages',
            'exclude_secret_chats' => exclude_secret_chats)
end

#clear_imported_contactsTD::Types::Ok

Clears all imported contacts, contacts list remains unchanged.

Returns:



458
459
460
# File 'lib/tdlib/client_methods.rb', line 458

def clear_imported_contacts
  broadcast('@type' => 'clearImportedContacts')
end

#clear_recent_stickers(is_attached = false) ⇒ TD::Types::Ok

Clears the list of recently used stickers.

Parameters:

  • is_attached (Boolean) (defaults to: false)

    Pass true to clear the list of stickers recently attached to photo or video files; pass false to clear the list of recently sent stickers.

Returns:



467
468
469
470
# File 'lib/tdlib/client_methods.rb', line 467

def clear_recent_stickers(is_attached = false)
  broadcast('@type'       => 'clearRecentStickers',
            'is_attached' => is_attached)
end

#clear_recently_found_chatsTD::Types::Ok

Clears the list of recently found chats.

Returns:



475
476
477
# File 'lib/tdlib/client_methods.rb', line 475

def clear_recently_found_chats
  broadcast('@type' => 'clearRecentlyFoundChats')
end

#closeTD::Types::Ok

Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes, Types::Update::AuthorizationState with Types::AuthorizationState::Closed will be sent.

Returns:



485
486
487
# File 'lib/tdlib/client_methods.rb', line 485

def close
  broadcast('@type' => 'close')
end

#close_chat(chat_id) ⇒ TD::Types::Ok

This method should be called if the chat is closed by the user. Many useful activities depend on the chat being opened or closed.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



494
495
496
497
# File 'lib/tdlib/client_methods.rb', line 494

def close_chat(chat_id)
  broadcast('@type'   => 'closeChat',
            'chat_id' => chat_id)
end

#close_secret_chat(secret_chat_id) ⇒ TD::Types::Ok

Closes a secret chat, effectively transfering its state to Types::SecretChatState::Closed.

Parameters:

  • secret_chat_id (Integer)

    Secret chat identifier.

Returns:



503
504
505
506
# File 'lib/tdlib/client_methods.rb', line 503

def close_secret_chat(secret_chat_id)
  broadcast('@type'          => 'closeSecretChat',
            'secret_chat_id' => secret_chat_id)
end

#create_basic_group_chat(basic_group_id, force = false) ⇒ TD::Types::Chat

Returns an existing chat corresponding to a known basic group.

Parameters:

  • basic_group_id (Integer)

    Basic group identifier.

  • force (Boolean) (defaults to: false)

    If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect.

Returns:



514
515
516
517
518
# File 'lib/tdlib/client_methods.rb', line 514

def create_basic_group_chat(basic_group_id, force = false)
  broadcast('@type'          => 'createBasicGroupChat',
            'basic_group_id' => basic_group_id,
            'force'          => force)
end

#create_call(user_id, protocol) ⇒ TD::Types::CallId

Creates a new call.

Parameters:

  • user_id (Integer)

    Identifier of the user to be called.

  • protocol (TD::Types::CallProtocol)

    Description of the call protocols supported by the client.

Returns:



525
526
527
528
529
# File 'lib/tdlib/client_methods.rb', line 525

def create_call(user_id, protocol)
  broadcast('@type'    => 'createCall',
            'user_id'  => user_id,
            'protocol' => protocol)
end

#create_new_basic_group_chat(user_ids, title) ⇒ TD::Types::Chat

Creates a new basic group and sends a corresponding Types::MessageContent::BasicGroupChatCreate.

Parameters:

  • user_ids (Array<Integer>)

    Identifiers of users to be added to the basic group.

  • title (String)

    Title of the new basic group; 1-255 characters.

Returns:



536
537
538
539
540
# File 'lib/tdlib/client_methods.rb', line 536

def create_new_basic_group_chat(user_ids, title)
  broadcast('@type'    => 'createNewBasicGroupChat',
            'user_ids' => user_ids,
            'title'    => title)
end

#create_new_secret_chat(user_id) ⇒ TD::Types::Chat

Creates a new secret chat.

Parameters:

  • user_id (Integer)

    Identifier of the target user.

Returns:



546
547
548
549
# File 'lib/tdlib/client_methods.rb', line 546

def create_new_secret_chat(user_id)
  broadcast('@type'   => 'createNewSecretChat',
            'user_id' => user_id)
end

#create_new_sticker_set(user_id, title, name, stickers, is_masks: false) ⇒ TD::Types::StickerSet

Creates a new sticker set; for bots only.

Parameters:

  • user_id (Integer)

    Sticker set owner.

  • title (String)

    Sticker set title; 1-64 characters.

  • name (String)

    Sticker set name. Can contain only English letters, digits and underscores. Must end with "by" ( is case insensitive); 1-64 characters.

  • is_masks (Boolean) (defaults to: false)

    True, if stickers are masks.

  • stickers (Array<TD::Types::InputSticker>)

    List of stickers to be added to the set.

Returns:



561
562
563
564
565
566
567
568
# File 'lib/tdlib/client_methods.rb', line 561

def create_new_sticker_set(user_id, title, name, stickers, is_masks: false)
  broadcast('@type'    => 'createNewStickerSet',
            'user_id'  => user_id,
            'title'    => title,
            'name'     => name,
            'is_masks' => is_masks,
            'stickers' => stickers)
end

#create_new_supergroup_chat(title, description, is_channel: false) ⇒ TD::Types::Chat

Creates a new supergroup or channel and sends a corresponding Types::MessageContent::SupergroupChatCreate.

Parameters:

  • title (String)

    Title of the new chat; 1-255 characters.

  • is_channel (Boolean) (defaults to: false)

    True, if a channel chat should be created.

  • description (String)

    Chat description; 0-255 characters.

Returns:



576
577
578
579
580
581
# File 'lib/tdlib/client_methods.rb', line 576

def create_new_supergroup_chat(title, description, is_channel: false)
  broadcast('@type'       => 'createNewSupergroupChat',
            'title'       => title,
            'is_channel'  => is_channel,
            'description' => description)
end

#create_private_chat(user_id, force = false) ⇒ TD::Types::Chat

Returns an existing chat corresponding to a given user.

Parameters:

  • user_id (Integer)

    User identifier.

  • force (Boolean) (defaults to: false)

    If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect.

Returns:



589
590
591
592
593
# File 'lib/tdlib/client_methods.rb', line 589

def create_private_chat(user_id, force = false)
  broadcast('@type'   => 'createPrivateChat',
            'user_id' => user_id,
            'force'   => force)
end

#create_secret_chat(secret_chat_id) ⇒ TD::Types::Chat

Returns an existing chat corresponding to a known secret chat.

Parameters:

  • secret_chat_id (Integer)

    Secret chat identifier.

Returns:



599
600
601
602
# File 'lib/tdlib/client_methods.rb', line 599

def create_secret_chat(secret_chat_id)
  broadcast('@type'          => 'createSecretChat',
            'secret_chat_id' => secret_chat_id)
end

#create_supergroup_chat(supergroup_id, force = false) ⇒ TD::Types::Chat

Returns an existing chat corresponding to a known supergroup or channel.

Parameters:

  • supergroup_id (Integer)

    Supergroup or channel identifier.

  • force (Boolean) (defaults to: false)

    If true, the chat will be created without network request. In this case all information about the chat except its type, title and photo can be incorrect.

Returns:



610
611
612
613
614
# File 'lib/tdlib/client_methods.rb', line 610

def create_supergroup_chat(supergroup_id, force = false)
  broadcast('@type'         => 'createSupergroupChat',
            'supergroup_id' => supergroup_id,
            'force'         => force)
end

#create_temporary_password(password, valid_for) ⇒ TD::Types::TemporaryPasswordState

Creates a new temporary password for processing payments.

Parameters:

  • password (String)

    Persistent user password.

  • valid_for (Integer)

    Time during which the temporary password will be valid, in seconds; should be between 60 and 86400.

Returns:



622
623
624
625
626
# File 'lib/tdlib/client_methods.rb', line 622

def create_temporary_password(password, valid_for)
  broadcast('@type'     => 'createTemporaryPassword',
            'password'  => password,
            'valid_for' => valid_for)
end

#delete_account(reason = nil) ⇒ TD::Types::Ok

Deletes the account of the current user, deleting all information associated with the user from the server. The phone number of the account can be used to create a new account. Can be called before authorization when the current authorization state is Types::AuthorizationState::WaitPassword.

Parameters:

  • reason (String, nil) (defaults to: nil)

    The reason why the account was deleted; optional.

Returns:



635
636
637
638
# File 'lib/tdlib/client_methods.rb', line 635

def (reason = nil)
  broadcast('@type'  => 'deleteAccount',
            'reason' => reason)
end

#delete_chat_history(chat_id, remove_from_chat_list = false) ⇒ TD::Types::Ok

Deletes all messages in the chat only for the user. Cannot be used in channels and public supergroups.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • remove_from_chat_list (Boolean) (defaults to: false)

    Pass true if the chat should be removed from the chats list.

Returns:



646
647
648
649
650
# File 'lib/tdlib/client_methods.rb', line 646

def delete_chat_history(chat_id, remove_from_chat_list = false)
  broadcast('@type'                 => 'deleteChatHistory',
            'chat_id'               => chat_id,
            'remove_from_chat_list' => remove_from_chat_list)
end

#delete_chat_messages_from_user(chat_id, user_id) ⇒ TD::Types::Ok

Deletes all messages sent by the specified user to a chat. Supported only in supergroups; requires can_delete_messages administrator privileges.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • user_id (Integer)

    User identifier.

Returns:



658
659
660
661
662
# File 'lib/tdlib/client_methods.rb', line 658

def delete_chat_messages_from_user(chat_id, user_id)
  broadcast('@type'   => 'deleteChatMessagesFromUser',
            'chat_id' => chat_id,
            'user_id' => user_id)
end

#delete_chat_reply_markup(chat_id, message_id) ⇒ TD::Types::Ok

Deletes the default reply markup from a chat. Must be called after a one-time keyboard or a ForceReply reply markup has been used. UpdateChatReplyMarkup will be sent if the reply markup will be changed.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • message_id (Integer)

    The message identifier of the used keyboard.

Returns:



671
672
673
674
675
# File 'lib/tdlib/client_methods.rb', line 671

def delete_chat_reply_markup(chat_id, message_id)
  broadcast('@type'      => 'deleteChatReplyMarkup',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#delete_file(file_id) ⇒ TD::Types::Ok

Deletes a file from the TDLib file cache.

Parameters:

  • file_id (Integer)

    Identifier of the file to delete.

Returns:



681
682
683
684
# File 'lib/tdlib/client_methods.rb', line 681

def delete_file(file_id)
  broadcast('@type'   => 'deleteFile',
            'file_id' => file_id)
end

#delete_language_pack(language_pack_id) ⇒ TD::Types::Ok

Deletes all information about a language pack in the current localization target. The language pack that is currently in use can't be deleted.

Parameters:

  • language_pack_id (String)

    Identifier of the language pack to delete.

Returns:



691
692
693
694
# File 'lib/tdlib/client_methods.rb', line 691

def delete_language_pack(language_pack_id)
  broadcast('@type'            => 'deleteLanguagePack',
            'language_pack_id' => language_pack_id)
end

#delete_messages(chat_id, message_ids, revoke = false) ⇒ TD::Types::Ok

Deletes messages.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • message_ids (Array<Integer>)

    Identifiers of the messages to be deleted.

  • revoke (Boolean) (defaults to: false)

    Pass true to try to delete outgoing messages for all chat members (may fail if messages are too old). Always true for supergroups, channels and secret chats.

Returns:



704
705
706
707
708
709
# File 'lib/tdlib/client_methods.rb', line 704

def delete_messages(chat_id, message_ids, revoke = false)
  broadcast('@type'       => 'deleteMessages',
            'chat_id'     => chat_id,
            'message_ids' => message_ids,
            'revoke'      => revoke)
end

#delete_passport_element(type) ⇒ TD::Types::Ok

Deletes a Telegram Passport element.

Parameters:

Returns:



715
716
717
718
# File 'lib/tdlib/client_methods.rb', line 715

def delete_passport_element(type)
  broadcast('@type' => 'deletePassportElement',
            'type'  => type)
end

#delete_profile_photo(profile_photo_id) ⇒ TD::Types::Ok

Deletes a profile photo. If something changes, Types::Update::User will be sent.

Parameters:

  • profile_photo_id (Integer)

    Identifier of the profile photo to delete.

Returns:



725
726
727
728
# File 'lib/tdlib/client_methods.rb', line 725

def delete_profile_photo(profile_photo_id)
  broadcast('@type'            => 'deleteProfilePhoto',
            'profile_photo_id' => profile_photo_id)
end

#delete_saved_credentialsTD::Types::Ok

Deletes saved credentials for all payment provider bots.

Returns:



733
734
735
# File 'lib/tdlib/client_methods.rb', line 733

def delete_saved_credentials
  broadcast('@type' => 'deleteSavedCredentials')
end

#delete_saved_order_infoTD::Types::Ok

Deletes saved order info.

Returns:



740
741
742
# File 'lib/tdlib/client_methods.rb', line 740

def delete_saved_order_info
  broadcast('@type' => 'deleteSavedOrderInfo')
end

#delete_supergroup(supergroup_id) ⇒ TD::Types::Ok

Deletes a supergroup or channel along with all messages in the corresponding chat. This will release the supergroup or channel username and remove all members; requires creator privileges in the supergroup or channel. Chats with more than 1000 members can't be deleted using this method.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup or channel.

Returns:



751
752
753
754
# File 'lib/tdlib/client_methods.rb', line 751

def delete_supergroup(supergroup_id)
  broadcast('@type'         => 'deleteSupergroup',
            'supergroup_id' => supergroup_id)
end

#destroyTD::Types::Ok

Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in the list of all active sessions. All local data will be destroyed. After the destruction completes Types::Update::AuthorizationState with Types::AuthorizationState::Closed will be sent.

Returns:



763
764
765
# File 'lib/tdlib/client_methods.rb', line 763

def destroy
  broadcast('@type' => 'destroy')
end

#disable_proxyTD::Types::Ok

Disables the currently enabled proxy. Can be called before authorization.

Returns:



771
772
773
# File 'lib/tdlib/client_methods.rb', line 771

def disable_proxy
  broadcast('@type' => 'disableProxy')
end

#discard_call(call_id, duration, connection_id, is_disconnected: false) ⇒ TD::Types::Ok

Discards a call.

Parameters:

  • call_id (Integer)

    Call identifier.

  • is_disconnected (Boolean) (defaults to: false)

    True, if the user was disconnected.

  • duration (Integer)

    The call duration, in seconds.

  • connection_id (Integer)

    Identifier of the connection used during the call.

Returns:



782
783
784
785
786
787
788
# File 'lib/tdlib/client_methods.rb', line 782

def discard_call(call_id, duration, connection_id, is_disconnected: false)
  broadcast('@type'           => 'discardCall',
            'call_id'         => call_id,
            'is_disconnected' => is_disconnected,
            'duration'        => duration,
            'connection_id'   => connection_id)
end

#disconnect_all_websitesTD::Types::Ok

Disconnects all websites from the current user's Telegram account.

Returns:



793
794
795
# File 'lib/tdlib/client_methods.rb', line 793

def disconnect_all_websites
  broadcast('@type' => 'disconnectAllWebsites')
end

#disconnect_website(website_id) ⇒ TD::Types::Ok

Disconnects website from the current user's Telegram account.

Parameters:

  • website_id (Integer)

    Website identifier.

Returns:



801
802
803
804
# File 'lib/tdlib/client_methods.rb', line 801

def disconnect_website(website_id)
  broadcast('@type'      => 'disconnectWebsite',
            'website_id' => website_id)
end

#download_file(file_id, priority = 1) ⇒ TD::Types::File

Asynchronously downloads a file from the cloud. Types::Update::File will be used to notify about the download progress and successful completion of the download. Returns file state just after the download has been started.

Parameters:

  • file_id (Integer)

    Identifier of the file to download.

  • priority (Integer) (defaults to: 1)

    Priority of the download (1-32). The higher the priority, the earlier the file will be downloaded. If the priorities of two files are equal, then the last one for which #download_file was called will be downloaded first.

Returns:



817
818
819
820
821
# File 'lib/tdlib/client_methods.rb', line 817

def download_file(file_id, priority = 1)
  broadcast('@type'    => 'downloadFile',
            'file_id'  => file_id,
            'priority' => priority)
end

#edit_custom_language_pack_info(info) ⇒ TD::Types::Ok

Edits information about a custom language pack in the current localization target.

Parameters:

Returns:



827
828
829
830
# File 'lib/tdlib/client_methods.rb', line 827

def edit_custom_language_pack_info(info)
  broadcast('@type' => 'editCustomLanguagePackInfo',
            'info'  => info)
end

#edit_inline_message_caption(inline_message_id, reply_markup, caption) ⇒ TD::Types::Ok

Edits the caption of an inline message sent via a bot; for bots only.

Parameters:

  • inline_message_id (String)

    Inline message identifier.

  • reply_markup (TD::Types::ReplyMarkup)

    The new message reply markup.

  • caption (TD::Types::FormattedText)

    New message content caption; 0-GetOption("message_caption_length_max") characters.

Returns:



839
840
841
842
843
844
# File 'lib/tdlib/client_methods.rb', line 839

def edit_inline_message_caption(inline_message_id, reply_markup, caption)
  broadcast('@type'             => 'editInlineMessageCaption',
            'inline_message_id' => inline_message_id,
            'reply_markup'      => reply_markup,
            'caption'           => caption)
end

#edit_inline_message_live_location(inline_message_id, reply_markup, location = nil) ⇒ TD::Types::Ok

Edits the content of a live location in an inline message sent via a bot; for bots only.

Parameters:

  • inline_message_id (String)

    Inline message identifier.

  • reply_markup (TD::Types::ReplyMarkup)

    The new message reply markup.

  • location (TD::Types::Location, nil) (defaults to: nil)

    New location content of the message. Pass nil to stop sharing the live location.

Returns:



853
854
855
856
857
858
# File 'lib/tdlib/client_methods.rb', line 853

def edit_inline_message_live_location(inline_message_id, reply_markup, location = nil)
  broadcast('@type'             => 'editInlineMessageLiveLocation',
            'inline_message_id' => inline_message_id,
            'reply_markup'      => reply_markup,
            'location'          => location)
end

#edit_inline_message_media(inline_message_id, input_message_content, reply_markup: nil) ⇒ TD::Types::Ok

Edits the content of a message with an animation, an audio, a document, a photo or a video in an inline message sent via a bot; for bots only.

Parameters:

Returns:



869
870
871
872
873
874
# File 'lib/tdlib/client_methods.rb', line 869

def edit_inline_message_media(inline_message_id, input_message_content, reply_markup: nil)
  broadcast('@type'                 => 'editInlineMessageMedia',
            'inline_message_id'     => inline_message_id,
            'reply_markup'          => reply_markup,
            'input_message_content' => input_message_content)
end

#edit_inline_message_reply_markup(inline_message_id, reply_markup) ⇒ TD::Types::Ok

Edits the reply markup of an inline message sent via a bot; for bots only.

Parameters:

  • inline_message_id (String)

    Inline message identifier.

  • reply_markup (TD::Types::ReplyMarkup)

    The new message reply markup.

Returns:



881
882
883
884
885
# File 'lib/tdlib/client_methods.rb', line 881

def edit_inline_message_reply_markup(inline_message_id, reply_markup)
  broadcast('@type'             => 'editInlineMessageReplyMarkup',
            'inline_message_id' => inline_message_id,
            'reply_markup'      => reply_markup)
end

#edit_inline_message_text(inline_message_id, input_message_content, reply_markup) ⇒ TD::Types::Ok

Edits the text of an inline text or game message sent via a bot; for bots only.

Parameters:

Returns:



893
894
895
896
897
898
# File 'lib/tdlib/client_methods.rb', line 893

def edit_inline_message_text(inline_message_id, input_message_content, reply_markup)
  broadcast('@type'                 => 'editInlineMessageText',
            'inline_message_id'     => inline_message_id,
            'reply_markup'          => reply_markup,
            'input_message_content' => input_message_content)
end

#edit_message_caption(chat_id, message_id, caption, reply_markup: nil) ⇒ TD::Types::Message

Edits the message content caption.

Parameters:

  • chat_id (Integer)

    The chat the message belongs to.

  • message_id (Integer)

    Identifier of the message.

  • reply_markup (TD::Types::ReplyMarkup, nil) (defaults to: nil)

    The new message reply markup; for bots only.

  • caption (TD::Types::FormattedText)

    New message content caption; 0-GetOption("message_caption_length_max") characters.

Returns:

  • (TD::Types::Message)

    the edited message after the edit is completed on the server side.



908
909
910
911
912
913
914
# File 'lib/tdlib/client_methods.rb', line 908

def edit_message_caption(chat_id, message_id, caption, reply_markup: nil)
  broadcast('@type'        => 'editMessageCaption',
            'chat_id'      => chat_id,
            'message_id'   => message_id,
            'reply_markup' => reply_markup,
            'caption'      => caption)
end

#edit_message_live_location(chat_id, message_id, location = nil, reply_markup: nil) ⇒ TD::Types::Message

Edits the message content of a live location. Messages can be edited for a limited period of time specified in the live location.

Parameters:

  • chat_id (Integer)

    The chat the message belongs to.

  • message_id (Integer)

    Identifier of the message.

  • reply_markup (TD::Types::ReplyMarkup, nil) (defaults to: nil)

    The new message reply markup; for bots only.

  • location (TD::Types::Location, nil) (defaults to: nil)

    New location content of the message. Pass nil to stop sharing the live location.

Returns:

  • (TD::Types::Message)

    the edited message after the edit is completed on the server side.



925
926
927
928
929
930
931
# File 'lib/tdlib/client_methods.rb', line 925

def edit_message_live_location(chat_id, message_id, location = nil, reply_markup: nil)
  broadcast('@type'        => 'editMessageLiveLocation',
            'chat_id'      => chat_id,
            'message_id'   => message_id,
            'reply_markup' => reply_markup,
            'location'     => location)
end

#edit_message_media(chat_id, message_id, input_message_content, reply_markup: nil) ⇒ TD::Types::Message

Edits the content of a message with an animation, an audio, a document, a photo or a video. The media in the message can't be replaced if the message was set to self-destruct. Media can't be replaced by self-destructing media. Media in an album can be edited only to contain a photo or a video.

Parameters:

Returns:

  • (TD::Types::Message)

    the edited message after the edit is completed on the server side.



945
946
947
948
949
950
951
# File 'lib/tdlib/client_methods.rb', line 945

def edit_message_media(chat_id, message_id, input_message_content, reply_markup: nil)
  broadcast('@type'                 => 'editMessageMedia',
            'chat_id'               => chat_id,
            'message_id'            => message_id,
            'reply_markup'          => reply_markup,
            'input_message_content' => input_message_content)
end

#edit_message_reply_markup(chat_id, message_id, reply_markup) ⇒ TD::Types::Message

Edits the message reply markup; for bots only.

Parameters:

  • chat_id (Integer)

    The chat the message belongs to.

  • message_id (Integer)

    Identifier of the message.

  • reply_markup (TD::Types::ReplyMarkup)

    The new message reply markup.

Returns:

  • (TD::Types::Message)

    the edited message after the edit is completed on the server side.



959
960
961
962
963
964
# File 'lib/tdlib/client_methods.rb', line 959

def edit_message_reply_markup(chat_id, message_id, reply_markup)
  broadcast('@type'        => 'editMessageReplyMarkup',
            'chat_id'      => chat_id,
            'message_id'   => message_id,
            'reply_markup' => reply_markup)
end

#edit_message_text(chat_id, message_id, input_message_content, reply_markup: nil) ⇒ TD::Types::Message

Edits the text of a message (or a text of a game message).

Parameters:

  • chat_id (Integer)

    The chat the message belongs to.

  • message_id (Integer)

    Identifier of the message.

  • reply_markup (TD::Types::ReplyMarkup, nil) (defaults to: nil)

    The new message reply markup; for bots only.

  • input_message_content (TD::Types::InputMessageContent::Text)

    New text content of the message.

Returns:

  • (TD::Types::Message)

    the edited message after the edit is completed on the server side.



973
974
975
976
977
978
979
# File 'lib/tdlib/client_methods.rb', line 973

def edit_message_text(chat_id, message_id, input_message_content, reply_markup: nil)
  broadcast('@type'                 => 'editMessageText',
            'chat_id'               => chat_id,
            'message_id'            => message_id,
            'reply_markup'          => reply_markup,
            'input_message_content' => input_message_content)
end

#edit_proxy(proxy_id, server, port, type, enable = false) ⇒ TD::Types::Proxy

Edits an existing proxy server for network requests. Can be called before authorization.

Parameters:

  • proxy_id (Integer)

    Proxy identifier.

  • server (String)

    Proxy server IP address.

  • port (Integer)

    Proxy server port.

  • enable (Boolean) (defaults to: false)

    True, if the proxy should be enabled.

  • type (TD::Types::ProxyType)

    Proxy type.

Returns:



990
991
992
993
994
995
996
997
# File 'lib/tdlib/client_methods.rb', line 990

def edit_proxy(proxy_id, server, port, type, enable = false)
  broadcast('@type'    => 'editProxy',
            'proxy_id' => proxy_id,
            'server'   => server,
            'port'     => port,
            'enable'   => enable,
            'type'     => type)
end

#enable_proxy(proxy_id) ⇒ TD::Types::Ok

Enables a proxy. Only one proxy can be enabled at a time. Can be called before authorization.

Parameters:

  • proxy_id (Integer)

    Proxy identifier.

Returns:



1005
1006
1007
1008
# File 'lib/tdlib/client_methods.rb', line 1005

def enable_proxy(proxy_id)
  broadcast('@type'    => 'enableProxy',
            'proxy_id' => proxy_id)
end

#finish_file_generation(generation_id, error: nil) ⇒ TD::Types::Ok

Finishes the file generation.

Parameters:

  • generation_id (Integer)

    The identifier of the generation process.

  • error (TD::Types::Error, nil) (defaults to: nil)

    If set, means that file generation has failed and should be terminated.

Returns:



1015
1016
1017
1018
1019
# File 'lib/tdlib/client_methods.rb', line 1015

def finish_file_generation(generation_id, error: nil)
  broadcast('@type'         => 'finishFileGeneration',
            'generation_id' => generation_id,
            'error'         => error)
end

#forward_messages(chat_id, from_chat_id, message_ids, disable_notification: false, from_background: false, as_album: false) ⇒ TD::Types::Messages?

Forwards previously sent messages.

Parameters:

  • chat_id (Integer)

    Identifier of the chat to which to forward messages.

  • from_chat_id (Integer)

    Identifier of the chat from which to forward messages.

  • message_ids (Array<Integer>)

    Identifiers of the messages to forward.

  • disable_notification (Boolean) (defaults to: false)

    Pass true to disable notification for the message, doesn't work if messages are forwarded to a secret chat.

  • from_background (Boolean) (defaults to: false)

    Pass true if the message is sent from the background.

  • as_album (Boolean) (defaults to: false)

    True, if the messages should be grouped into an album after forwarding. For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages.

Returns:

  • (TD::Types::Messages, nil)

    the forwarded messages in the same order as the message identifiers passed in message_ids. If a message can't be forwarded, nil will be returned instead of the message.



1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
# File 'lib/tdlib/client_methods.rb', line 1034

def forward_messages(chat_id, from_chat_id, message_ids,
                     disable_notification: false, from_background: false, as_album: false)
  broadcast('@type'                => 'forwardMessages',
            'chat_id'              => chat_id,
            'from_chat_id'         => from_chat_id,
            'message_ids'          => message_ids,
            'disable_notification' => disable_notification,
            'from_background'      => from_background,
            'as_album'             => as_album)
end

Generates a new invite link for a chat; the previously generated link is revoked. Available for basic groups, supergroups, and channels. In basic groups this can be called only by the group's creator; in supergroups and channels this requires appropriate administrator rights.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



1052
1053
1054
1055
# File 'lib/tdlib/client_methods.rb', line 1052

def generate_chat_invite_link(chat_id)
  broadcast('@type'   => 'generateChatInviteLink',
            'chat_id' => chat_id)
end

#get_account_ttlTD::Types::AccountTtl

Returns the period of inactivity after which the account of the current user will automatically be deleted.



1060
1061
1062
# File 'lib/tdlib/client_methods.rb', line 1060

def 
  broadcast('@type' => 'getAccountTtl')
end

#get_active_live_location_messagesTD::Types::Messages

Returns all active live locations that should be updated by the client. The list is persistent across application restarts only if the message database is used.

Returns:



1068
1069
1070
# File 'lib/tdlib/client_methods.rb', line 1068

def get_active_live_location_messages
  broadcast('@type' => 'getActiveLiveLocationMessages')
end

#get_active_sessionsTD::Types::Sessions

Returns all active sessions of the current user.

Returns:



1075
1076
1077
# File 'lib/tdlib/client_methods.rb', line 1075

def get_active_sessions
  broadcast('@type' => 'getActiveSessions')
end

#get_all_passport_elements(password) ⇒ TD::Types::PassportElements

Returns all available Telegram Passport elements.

Parameters:

  • password (String)

    Password of the current user.

Returns:



1083
1084
1085
1086
# File 'lib/tdlib/client_methods.rb', line 1083

def get_all_passport_elements(password)
  broadcast('@type'    => 'getAllPassportElements',
            'password' => password)
end

#get_archived_sticker_sets(offset_sticker_set_id, limit = 100, is_masks: false) ⇒ TD::Types::StickerSets

Returns a list of archived sticker sets.

Parameters:

  • is_masks (Boolean) (defaults to: false)

    Pass true to return mask stickers sets; pass false to return ordinary sticker sets.

  • offset_sticker_set_id (Integer)

    Identifier of the sticker set from which to return the result.

  • limit (Integer) (defaults to: 100)

    Maximum number of sticker sets to return.

Returns:



1094
1095
1096
1097
1098
1099
# File 'lib/tdlib/client_methods.rb', line 1094

def get_archived_sticker_sets(offset_sticker_set_id, limit = 100, is_masks: false)
  broadcast('@type'                 => 'getArchivedStickerSets',
            'is_masks'              => is_masks,
            'offset_sticker_set_id' => offset_sticker_set_id,
            'limit'                 => limit)
end

#get_attached_sticker_sets(file_id) ⇒ TD::Types::StickerSets

Returns a list of sticker sets attached to a file. Currently only photos and videos can have attached sticker sets.

Parameters:

  • file_id (Integer)

    File identifier.

Returns:



1106
1107
1108
1109
# File 'lib/tdlib/client_methods.rb', line 1106

def get_attached_sticker_sets(file_id)
  broadcast('@type'   => 'getAttachedStickerSets',
            'file_id' => file_id)
end

#get_authorization_stateTD::Types::AuthorizationState

Returns the current authorization state; this is an offline request. For informational purposes only. Use Types::Update::AuthorizationState instead to maintain the current authorization state.



1116
1117
1118
# File 'lib/tdlib/client_methods.rb', line 1116

def get_authorization_state
  broadcast('@type' => 'getAuthorizationState')
end

#get_basic_group(basic_group_id) ⇒ TD::Types::BasicGroup

Returns information about a basic group by its identifier. This is an offline request if the current user is not a bot.

Parameters:

  • basic_group_id (Integer)

    Basic group identifier.

Returns:



1125
1126
1127
1128
# File 'lib/tdlib/client_methods.rb', line 1125

def get_basic_group(basic_group_id)
  broadcast('@type'          => 'getBasicGroup',
            'basic_group_id' => basic_group_id)
end

#get_basic_group_full_info(basic_group_id) ⇒ TD::Types::BasicGroupFullInfo

Returns full information about a basic group by its identifier.

Parameters:

  • basic_group_id (Integer)

    Basic group identifier.

Returns:



1134
1135
1136
1137
# File 'lib/tdlib/client_methods.rb', line 1134

def get_basic_group_full_info(basic_group_id)
  broadcast('@type'          => 'getBasicGroupFullInfo',
            'basic_group_id' => basic_group_id)
end

#get_blocked_users(offset, limit = 100) ⇒ TD::Types::Users

Returns users that were blocked by the current user.

Parameters:

  • offset (Integer)

    Number of users to skip in the result; must be non-negative.

  • limit (Integer) (defaults to: 100)

    Maximum number of users to return; up to 100.

Returns:



1144
1145
1146
1147
1148
# File 'lib/tdlib/client_methods.rb', line 1144

def get_blocked_users(offset, limit = 100)
  broadcast('@type'  => 'getBlockedUsers',
            'offset' => offset,
            'limit'  => limit)
end

#get_callback_query_answer(chat_id, message_id, payload) ⇒ TD::Types::CallbackQueryAnswer

Sends a callback query to a bot and returns an answer. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.

Parameters:

  • chat_id (Integer)

    Identifier of the chat with the message.

  • message_id (Integer)

    Identifier of the message from which the query originated.

  • payload (TD::Types::CallbackQueryPayload)

    Query payload.

Returns:



1157
1158
1159
1160
1161
1162
# File 'lib/tdlib/client_methods.rb', line 1157

def get_callback_query_answer(chat_id, message_id, payload)
  broadcast('@type'      => 'getCallbackQueryAnswer',
            'chat_id'    => chat_id,
            'message_id' => message_id,
            'payload'    => payload)
end

#get_chat(chat_id) ⇒ TD::Types::Chat

Returns information about a chat by its identifier, this is an offline request if the current user is not a bot.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



1168
1169
1170
1171
# File 'lib/tdlib/client_methods.rb', line 1168

def get_chat(chat_id)
  broadcast('@type'   => 'getChat',
            'chat_id' => chat_id)
end

#get_chat_administrators(chat_id) ⇒ TD::Types::Users

Returns a list of users who are administrators of the chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



1177
1178
1179
1180
# File 'lib/tdlib/client_methods.rb', line 1177

def get_chat_administrators(chat_id)
  broadcast('@type'   => 'getChatAdministrators',
            'chat_id' => chat_id)
end

#get_chat_event_log(chat_id, query, from_event_id, limit, filters, user_ids) ⇒ TD::Types::ChatEvents

Returns a list of service actions taken by chat members and administrators in the last 48 hours. Available only in supergroups and channels. Requires administrator rights. Returns results in reverse chronological order (i.e., in order of decreasing event_id).

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • query (String)

    Search query by which to filter events.

  • from_event_id (Integer)

    Identifier of an event from which to return results. Use 0 to get results from the latest events.

  • limit (Integer)

    Maximum number of events to return; up to 100.

  • filters (TD::Types::ChatEventLogFilters)

    The types of events to return. By default, all types will be returned.

  • user_ids (Array<Integer>)

    User identifiers by which to filter events. By default, events relating to all users will be returned.

Returns:



1197
1198
1199
1200
1201
1202
1203
1204
1205
# File 'lib/tdlib/client_methods.rb', line 1197

def get_chat_event_log(chat_id, query, from_event_id, limit, filters, user_ids)
  broadcast('@type'         => 'getChatEventLog',
            'chat_id'       => chat_id,
            'query'         => query,
            'from_event_id' => from_event_id,
            'limit'         => limit,
            'filters'       => filters,
            'user_ids'      => user_ids)
end

#get_chat_history(chat_id, from_message_id, offset = 0, limit = 100, only_local: false) ⇒ TD::Types::Messages

Returns messages in a chat. The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id). For optimal performance the number of returned messages is chosen by the library. This is an offline request if only_local is true.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • from_message_id (Integer)

    Identifier of the message starting from which history must be fetched; use 0 to get results from the last message.

  • offset (Integer) (defaults to: 0)

    Specify 0 to get results from exactly the from_message_id or a negative offset to get the specified message and some newer messages.

  • limit (Integer) (defaults to: 100)

    The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached.

  • only_local (Boolean) (defaults to: false)

    If true, returns only messages that are available locally without sending network requests.

Returns:



1225
1226
1227
1228
1229
1230
1231
1232
# File 'lib/tdlib/client_methods.rb', line 1225

def get_chat_history(chat_id, from_message_id, offset = 0, limit = 100, only_local: false)
  broadcast('@type'           => 'getChatHistory',
            'chat_id'         => chat_id,
            'from_message_id' => from_message_id,
            'offset'          => offset,
            'limit'           => limit,
            'only_local'      => only_local)
end

#get_chat_member(chat_id, user_id) ⇒ TD::Types::ChatMember

Returns information about a single member of a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • user_id (Integer)

    User identifier.

Returns:



1239
1240
1241
1242
1243
# File 'lib/tdlib/client_methods.rb', line 1239

def get_chat_member(chat_id, user_id)
  broadcast('@type'   => 'getChatMember',
            'chat_id' => chat_id,
            'user_id' => user_id)
end

#get_chat_message_by_date(chat_id, date) ⇒ TD::Types::Message

Returns the last message sent in a chat no later than the specified date.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • date (Integer)

    Point in time (Unix timestamp) relative to which to search for messages.

Returns:



1250
1251
1252
1253
1254
# File 'lib/tdlib/client_methods.rb', line 1250

def get_chat_message_by_date(chat_id, date)
  broadcast('@type'   => 'getChatMessageByDate',
            'chat_id' => chat_id,
            'date'    => date)
end

#get_chat_message_count(chat_id, filter = nil, return_local: false) ⇒ TD::Types::Count

Returns approximate number of messages of the specified type in the chat.

Parameters:

  • chat_id (Integer)

    Identifier of the chat in which to count messages.

  • filter (TD::Types::SearchMessagesFilter, nil) (defaults to: nil)

    Filter for message content; Types::SearchMessagesFilter::Empty is unsupported in this function.

  • return_local (Boolean) (defaults to: false)

    If true, returns count that is available locally without sending network requests, returning -1 if the number of messages is unknown.

Returns:



1264
1265
1266
1267
1268
1269
# File 'lib/tdlib/client_methods.rb', line 1264

def get_chat_message_count(chat_id, filter = nil, return_local: false)
  broadcast('@type'        => 'getChatMessageCount',
            'chat_id'      => chat_id,
            'filter'       => filter,
            'return_local' => return_local)
end

#get_chat_pinned_message(chat_id) ⇒ TD::Types::Message

Returns information about a pinned chat message.

Parameters:

  • chat_id (Integer)

    Identifier of the chat the message belongs to.

Returns:



1275
1276
1277
1278
# File 'lib/tdlib/client_methods.rb', line 1275

def get_chat_pinned_message(chat_id)
  broadcast('@type'   => 'getChatPinnedMessage',
            'chat_id' => chat_id)
end

#get_chat_report_spam_state(chat_id) ⇒ TD::Types::ChatReportSpamState

Returns information on whether the current chat can be reported as spam.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



1284
1285
1286
1287
# File 'lib/tdlib/client_methods.rb', line 1284

def get_chat_report_spam_state(chat_id)
  broadcast('@type'   => 'getChatReportSpamState',
            'chat_id' => chat_id)
end

#get_chats(offset_chat_id = 0, limit = 100, offset_order: 9223372036854775807) ⇒ TD::Types::Chats

Returns an ordered list of chats. Chats are sorted by the pair (order, chat_id) in decreasing order. (For example, to get a list of chats from the beginning, the offset_order should be equal to 2^63 - 1). For optimal performance the number of returned chats is chosen by the library.

Parameters:

  • offset_order (Integer) (defaults to: 9223372036854775807)

    Chat order to return chats from.

  • offset_chat_id (Integer) (defaults to: 0)

    Chat identifier to return chats from.

  • limit (Integer) (defaults to: 100)

    The maximum number of chats to be returned. It is possible that fewer chats than the limit are returned even if the end of the list is not reached.

Returns:



1299
1300
1301
1302
1303
1304
# File 'lib/tdlib/client_methods.rb', line 1299

def get_chats(offset_chat_id = 0, limit = 100, offset_order: 9223372036854775807)
  broadcast('@type'          => 'getChats',
            'offset_order'   => offset_order,
            'offset_chat_id' => offset_chat_id,
            'limit'          => limit)
end

#get_connected_websitesTD::Types::ConnectedWebsites

Returns all website where the current user used Telegram to log in.



1309
1310
1311
# File 'lib/tdlib/client_methods.rb', line 1309

def get_connected_websites
  broadcast('@type' => 'getConnectedWebsites')
end

#get_contactsTD::Types::Users

Returns all user contacts.

Returns:



1316
1317
1318
# File 'lib/tdlib/client_methods.rb', line 1316

def get_contacts
  broadcast('@type' => 'getContacts')
end

#get_country_codeTD::Types::Text

Uses current user IP to found his country. Can be called before authorization.

Returns:



1324
1325
1326
# File 'lib/tdlib/client_methods.rb', line 1324

def get_country_code
  broadcast('@type' => 'getCountryCode')
end

#get_created_public_chatsTD::Types::Chats

Returns a list of public chats created by the user.

Returns:



1331
1332
1333
# File 'lib/tdlib/client_methods.rb', line 1331

def get_created_public_chats
  broadcast('@type' => 'getCreatedPublicChats')
end

Returns information about a tg:// deep link. Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing. Returns a 404 error for unknown links. Can be called before authorization.

Parameters:

  • link (String)

    The link.

Returns:



1342
1343
1344
1345
# File 'lib/tdlib/client_methods.rb', line 1342

def get_deep_link_info(link)
  broadcast('@type' => 'getDeepLinkInfo',
            'link'  => link)
end

#get_favorite_stickersTD::Types::Stickers

Returns favorite stickers.

Returns:



1350
1351
1352
# File 'lib/tdlib/client_methods.rb', line 1350

def get_favorite_stickers
  broadcast('@type' => 'getFavoriteStickers')
end

#get_file(file_id) ⇒ TD::Types::File

Returns information about a file; this is an offline request.

Parameters:

  • file_id (Integer)

    Identifier of the file to get.

Returns:



1358
1359
1360
1361
# File 'lib/tdlib/client_methods.rb', line 1358

def get_file(file_id)
  broadcast('@type'   => 'getFile',
            'file_id' => file_id)
end

#get_file_extension(mime_type) ⇒ TD::Types::Text

Returns the extension of a file, guessed by its MIME type. Returns an empty string on failure. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

  • mime_type (String)

    The MIME type of the file.

Returns:



1371
1372
1373
1374
# File 'lib/tdlib/client_methods.rb', line 1371

def get_file_extension(mime_type)
  broadcast('@type'     => 'getFileExtension',
            'mime_type' => mime_type)
end

#get_file_mime_type(file_name) ⇒ TD::Types::Text

Returns the MIME type of a file, guessed by its extension. Returns an empty string on failure. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

  • file_name (String)

    The name of the file or path to the file.

Returns:



1384
1385
1386
1387
# File 'lib/tdlib/client_methods.rb', line 1384

def get_file_mime_type(file_name)
  broadcast('@type'     => 'getFileMimeType',
            'file_name' => file_name)
end

#get_game_high_scores(chat_id, message_id, user_id) ⇒ TD::Types::GameHighScores

Returns the high scores for a game and some part of the high score table in the range of the specified user; for bots only.

Parameters:

  • chat_id (Integer)

    The chat that contains the message with the game.

  • message_id (Integer)

    Identifier of the message.

  • user_id (Integer)

    User identifier.

Returns:



1396
1397
1398
1399
1400
1401
# File 'lib/tdlib/client_methods.rb', line 1396

def get_game_high_scores(chat_id, message_id, user_id)
  broadcast('@type'      => 'getGameHighScores',
            'chat_id'    => chat_id,
            'message_id' => message_id,
            'user_id'    => user_id)
end

#get_groups_in_common(user_id, offset_chat_id = 0, limit = 100) ⇒ TD::Types::Chats

Returns a list of common chats with a given user. Chats are sorted by their type and creation date.

Parameters:

  • user_id (Integer)

    User identifier.

  • offset_chat_id (Integer) (defaults to: 0)

    Chat identifier starting from which to return chats; use 0 for the first request.

  • limit (Integer) (defaults to: 100)

    Maximum number of chats to be returned; up to 100.

Returns:



1410
1411
1412
1413
1414
1415
# File 'lib/tdlib/client_methods.rb', line 1410

def get_groups_in_common(user_id, offset_chat_id = 0, limit = 100)
  broadcast('@type'          => 'getGroupsInCommon',
            'user_id'        => user_id,
            'offset_chat_id' => offset_chat_id,
            'limit'          => limit)
end

#get_imported_contact_countTD::Types::Count

Returns the total number of imported contacts.

Returns:



1420
1421
1422
# File 'lib/tdlib/client_methods.rb', line 1420

def get_imported_contact_count
  broadcast('@type' => 'getImportedContactCount')
end

#get_inline_game_high_scores(inline_message_id, user_id) ⇒ TD::Types::GameHighScores

Returns game high scores and some part of the high score table in the range of the specified user; for bots only.

Parameters:

  • inline_message_id (String)

    Inline message identifier.

  • user_id (Integer)

    User identifier.

Returns:



1429
1430
1431
1432
1433
# File 'lib/tdlib/client_methods.rb', line 1429

def get_inline_game_high_scores(inline_message_id, user_id)
  broadcast('@type'             => 'getInlineGameHighScores',
            'inline_message_id' => inline_message_id,
            'user_id'           => user_id)
end

#get_inline_query_results(bot_user_id, chat_id, query, offset = '0', user_location: nil) ⇒ TD::Types::InlineQueryResults

Sends an inline query to a bot and returns its results. Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.

Parameters:

  • bot_user_id (Integer)

    The identifier of the target bot.

  • chat_id (Integer)

    Identifier of the chat, where the query was sent.

  • user_location (TD::Types::Location, nil) (defaults to: nil)

    Location of the user, only if needed.

  • query (String)

    Text of the query.

  • offset (String) (defaults to: '0')

    Offset of the first entry to return.

Returns:



1444
1445
1446
1447
1448
1449
1450
1451
# File 'lib/tdlib/client_methods.rb', line 1444

def get_inline_query_results(bot_user_id, chat_id, query, offset = '0', user_location: nil)
  broadcast('@type'         => 'getInlineQueryResults',
            'bot_user_id'   => bot_user_id,
            'chat_id'       => chat_id,
            'user_location' => user_location,
            'query'         => query,
            'offset'        => offset)
end

#get_installed_sticker_sets(is_masks = false) ⇒ TD::Types::StickerSets

Returns a list of installed sticker sets.

Parameters:

  • is_masks (Boolean) (defaults to: false)

    Pass true to return mask sticker sets; pass false to return ordinary sticker sets.

Returns:



1457
1458
1459
1460
# File 'lib/tdlib/client_methods.rb', line 1457

def get_installed_sticker_sets(is_masks = false)
  broadcast('@type'    => 'getInstalledStickerSets',
            'is_masks' => is_masks)
end

#get_invite_textTD::Types::Text

Returns the default text for invitation messages to be used as a placeholder when the current user invites friends to Telegram.

Returns:



1466
1467
1468
# File 'lib/tdlib/client_methods.rb', line 1466

def get_invite_text
  broadcast('@type' => 'getInviteText')
end

#get_language_pack_string(language_pack_database_path, localization_target, language_pack_id, key) ⇒ TD::Types::LanguagePackStringValue

Returns a string stored in the local database from the specified localization target and language pack by its key. Returns a 404 error if the string is not found. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

  • language_pack_database_path (String)

    Path to the language pack database in which strings are stored.

  • localization_target (String)

    Localization target to which the language pack belongs.

  • language_pack_id (String)

    Language pack identifier.

  • key (String)

    Language pack key of the string to be returned.

Returns:



1481
1482
1483
1484
1485
1486
1487
# File 'lib/tdlib/client_methods.rb', line 1481

def get_language_pack_string(language_pack_database_path, localization_target, language_pack_id, key)
  broadcast('@type'                       => 'getLanguagePackString',
            'language_pack_database_path' => language_pack_database_path,
            'localization_target'         => localization_target,
            'language_pack_id'            => language_pack_id,
            'key'                         => key)
end

#get_language_pack_strings(language_pack_id, keys) ⇒ TD::Types::LanguagePackStrings

Returns strings from a language pack in the current localization target by their keys.

Parameters:

  • language_pack_id (String)

    Language pack identifier of the strings to be returned.

  • keys (Array<String>)

    Language pack keys of the strings to be returned; leave empty to request all available strings.

Returns:



1495
1496
1497
1498
1499
# File 'lib/tdlib/client_methods.rb', line 1495

def get_language_pack_strings(language_pack_id, keys)
  broadcast('@type'            => 'getLanguagePackStrings',
            'language_pack_id' => language_pack_id,
            'keys'             => keys)
end

#get_localization_target_info(only_local = false) ⇒ TD::Types::LocalizationTargetInfo

Returns information about the current localization target. This is an offline request if only_local is true.

Parameters:

  • only_local (Boolean) (defaults to: false)

    If true, returns only locally available information without sending network requests.

Returns:



1506
1507
1508
1509
# File 'lib/tdlib/client_methods.rb', line 1506

def get_localization_target_info(only_local = false)
  broadcast('@type'      => 'getLocalizationTargetInfo',
            'only_local' => only_local)
end

#get_map_thumbnail_file(location, zoom = 13, width = 1024, height = 1024, scale = 1, chat_id: 0) ⇒ TD::Types::File

Returns information about a file with a map thumbnail in PNG format. Only map thumbnail files with size less than 1MB can be downloaded.

Parameters:

  • location (TD::Types::Location)

    Location of the map center.

  • zoom (Integer) (defaults to: 13)

    Map zoom level; 13-20.

  • width (Integer) (defaults to: 1024)

    Map width in pixels before applying scale; 16-1024.

  • height (Integer) (defaults to: 1024)

    Map height in pixels before applying scale; 16-1024.

  • scale (Integer) (defaults to: 1)

    Map scale; 1-3.

  • chat_id (Integer) (defaults to: 0)

    Identifier of a chat, in which the thumbnail will be shown. Use 0 if unknown.

Returns:



1522
1523
1524
1525
1526
1527
1528
1529
1530
# File 'lib/tdlib/client_methods.rb', line 1522

def get_map_thumbnail_file(location, zoom = 13, width = 1024, height = 1024, scale = 1, chat_id: 0)
  broadcast('@type'    => 'getMapThumbnailFile',
            'location' => location,
            'zoom'     => zoom,
            'width'    => width,
            'height'   => height,
            'scale'    => scale,
            'chat_id'  => chat_id)
end

#get_meTD::Types::User

Returns the current user.

Returns:



1535
1536
1537
# File 'lib/tdlib/client_methods.rb', line 1535

def get_me
  broadcast('@type' => 'getMe')
end

#get_message(chat_id, message_id) ⇒ TD::Types::Message

Returns information about a message.

Parameters:

  • chat_id (Integer)

    Identifier of the chat the message belongs to.

  • message_id (Integer)

    Identifier of the message to get.

Returns:



1544
1545
1546
1547
1548
# File 'lib/tdlib/client_methods.rb', line 1544

def get_message(chat_id, message_id)
  broadcast('@type'      => 'getMessage',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#get_messages(chat_id, message_ids) ⇒ TD::Types::Messages

Returns information about messages. If a message is not found, returns nil on the corresponding position of the result.

Parameters:

  • chat_id (Integer)

    Identifier of the chat the messages belong to.

  • message_ids (Array<Integer>)

    Identifiers of the messages to get.

Returns:



1556
1557
1558
1559
1560
# File 'lib/tdlib/client_methods.rb', line 1556

def get_messages(chat_id, message_ids)
  broadcast('@type'       => 'getMessages',
            'chat_id'     => chat_id,
            'message_ids' => message_ids)
end

#get_network_statistics(only_current = false) ⇒ TD::Types::NetworkStatistics

Returns network data usage statistics. Can be called before authorization.

Parameters:

  • only_current (Boolean) (defaults to: false)

    If true, returns only data for the current library launch.

Returns:



1567
1568
1569
1570
# File 'lib/tdlib/client_methods.rb', line 1567

def get_network_statistics(only_current = false)
  broadcast('@type'        => 'getNetworkStatistics',
            'only_current' => only_current)
end

#get_option(name) ⇒ TD::Types::OptionValue

Returns the value of an option by its name. Can be called before authorization.

Parameters:

  • name (String)

    The name of the option.

Returns:

See Also:



1578
1579
1580
1581
# File 'lib/tdlib/client_methods.rb', line 1578

def get_option(name)
  broadcast('@type' => 'getOption',
            'name'  => name)
end

#get_passport_authorization_form(bot_user_id, scope, public_key, nonce, password) ⇒ TD::Types::PassportAuthorizationForm

Returns a Telegram Passport authorization form for sharing data with a service.

Parameters:

  • bot_user_id (Integer)

    User identifier of the service's bot.

  • scope (String)

    Telegram Passport element types requested by the service.

  • public_key (String)

    Service's public_key.

  • nonce (String)

    Authorization form nonce provided by the service.

  • password (String)

    Password of the current user.

Returns:



1591
1592
1593
1594
1595
1596
1597
1598
# File 'lib/tdlib/client_methods.rb', line 1591

def get_passport_authorization_form(bot_user_id, scope, public_key, nonce, password)
  broadcast('@type'       => 'getPassportAuthorizationForm',
            'bot_user_id' => bot_user_id,
            'scope'       => scope,
            'public_key'  => public_key,
            'nonce'       => nonce,
            'password'    => password)
end

#get_passport_element(type, password) ⇒ TD::Types::PassportElement

Returns one of the available Telegram Passport elements.

Parameters:

Returns:



1605
1606
1607
1608
1609
# File 'lib/tdlib/client_methods.rb', line 1605

def get_passport_element(type, password)
  broadcast('@type'    => 'getPassportElement',
            'type'     => type,
            'password' => password)
end

#get_password_stateTD::Types::PasswordState

Returns the current state of 2-step verification.



1614
1615
1616
# File 'lib/tdlib/client_methods.rb', line 1614

def get_password_state
  broadcast('@type' => 'getPasswordState')
end

#get_payment_form(chat_id, message_id) ⇒ TD::Types::PaymentForm

Returns an invoice payment form. This method should be called when the user presses Types::InlineKeyboardButton::Buy.

Parameters:

  • chat_id (Integer)

    Chat identifier of the Invoice message.

  • message_id (Integer)

    Message identifier.

Returns:



1624
1625
1626
1627
1628
# File 'lib/tdlib/client_methods.rb', line 1624

def get_payment_form(chat_id, message_id)
  broadcast('@type'      => 'getPaymentForm',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#get_payment_receipt(chat_id, message_id) ⇒ TD::Types::PaymentReceipt

Returns information about a successful payment.

Parameters:

  • chat_id (Integer)

    Chat identifier of the PaymentSuccessful message.

  • message_id (Integer)

    Message identifier.

Returns:



1635
1636
1637
1638
1639
# File 'lib/tdlib/client_methods.rb', line 1635

def get_payment_receipt(chat_id, message_id)
  broadcast('@type'      => 'getPaymentReceipt',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#get_preferred_country_language(country_code) ⇒ TD::Types::Text

Returns an IETF language tag of the language preferred in the country, which should be used to fill native fields in Telegram Passport personal details. Returns a 404 error if unknown.

Parameters:

  • country_code (String)

    A two-letter ISO 3166-1 alpha-2 country code.

Returns:



1647
1648
1649
1650
# File 'lib/tdlib/client_methods.rb', line 1647

def get_preferred_country_language(country_code)
  broadcast('@type'        => 'getPreferredCountryLanguage',
            'country_code' => country_code)
end

#get_proxiesTD::Types::Proxies

Returns list of proxies that are currently set up. Can be called before authorization.

Returns:



1656
1657
1658
# File 'lib/tdlib/client_methods.rb', line 1656

def get_proxies
  broadcast('@type' => 'getProxies')
end

Returns an HTTPS link, which can be used to add a proxy. Available only for SOCKS5 and MTProto proxies. Can be called before authorization.

Parameters:

  • proxy_id (Integer)

    Proxy identifier.

Returns:



1666
1667
1668
1669
# File 'lib/tdlib/client_methods.rb', line 1666

def get_proxy_link(proxy_id)
  broadcast('@type'    => 'getProxyLink',
            'proxy_id' => proxy_id)
end

Returns a public HTTPS link to a message. Available only for messages in public supergroups and channels.

Parameters:

  • chat_id (Integer)

    Identifier of the chat to which the message belongs.

  • message_id (Integer)

    Identifier of the message.

  • for_album (Boolean) (defaults to: false)

    Pass true if a link for a whole media album should be returned.

Returns:



1678
1679
1680
1681
1682
1683
# File 'lib/tdlib/client_methods.rb', line 1678

def get_public_message_link(chat_id, message_id, for_album: false)
  broadcast('@type'      => 'getPublicMessageLink',
            'chat_id'    => chat_id,
            'message_id' => message_id,
            'for_album'  => for_album)
end

#get_recent_inline_botsTD::Types::Users

Returns up to 20 recently used inline bots in the order of their last usage.

Returns:



1688
1689
1690
# File 'lib/tdlib/client_methods.rb', line 1688

def get_recent_inline_bots
  broadcast('@type' => 'getRecentInlineBots')
end

#get_recent_stickers(is_attached = false) ⇒ TD::Types::Stickers

Returns a list of recently used stickers.

Parameters:

  • is_attached (Boolean) (defaults to: false)

    Pass true to return stickers and masks that were recently attached to photos or video files; pass false to return recently sent stickers.

Returns:



1697
1698
1699
1700
# File 'lib/tdlib/client_methods.rb', line 1697

def get_recent_stickers(is_attached = false)
  broadcast('@type'       => 'getRecentStickers',
            'is_attached' => is_attached)
end

#get_recently_visited_t_me_urls(referrer) ⇒ TD::Types::TMeUrls

Returns t.me URLs recently visited by a newly registered user.

Parameters:

  • referrer (String)

    Google Play referrer to identify the user.

Returns:



1706
1707
1708
1709
# File 'lib/tdlib/client_methods.rb', line 1706

def get_recently_visited_t_me_urls(referrer)
  broadcast('@type'    => 'getRecentlyVisitedTMeUrls',
            'referrer' => referrer)
end

#get_recovery_email_address(password) ⇒ TD::Types::RecoveryEmailAddress

Returns a recovery email address that was previously set up. This method can be used to verify a password provided by the user.

Parameters:

  • password (String)

    The password for the current user.

Returns:



1716
1717
1718
1719
# File 'lib/tdlib/client_methods.rb', line 1716

def get_recovery_email_address(password)
  broadcast('@type'    => 'getRecoveryEmailAddress',
            'password' => password)
end

#get_remote_file(remote_file_id, file_type = nil) ⇒ TD::Types::File

Returns information about a file by its remote ID; this is an offline request. Can be used to register a URL as a file for further uploading, or sending as a message.

Parameters:

  • remote_file_id (String)

    Remote identifier of the file to get.

  • file_type (TD::Types::FileType, nil) (defaults to: nil)

    File type, if known.

Returns:



1727
1728
1729
1730
1731
# File 'lib/tdlib/client_methods.rb', line 1727

def get_remote_file(remote_file_id, file_type = nil)
  broadcast('@type'          => 'getRemoteFile',
            'remote_file_id' => remote_file_id,
            'file_type'      => file_type)
end

#get_replied_message(chat_id, message_id) ⇒ TD::Types::Message

Returns information about a message that is replied by given message.

Parameters:

  • chat_id (Integer)

    Identifier of the chat the message belongs to.

  • message_id (Integer)

    Identifier of the message reply to which get.

Returns:



1738
1739
1740
1741
1742
# File 'lib/tdlib/client_methods.rb', line 1738

def get_replied_message(chat_id, message_id)
  broadcast('@type'      => 'getRepliedMessage',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#get_saved_animationsTD::Types::Animations

Returns saved animations.



1747
1748
1749
# File 'lib/tdlib/client_methods.rb', line 1747

def get_saved_animations
  broadcast('@type' => 'getSavedAnimations')
end

#get_saved_order_infoTD::Types::OrderInfo

Returns saved order info, if any.



1754
1755
1756
# File 'lib/tdlib/client_methods.rb', line 1754

def get_saved_order_info
  broadcast('@type' => 'getSavedOrderInfo')
end

#get_scope_notification_settings(scope) ⇒ TD::Types::ScopeNotificationSettings

Returns the notification settings for chats of a given type.

Parameters:

Returns:



1763
1764
1765
1766
# File 'lib/tdlib/client_methods.rb', line 1763

def get_scope_notification_settings(scope)
  broadcast('@type' => 'getScopeNotificationSettings',
            'scope' => scope)
end

#get_secret_chat(secret_chat_id) ⇒ TD::Types::SecretChat

Returns information about a secret chat by its identifier. This is an offline request.

Parameters:

  • secret_chat_id (Integer)

    Secret chat identifier.

Returns:



1773
1774
1775
1776
# File 'lib/tdlib/client_methods.rb', line 1773

def get_secret_chat(secret_chat_id)
  broadcast('@type'          => 'getSecretChat',
            'secret_chat_id' => secret_chat_id)
end

#get_sticker_emojis(sticker) ⇒ TD::Types::StickerEmojis

Returns emoji corresponding to a sticker.

Parameters:

Returns:



1782
1783
1784
1785
# File 'lib/tdlib/client_methods.rb', line 1782

def get_sticker_emojis(sticker)
  broadcast('@type'   => 'getStickerEmojis',
            'sticker' => sticker)
end

#get_sticker_set(set_id) ⇒ TD::Types::StickerSet

Returns information about a sticker set by its identifier.

Parameters:

  • set_id (Integer)

    Identifier of the sticker set.

Returns:



1791
1792
1793
1794
# File 'lib/tdlib/client_methods.rb', line 1791

def get_sticker_set(set_id)
  broadcast('@type'  => 'getStickerSet',
            'set_id' => set_id)
end

#get_stickers(emoji, limit = 100) ⇒ TD::Types::Stickers

Returns stickers from the installed sticker sets that correspond to a given emoji. If the emoji is not empty, favorite and recently used stickers may also be returned.

Parameters:

  • emoji (String)

    String representation of emoji. If empty, returns all known installed stickers.

  • limit (Integer) (defaults to: 100)

    Maximum number of stickers to be returned.

Returns:



1803
1804
1805
1806
1807
# File 'lib/tdlib/client_methods.rb', line 1803

def get_stickers(emoji, limit = 100)
  broadcast('@type' => 'getStickers',
            'emoji' => emoji,
            'limit' => limit)
end

#get_storage_statistics(chat_limit) ⇒ TD::Types::StorageStatistics

Returns storage usage statistics.

Parameters:

  • chat_limit (Integer)

    Maximum number of chats with the largest storage usage for which separate statistics should be returned. All other chats will be grouped in entries with chat_id == 0. If the chat info database is not used, the chat_limit is ignored and is always set to 0.

Returns:



1816
1817
1818
1819
# File 'lib/tdlib/client_methods.rb', line 1816

def get_storage_statistics(chat_limit)
  broadcast('@type'      => 'getStorageStatistics',
            'chat_limit' => chat_limit)
end

#get_storage_statistics_fastTD::Types::StorageStatisticsFast

Quickly returns approximate storage usage statistics.



1824
1825
1826
# File 'lib/tdlib/client_methods.rb', line 1824

def get_storage_statistics_fast
  broadcast('@type' => 'getStorageStatisticsFast')
end

#get_supergroup(supergroup_id) ⇒ TD::Types::Supergroup

Returns information about a supergroup or channel by its identifier. This is an offline request if the current user is not a bot.

Parameters:

  • supergroup_id (Integer)

    Supergroup or channel identifier.

Returns:



1833
1834
1835
1836
# File 'lib/tdlib/client_methods.rb', line 1833

def get_supergroup(supergroup_id)
  broadcast('@type'         => 'getSupergroup',
            'supergroup_id' => supergroup_id)
end

#get_supergroup_full_info(supergroup_id) ⇒ TD::Types::SupergroupFullInfo

Returns full information about a supergroup or channel by its identifier, cached for up to 1 minute.

Parameters:

  • supergroup_id (Integer)

    Supergroup or channel identifier.

Returns:



1842
1843
1844
1845
# File 'lib/tdlib/client_methods.rb', line 1842

def get_supergroup_full_info(supergroup_id)
  broadcast('@type'         => 'getSupergroupFullInfo',
            'supergroup_id' => supergroup_id)
end

#get_supergroup_members(supergroup_id, filter, offset, limit) ⇒ TD::Types::ChatMembers

Returns information about members or banned users in a supergroup or channel. Can be used only if SupergroupFullInfo.can_get_members == true; additionally, administrator privileges may be required for some filters.

Parameters:

Returns:



1857
1858
1859
1860
1861
1862
1863
# File 'lib/tdlib/client_methods.rb', line 1857

def get_supergroup_members(supergroup_id, filter, offset, limit)
  broadcast('@type'         => 'getSupergroupMembers',
            'supergroup_id' => supergroup_id,
            'filter'        => filter,
            'offset'        => offset,
            'limit'         => limit)
end

#get_support_userTD::Types::User

Returns a user that can be contacted to get support.

Returns:



1868
1869
1870
# File 'lib/tdlib/client_methods.rb', line 1868

def get_support_user
  broadcast('@type' => 'getSupportUser')
end

#get_temporary_password_stateTD::Types::TemporaryPasswordState

Returns information about the current temporary password.



1875
1876
1877
# File 'lib/tdlib/client_methods.rb', line 1875

def get_temporary_password_state
  broadcast('@type' => 'getTemporaryPasswordState')
end

#get_text_entities(text) ⇒ TD::Types::TextEntities

Returns all entities (mentions, hashtags, cashtags, bot commands, URLs, and email addresses) contained in the text. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

  • text (String)

    The text in which to look for entites.

Returns:



1886
1887
1888
1889
# File 'lib/tdlib/client_methods.rb', line 1886

def get_text_entities(text)
  broadcast('@type' => 'getTextEntities',
            'text'  => text)
end

#get_top_chats(category, limit = 30) ⇒ TD::Types::Chats

Returns a list of frequently used chats. Supported only if the chat info database is enabled.

Parameters:

  • category (TD::Types::TopChatCategory)

    Category of chats to be returned.

  • limit (Integer) (defaults to: 30)

    Maximum number of chats to be returned; up to 30.

Returns:



1897
1898
1899
1900
1901
# File 'lib/tdlib/client_methods.rb', line 1897

def get_top_chats(category, limit = 30)
  broadcast('@type'    => 'getTopChats',
            'category' => category,
            'limit'    => limit)
end

Returns a list of trending sticker sets.



1906
1907
1908
# File 'lib/tdlib/client_methods.rb', line 1906

def get_trending_sticker_sets
  broadcast('@type' => 'getTrendingStickerSets')
end

#get_user(user_id) ⇒ TD::Types::User

Returns information about a user by their identifier. This is an offline request if the current user is not a bot.

Parameters:

  • user_id (Integer)

    User identifier.

Returns:



1915
1916
1917
1918
# File 'lib/tdlib/client_methods.rb', line 1915

def get_user(user_id)
  broadcast('@type'   => 'getUser',
            'user_id' => user_id)
end

#get_user_full_info(user_id) ⇒ TD::Types::UserFullInfo

Returns full information about a user by their identifier.

Parameters:

  • user_id (Integer)

    User identifier.

Returns:



1924
1925
1926
1927
# File 'lib/tdlib/client_methods.rb', line 1924

def get_user_full_info(user_id)
  broadcast('@type'   => 'getUserFullInfo',
            'user_id' => user_id)
end

#get_user_privacy_setting_rules(setting) ⇒ TD::Types::UserPrivacySettingRules

Returns the current privacy settings.

Parameters:

Returns:



1933
1934
1935
1936
# File 'lib/tdlib/client_methods.rb', line 1933

def get_user_privacy_setting_rules(setting)
  broadcast('@type'   => 'getUserPrivacySettingRules',
            'setting' => setting)
end

#get_user_profile_photos(user_id, offset = 0, limit = 100) ⇒ TD::Types::UserProfilePhotos

Returns the profile photos of a user. The result of this query may be outdated: some photos might have been deleted already.

Parameters:

  • user_id (Integer)

    User identifier.

  • offset (Integer) (defaults to: 0)

    The number of photos to skip; must be non-negative.

  • limit (Integer) (defaults to: 100)

    Maximum number of photos to be returned; up to 100.

Returns:



1945
1946
1947
1948
1949
1950
# File 'lib/tdlib/client_methods.rb', line 1945

def (user_id, offset = 0, limit = 100)
  broadcast('@type'   => 'getUserProfilePhotos',
            'user_id' => user_id,
            'offset'  => offset,
            'limit'   => limit)
end

#get_wallpapersTD::Types::Wallpapers

Returns background wallpapers.



1955
1956
1957
# File 'lib/tdlib/client_methods.rb', line 1955

def get_wallpapers
  broadcast('@type' => 'getWallpapers')
end

#get_web_page_instant_view(url, force_full = false) ⇒ TD::Types::WebPageInstantView

Returns an instant view version of a web page if available. Returns a 404 error if the web page has no instant view page.

Parameters:

  • url (String)

    The web page URL.

  • force_full (Boolean) (defaults to: false)

    If true, the full instant view for the web page will be returned.

Returns:



1965
1966
1967
1968
1969
# File 'lib/tdlib/client_methods.rb', line 1965

def get_web_page_instant_view(url, force_full = false)
  broadcast('@type'      => 'getWebPageInstantView',
            'url'        => url,
            'force_full' => force_full)
end

#get_web_page_preview(text) ⇒ TD::Types::WebPage

Returns a web page preview by the text of the message. Do not call this function too often. Returns a 404 error if the web page has no preview.

Parameters:

Returns:



1977
1978
1979
1980
# File 'lib/tdlib/client_methods.rb', line 1977

def get_web_page_preview(text)
  broadcast('@type' => 'getWebPagePreview',
            'text'  => text)
end

#import_contacts(contacts) ⇒ TD::Types::ImportedContacts

Adds new contacts or edits existing contacts; contacts' user identifiers are ignored.

Parameters:

  • contacts (Array<TD::Types::Contact>)

    The list of contacts to import or edit, contact's vCard are ignored and are not imported.

Returns:



1987
1988
1989
1990
# File 'lib/tdlib/client_methods.rb', line 1987

def import_contacts(contacts)
  broadcast('@type'    => 'importContacts',
            'contacts' => contacts)
end

#join_chat(chat_id) ⇒ TD::Types::Ok

Adds current user as a new member to a chat. Private and secret chats can't be joined using this method.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



1997
1998
1999
2000
# File 'lib/tdlib/client_methods.rb', line 1997

def join_chat(chat_id)
  broadcast('@type'   => 'joinChat',
            'chat_id' => chat_id)
end

Uses an invite link to add the current user to the chat if possible. The new member will not be added until the chat state has been synchronized with the server.

Parameters:

Returns:



2008
2009
2010
2011
# File 'lib/tdlib/client_methods.rb', line 2008

def join_chat_by_invite_link(invite_link)
  broadcast('@type'       => 'joinChatByInviteLink',
            'invite_link' => invite_link)
end

#leave_chat(chat_id) ⇒ TD::Types::Ok

Removes current user from chat members. Private and secret chats can't be left using this method.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



2018
2019
2020
2021
# File 'lib/tdlib/client_methods.rb', line 2018

def leave_chat(chat_id)
  broadcast('@type'   => 'leaveChat',
            'chat_id' => chat_id)
end

#log_outTD::Types::Ok

Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be destroyed. After the logout completes, Types::Update::AuthorizationState with Types::AuthorizationState::Closed will be sent.

Returns:



2030
2031
2032
# File 'lib/tdlib/client_methods.rb', line 2030

def log_out
  broadcast('@type' => 'logOut')
end

#open_chat(chat_id) ⇒ TD::Types::Ok

This method should be called if the chat is opened by the user. Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are received only for opened chats).

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



2040
2041
2042
2043
# File 'lib/tdlib/client_methods.rb', line 2040

def open_chat(chat_id)
  broadcast('@type'   => 'openChat',
            'chat_id' => chat_id)
end

#open_message_content(chat_id, message_id) ⇒ TD::Types::Ok

This method should be called if the message content has been opened (e.g., the user has opened a photo, video, document, location or venue, or has listened to an audio file or voice note message). An Types::Update::MessageContentOpened will be generated if something has changed.

Parameters:

  • chat_id (Integer)

    Chat identifier of the message.

  • message_id (Integer)

    Identifier of the message with the opened content.

Returns:



2052
2053
2054
2055
2056
# File 'lib/tdlib/client_methods.rb', line 2052

def open_message_content(chat_id, message_id)
  broadcast('@type'      => 'openMessageContent',
            'chat_id'    => chat_id,
            'message_id' => message_id)
end

#optimize_storage(size: -1,, ttl: -1,, count: -1,, immunity_delay: -1,, file_types: nil, chat_ids: nil, exclude_chat_ids: nil, chat_limit: nil) ⇒ TD::Types::StorageStatistics

Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics. Secret thumbnails can't be deleted.

Parameters:

  • size (Integer) (defaults to: -1,)

    Limit on the total size of files after deletion. Pass -1 to use the default limit.

  • ttl (Integer) (defaults to: -1,)

    Limit on the time that has passed since the last time a file was accessed (or creation time for some filesystems). Pass -1 to use the default limit.

  • count (Integer) (defaults to: -1,)

    Limit on the total count of files after deletion. Pass -1 to use the default limit.

  • immunity_delay (Integer) (defaults to: -1,)

    The amount of time after the creation of a file during which it can't be deleted, in seconds. Pass -1 to use the default value.

  • file_types (Array<TD::Types::FileType>, nil) (defaults to: nil)

    If not empty, only files with the given type(s) are considered. By default, all types except thumbnails, profile photos, stickers and wallpapers are deleted.

  • chat_ids (Array<Integer>, nil) (defaults to: nil)

    If not empty, only files from the given chats are considered. Use 0 as chat identifier to delete files not belonging to any chat (e.g., profile photos).

  • exclude_chat_ids (Array<Integer>, nil) (defaults to: nil)

    If not empty, files from the given chats are excluded. Use 0 as chat identifier to exclude all files not belonging to any chat (e.g., profile photos).

  • chat_limit (Integer, nil) (defaults to: nil)

    Same as in #get_storage_statistics. Affects only returned statistics.

Returns:



2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
# File 'lib/tdlib/client_methods.rb', line 2080

def optimize_storage(size: -1, ttl: -1, count: -1, immunity_delay: -1,
                     file_types: nil, chat_ids: nil, exclude_chat_ids: nil, chat_limit: nil)
  broadcast('@type'            => 'optimizeStorage',
            'size'             => size,
            'ttl'              => ttl,
            'count'            => count,
            'immunity_delay'   => immunity_delay,
            'file_types'       => file_types,
            'chat_ids'         => chat_ids,
            'exclude_chat_ids' => exclude_chat_ids,
            'chat_limit'       => chat_limit)
end

#parse_text_entities(text, parse_mode) ⇒ TD::Types::FormattedText

Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text. This is an offline method. Can be called before authorization. Can be called synchronously.

Parameters:

Returns:



2101
2102
2103
2104
2105
# File 'lib/tdlib/client_methods.rb', line 2101

def parse_text_entities(text, parse_mode)
  broadcast('@type'      => 'parseTextEntities',
            'text'       => text,
            'parse_mode' => parse_mode)
end

#pin_supergroup_message(supergroup_id, message_id, disable_notification: false) ⇒ TD::Types::Ok

Pins a message in a supergroup or channel; requires appropriate administrator rights in the supergroup or channel.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup or channel.

  • message_id (Integer)

    Identifier of the new pinned message.

  • disable_notification (Boolean) (defaults to: false)

    True, if there should be no notification about the pinned message.

Returns:



2113
2114
2115
2116
2117
2118
# File 'lib/tdlib/client_methods.rb', line 2113

def pin_supergroup_message(supergroup_id, message_id, disable_notification: false)
  broadcast('@type'                => 'pinSupergroupMessage',
            'supergroup_id'        => supergroup_id,
            'message_id'           => message_id,
            'disable_notification' => disable_notification)
end

#ping_proxy(proxy_id) ⇒ TD::Types::Seconds

Computes time needed to receive a response from a Telegram server through a proxy. Can be called before authorization.

Parameters:

  • proxy_id (Integer)

    Proxy identifier. Use 0 to ping a Telegram server without a proxy.

Returns:



2126
2127
2128
2129
# File 'lib/tdlib/client_methods.rb', line 2126

def ping_proxy(proxy_id)
  broadcast('@type'    => 'pingProxy',
            'proxy_id' => proxy_id)
end

#process_dc_update(dc, addr) ⇒ TD::Types::Ok

Handles a DC_UPDATE push service notification. Can be called before authorization.

Parameters:

  • dc (String)

    Value of the "dc" parameter of the notification.

  • addr (String)

    Value of the "addr" parameter of the notification.

Returns:



2137
2138
2139
2140
2141
# File 'lib/tdlib/client_methods.rb', line 2137

def process_dc_update(dc, addr)
  broadcast('@type' => 'processDcUpdate',
            'dc'    => dc,
            'addr'  => addr)
end

#read_all_chat_mentions(chat_id) ⇒ TD::Types::Ok

Marks all mentions in a chat as read.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



2147
2148
2149
2150
# File 'lib/tdlib/client_methods.rb', line 2147

def read_all_chat_mentions(chat_id)
  broadcast('@type'   => 'readAllChatMentions',
            'chat_id' => chat_id)
end

#recover_authentication_password(recovery_code) ⇒ TD::Types::Ok

Recovers the password with a password recovery code sent to an email address that was previously set up. Works only when the current authorization state is Types::AuthorizationState::WaitPassword.

Parameters:

  • recovery_code (String)

    Recovery code to check.

Returns:



2157
2158
2159
2160
# File 'lib/tdlib/client_methods.rb', line 2157

def recover_authentication_password(recovery_code)
  broadcast('@type'         => 'recoverAuthenticationPassword',
            'recovery_code' => recovery_code)
end

#recover_password(recovery_code) ⇒ TD::Types::PasswordState

Recovers the password using a recovery code sent to an email address that was previously set up.

Parameters:

  • recovery_code (String)

    Recovery code to check.

Returns:



2166
2167
2168
2169
# File 'lib/tdlib/client_methods.rb', line 2166

def recover_password(recovery_code)
  broadcast('@type'         => 'recoverPassword',
            'recovery_code' => recovery_code)
end

#register_device(device_token, other_user_ids = []) ⇒ TD::Types::Ok

Registers the currently used device for receiving push notifications.

Parameters:

  • device_token (TD::Types::DeviceToken)

    Device token.

  • other_user_ids (Array<Integer>) (defaults to: [])

    List of at most 100 user identifiers of other users currently using the client.

Returns:



2177
2178
2179
2180
2181
# File 'lib/tdlib/client_methods.rb', line 2177

def register_device(device_token, other_user_ids = [])
  broadcast('@type'          => 'registerDevice',
            'device_token'   => device_token,
            'other_user_ids' => other_user_ids)
end

#remove_contacts(user_ids) ⇒ TD::Types::Ok

Removes users from the contacts list.

Parameters:

  • user_ids (Array<Integer>)

    Identifiers of users to be deleted.

Returns:



2187
2188
2189
2190
# File 'lib/tdlib/client_methods.rb', line 2187

def remove_contacts(user_ids)
  broadcast('@type'    => 'removeContacts',
            'user_ids' => user_ids)
end

#remove_favorite_sticker(sticker) ⇒ TD::Types::Ok

Removes a sticker from the list of favorite stickers.

Parameters:

Returns:



2196
2197
2198
2199
# File 'lib/tdlib/client_methods.rb', line 2196

def remove_favorite_sticker(sticker)
  broadcast('@type'   => 'removeFavoriteSticker',
            'sticker' => sticker)
end

#remove_proxy(proxy_id) ⇒ TD::Types::Ok

Removes a proxy server. Can be called before authorization.

Parameters:

  • proxy_id (Integer)

    Proxy identifier.

Returns:



2206
2207
2208
2209
# File 'lib/tdlib/client_methods.rb', line 2206

def remove_proxy(proxy_id)
  broadcast('@type'    => 'removeProxy',
            'proxy_id' => proxy_id)
end

#remove_recent_hashtag(hashtag) ⇒ TD::Types::Ok

Removes a hashtag from the list of recently used hashtags.

Parameters:

  • hashtag (String)

    Hashtag to delete.

Returns:



2215
2216
2217
2218
# File 'lib/tdlib/client_methods.rb', line 2215

def remove_recent_hashtag(hashtag)
  broadcast('@type'   => 'removeRecentHashtag',
            'hashtag' => hashtag)
end

#remove_recent_sticker(sticker, is_attached: false) ⇒ TD::Types::Ok

Removes a sticker from the list of recently used stickers.

Parameters:

  • is_attached (Boolean) (defaults to: false)

    Pass true to remove the sticker from the list of stickers recently attached to photo or video files; pass false to remove the sticker from the list of recently sent stickers.

  • sticker (TD::Types::InputFile)

    Sticker file to delete.

Returns:



2226
2227
2228
2229
2230
# File 'lib/tdlib/client_methods.rb', line 2226

def remove_recent_sticker(sticker, is_attached: false)
  broadcast('@type'       => 'removeRecentSticker',
            'is_attached' => is_attached,
            'sticker'     => sticker)
end

#remove_recently_found_chat(chat_id) ⇒ TD::Types::Ok

Removes a chat from the list of recently found chats.

Parameters:

  • chat_id (Integer)

    Identifier of the chat to be removed.

Returns:



2236
2237
2238
2239
# File 'lib/tdlib/client_methods.rb', line 2236

def remove_recently_found_chat(chat_id)
  broadcast('@type'   => 'removeRecentlyFoundChat',
            'chat_id' => chat_id)
end

#remove_saved_animation(animation) ⇒ TD::Types::Ok

Removes an animation from the list of saved animations.

Parameters:

Returns:



2245
2246
2247
2248
# File 'lib/tdlib/client_methods.rb', line 2245

def remove_saved_animation(animation)
  broadcast('@type'     => 'removeSavedAnimation',
            'animation' => animation)
end

#remove_sticker_from_set(sticker) ⇒ TD::Types::Ok

Removes a sticker from the set to which it belongs; for bots only. The sticker set must have been created by the bot.

Parameters:

Returns:



2255
2256
2257
2258
# File 'lib/tdlib/client_methods.rb', line 2255

def remove_sticker_from_set(sticker)
  broadcast('@type'   => 'removeStickerFromSet',
            'sticker' => sticker)
end

#remove_top_chat(category, chat_id) ⇒ TD::Types::Ok

Removes a chat from the list of frequently used chats. Supported only if the chat info database is enabled.

Parameters:

Returns:



2266
2267
2268
2269
2270
# File 'lib/tdlib/client_methods.rb', line 2266

def remove_top_chat(category, chat_id)
  broadcast('@type'    => 'removeTopChat',
            'category' => category,
            'chat_id'  => chat_id)
end

#reorder_installed_sticker_sets(sticker_set_ids, is_masks: false) ⇒ TD::Types::Ok

Changes the order of installed sticker sets.

Parameters:

  • is_masks (Boolean) (defaults to: false)

    Pass true to change the order of mask sticker sets; pass false to change the order of ordinary sticker sets.

  • sticker_set_ids (Array<Integer>)

    Identifiers of installed sticker sets in the new correct order.

Returns:



2278
2279
2280
2281
2282
# File 'lib/tdlib/client_methods.rb', line 2278

def reorder_installed_sticker_sets(sticker_set_ids, is_masks: false)
  broadcast('@type'           => 'reorderInstalledStickerSets',
            'is_masks'        => is_masks,
            'sticker_set_ids' => sticker_set_ids)
end

#report_chat(chat_id, reason, message_ids = []) ⇒ TD::Types::Ok

Reports a chat to the Telegram moderators. Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by moderators.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • reason (TD::Types::ChatReportReason)

    The reason for reporting the chat.

  • message_ids (Array<Integer>) (defaults to: [])

    Identifiers of reported messages, if any.

Returns:



2292
2293
2294
2295
2296
2297
# File 'lib/tdlib/client_methods.rb', line 2292

def report_chat(chat_id, reason, message_ids = [])
  broadcast('@type'       => 'reportChat',
            'chat_id'     => chat_id,
            'reason'      => reason,
            'message_ids' => message_ids)
end

#report_supergroup_spam(supergroup_id, user_id, message_ids = []) ⇒ TD::Types::Ok

Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup.

Parameters:

  • supergroup_id (Integer)

    Supergroup identifier.

  • user_id (Integer)

    User identifier.

  • message_ids (Array<Integer>) (defaults to: [])

    Identifiers of messages sent in the supergroup by the user. This list must be non-empty.

Returns:



2306
2307
2308
2309
2310
2311
# File 'lib/tdlib/client_methods.rb', line 2306

def report_supergroup_spam(supergroup_id, user_id, message_ids = [])
  broadcast('@type'         => 'reportSupergroupSpam',
            'supergroup_id' => supergroup_id,
            'user_id'       => user_id,
            'message_ids'   => message_ids)
end

#request_authentication_password_recoveryTD::Types::Ok

Requests to send a password recovery code to an email address that was previously set up. Works only when the current authorization state is Types::AuthorizationState::WaitPassword.

Returns:



2317
2318
2319
# File 'lib/tdlib/client_methods.rb', line 2317

def request_authentication_password_recovery
  broadcast('@type' => 'requestAuthenticationPasswordRecovery')
end

#request_password_recoveryTD::Types::EmailAddressAuthenticationCodeInfo

Requests to send a password recovery code to an email address that was previously set up.



2324
2325
2326
# File 'lib/tdlib/client_methods.rb', line 2324

def request_password_recovery
  broadcast('@type' => 'requestPasswordRecovery')
end

#resend_authentication_codeTD::Types::Ok

Re-sends an authentication code to the user. Works only when the current authorization state is Types::AuthorizationState::WaitCode and the Types::AuthenticationCodeInfo#next_type of the result is not nil.

Returns:



2333
2334
2335
# File 'lib/tdlib/client_methods.rb', line 2333

def resend_authentication_code
  broadcast('@type' => 'resendAuthenticationCode')
end

#resend_change_phone_number_codeTD::Types::AuthenticationCodeInfo

Re-sends the authentication code sent to confirm a new phone number for the user. Works only if the previously received Types::AuthenticationCodeInfo#next_type was not nil.



2341
2342
2343
# File 'lib/tdlib/client_methods.rb', line 2341

def resend_change_phone_number_code
  broadcast('@type' => 'resendChangePhoneNumberCode')
end

#resend_email_address_verification_codeTD::Types::EmailAddressAuthenticationCodeInfo

Re-sends the code to verify an email address to be added to a user's Telegram Passport.



2348
2349
2350
# File 'lib/tdlib/client_methods.rb', line 2348

def resend_email_address_verification_code
  broadcast('@type' => 'resendEmailAddressVerificationCode')
end

#resend_phone_number_confirmation_codeTD::Types::AuthenticationCodeInfo

Resends phone number confirmation code.



2355
2356
2357
# File 'lib/tdlib/client_methods.rb', line 2355

def resend_phone_number_confirmation_code
  broadcast('@type' => 'resendPhoneNumberConfirmationCode')
end

#resend_phone_number_verification_codeTD::Types::AuthenticationCodeInfo

Re-sends the code to verify a phone number to be added to a user's Telegram Passport.



2362
2363
2364
# File 'lib/tdlib/client_methods.rb', line 2362

def resend_phone_number_verification_code
  broadcast('@type' => 'resendPhoneNumberVerificationCode')
end

#reset_all_notification_settingsTD::Types::Ok

Resets all notification settings to their default values. By default, all chats are unmuted, the sound is set to "default" and message previews are shown.

Returns:



2370
2371
2372
# File 'lib/tdlib/client_methods.rb', line 2370

def reset_all_notification_settings
  broadcast('@type' => 'resetAllNotificationSettings')
end

#reset_network_statisticsTD::Types::Ok

Resets all network data usage statistics to zero. Can be called before authorization.

Returns:



2378
2379
2380
# File 'lib/tdlib/client_methods.rb', line 2378

def reset_network_statistics
  broadcast('@type' => 'resetNetworkStatistics')
end

#search_call_messages(from_message_id, limit = 100, only_missed: false) ⇒ TD::Types::Messages

Searches for call messages. Returns the results in reverse chronological order (i.e., in order of decreasing message_id). For optimal performance the number of returned messages is chosen by the library.

Parameters:

  • from_message_id (Integer)

    Identifier of the message from which to search; use 0 to get results from the last message.

  • limit (Integer) (defaults to: 100)

    The maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached.

  • only_missed (Boolean) (defaults to: false)

    If true, returns only messages with missed calls.

Returns:



2393
2394
2395
2396
2397
2398
# File 'lib/tdlib/client_methods.rb', line 2393

def search_call_messages(from_message_id, limit = 100, only_missed: false)
  broadcast('@type'           => 'searchCallMessages',
            'from_message_id' => from_message_id,
            'limit'           => limit,
            'only_missed'     => only_missed)
end

#search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFilter::Members.new) ⇒ TD::Types::ChatMembers

Searches for a specified query in the first name, last name and username of the members of a specified chat. Requires administrator rights in channels.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • query (String, nil) (defaults to: nil)

    Query to search for.

  • limit (Integer) (defaults to: 100)

    The maximum number of users to be returned.

  • filter (TD::Types::ChatMembersFilter) (defaults to: ChatMembersFilter::Members.new)

    The type of users to return. By default, Types::ChatMembersFilter::Members.

Returns:



2409
2410
2411
2412
2413
2414
2415
# File 'lib/tdlib/client_methods.rb', line 2409

def search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFilter::Members.new)
  broadcast('@type'   => 'searchChatMembers',
            'chat_id' => chat_id,
            'query'   => query,
            'limit'   => limit,
            'filter'  => filter)
end

#search_chat_messages(chat_id, offset = 0, limit = 100, query: nil, sender_user_id: 0, from_message_id: 0, filter: SearchMessagesFilter::Empty.new) ⇒ TD::Types::Messages

Searches for messages with given words in the chat. Returns the results in reverse chronological order, i.e. in order of decreasing message_id. Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an enabled message database. For optimal performance the number of returned messages is chosen by the library.

Parameters:

  • chat_id (Integer)

    Identifier of the chat in which to search messages.

  • query (String, nil) (defaults to: nil)

    Query to search for.

  • sender_user_id (Integer) (defaults to: 0)

    If not 0, only messages sent by the specified user will be returned. Not supported in secret chats.

  • from_message_id (Integer) (defaults to: 0)

    Identifier of the message starting from which history must be fetched; use 0 to get results from the last message.

  • offset (Integer) (defaults to: 0)

    Specify 0 to get results from exactly the from_message_id or a negative offset to get the specified message and some newer messages.

  • limit (Integer) (defaults to: 100)

    The maximum number of messages to be returned; must be positive and can't be greater than 100. If the offset is negative, the limit must be greater than -offset. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached.

  • filter (TD::Types::SearchMessagesFilter) (defaults to: SearchMessagesFilter::Empty.new)

    Filter for message content in the search results.

Returns:



2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
# File 'lib/tdlib/client_methods.rb', line 2438

def search_chat_messages(chat_id, offset = 0, limit = 100,
                         query: nil, sender_user_id: 0, from_message_id: 0, filter: SearchMessagesFilter::Empty.new)
  broadcast('@type'           => 'searchChatMessages',
            'chat_id'         => chat_id,
            'query'           => query,
            'sender_user_id'  => sender_user_id,
            'from_message_id' => from_message_id,
            'offset'          => offset,
            'limit'           => limit,
            'filter'          => filter)
end

#search_chat_recent_location_messages(chat_id, limit = 100) ⇒ TD::Types::Messages

Returns information about the recent locations of chat members that were sent to the chat. Returns up to 1 location message per user.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • limit (Integer) (defaults to: 100)

    Maximum number of messages to be returned.

Returns:



2456
2457
2458
2459
2460
# File 'lib/tdlib/client_methods.rb', line 2456

def search_chat_recent_location_messages(chat_id, limit = 100)
  broadcast('@type'   => 'searchChatRecentLocationMessages',
            'chat_id' => chat_id,
            'limit'   => limit)
end

#search_chats(query = nil, limit = 100) ⇒ TD::Types::Chats

Searches for the specified query in the title and username of already known chats, this is an offline request. Returns chats in the order seen in the chat list.

Parameters:

  • query (String, nil) (defaults to: nil)

    Query to search for. If the query is empty, returns up to 20 recently found chats.

  • limit (Integer) (defaults to: 100)

    Maximum number of chats to be returned.

Returns:



2469
2470
2471
2472
2473
# File 'lib/tdlib/client_methods.rb', line 2469

def search_chats(query = nil, limit = 100)
  broadcast('@type' => 'searchChats',
            'query' => query,
            'limit' => limit)
end

#search_chats_on_server(query, limit = 100) ⇒ TD::Types::Chats

Searches for the specified query in the title and username of already known chats via request to the server. Returns chats in the order seen in the chat list.

Parameters:

  • query (String)

    Query to search for.

  • limit (Integer) (defaults to: 100)

    Maximum number of chats to be returned.

Returns:



2481
2482
2483
2484
2485
# File 'lib/tdlib/client_methods.rb', line 2481

def search_chats_on_server(query, limit = 100)
  broadcast('@type' => 'searchChatsOnServer',
            'query' => query,
            'limit' => limit)
end

#search_contacts(query = nil, limit = 100) ⇒ TD::Types::Users

Searches for the specified query in the first names, last names and usernames of the known user contacts.

Parameters:

  • query (String, nil) (defaults to: nil)

    Query to search for; can be empty to return all contacts.

  • limit (Integer) (defaults to: 100)

    Maximum number of users to be returned.

Returns:



2492
2493
2494
2495
2496
# File 'lib/tdlib/client_methods.rb', line 2492

def search_contacts(query = nil, limit = 100)
  broadcast('@type' => 'searchContacts',
            'query' => query,
            'limit' => limit)
end

#search_hashtags(prefix = nil, limit = 100) ⇒ TD::Types::Hashtags

Searches for recently used hashtags by their prefix.

Parameters:

  • prefix (String, nil) (defaults to: nil)

    Hashtag prefix to search for.

  • limit (Integer) (defaults to: 100)

    Maximum number of hashtags to be returned.

Returns:



2503
2504
2505
2506
2507
# File 'lib/tdlib/client_methods.rb', line 2503

def search_hashtags(prefix = nil, limit = 100)
  broadcast('@type'  => 'searchHashtags',
            'prefix' => prefix,
            'limit'  => limit)
end

#search_installed_sticker_sets(query = nil, limit = 100, is_masks: false) ⇒ TD::Types::StickerSets

Searches for installed sticker sets by looking for specified query in their title and name.

Parameters:

  • is_masks (Boolean) (defaults to: false)

    Pass true to return mask sticker sets; pass false to return ordinary sticker sets.

  • query (String, nil) (defaults to: nil)

    Query to search for.

  • limit (Integer) (defaults to: 100)

    Maximum number of sticker sets to return.

Returns:



2515
2516
2517
2518
2519
2520
# File 'lib/tdlib/client_methods.rb', line 2515

def search_installed_sticker_sets(query = nil, limit = 100, is_masks: false)
  broadcast('@type'    => 'searchInstalledStickerSets',
            'is_masks' => is_masks,
            'query'    => query,
            'limit'    => limit)
end

#search_messages(query, limit = 100, offset_date: 0, offset_chat_id: 0, offset_message_id: 0) ⇒ TD::Types::Messages

Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). For optimal performance the number of returned messages is chosen by the library.

Parameters:

  • query (String)

    Query to search for.

  • offset_date (Integer) (defaults to: 0)

    The date of the message starting from which the results should be fetched. Use 0 or any date in the future to get results from the last message.

  • offset_chat_id (Integer) (defaults to: 0)

    The chat identifier of the last found message, or 0 for the first request.

  • offset_message_id (Integer) (defaults to: 0)

    The message identifier of the last found message, or 0 for the first request.

  • limit (Integer) (defaults to: 100)

    The maximum number of messages to be returned, up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached.

Returns:



2535
2536
2537
2538
2539
2540
2541
2542
# File 'lib/tdlib/client_methods.rb', line 2535

def search_messages(query, limit = 100, offset_date: 0, offset_chat_id: 0, offset_message_id: 0)
  broadcast('@type'             => 'searchMessages',
            'query'             => query,
            'offset_date'       => offset_date,
            'offset_chat_id'    => offset_chat_id,
            'offset_message_id' => offset_message_id,
            'limit'             => limit)
end

#search_public_chat(username) ⇒ TD::Types::Chat

Searches a public chat by its username. Currently only private chats, supergroups and channels can be public. Returns the chat if found; otherwise an error is returned.

Parameters:

  • username (String)

    Username to be resolved.

Returns:



2550
2551
2552
2553
# File 'lib/tdlib/client_methods.rb', line 2550

def search_public_chat(username)
  broadcast('@type'    => 'searchPublicChat',
            'username' => username)
end

#search_public_chats(query) ⇒ TD::Types::Chats

Searches public chats by looking for specified query in their username and title. Currently only private chats, supergroups and channels can be public. Returns a meaningful number of results. Returns nothing if the length of the searched username prefix is less than 5. Excludes private chats with contacts and chats from the chat list from the results.

Parameters:

  • query (String)

    Query to search for.

Returns:



2563
2564
2565
2566
# File 'lib/tdlib/client_methods.rb', line 2563

def search_public_chats(query)
  broadcast('@type' => 'searchPublicChats',
            'query' => query)
end

#search_secret_messages(chat_id, query, limit = 100, from_search_id: 0, filter: SearchMessagesFilter::Empty.new) ⇒ TD::Types::FoundMessages

Searches for messages in secret chats. Returns the results in reverse chronological order. For optimal performance the number of returned messages is chosen by the library.

Parameters:

  • chat_id (Integer)

    Identifier of the chat in which to search. Specify 0 to search in all secret chats.

  • query (String)

    Query to search for. If empty, #search_chat_messages should be used instead.

  • from_search_id (Integer) (defaults to: 0)

    The identifier from the result of a previous request, use 0 to get results from the last message.

  • limit (Integer) (defaults to: 100)

    Maximum number of messages to be returned; up to 100. Fewer messages may be returned than specified by the limit, even if the end of the message history has not been reached.

  • filter (TD::Types::SearchMessagesFilter) (defaults to: SearchMessagesFilter::Empty.new)

    A filter for the content of messages in the search results.

Returns:



2583
2584
2585
2586
2587
2588
2589
2590
# File 'lib/tdlib/client_methods.rb', line 2583

def search_secret_messages(chat_id, query, limit = 100, from_search_id: 0, filter: SearchMessagesFilter::Empty.new)
  broadcast('@type'          => 'searchSecretMessages',
            'chat_id'        => chat_id,
            'query'          => query,
            'from_search_id' => from_search_id,
            'limit'          => limit,
            'filter'         => filter)
end

#search_sticker_set(name) ⇒ TD::Types::StickerSet

Searches for a sticker set by its name.

Parameters:

  • name (String)

    Name of the sticker set.

Returns:



2596
2597
2598
2599
# File 'lib/tdlib/client_methods.rb', line 2596

def search_sticker_set(name)
  broadcast('@type' => 'searchStickerSet',
            'name'  => name)
end

#search_sticker_sets(query) ⇒ TD::Types::StickerSets

Searches for ordinary sticker sets by looking for specified query in their title and name. Excludes installed sticker sets from the results.

Parameters:

  • query (String)

    Query to search for.

Returns:



2606
2607
2608
2609
# File 'lib/tdlib/client_methods.rb', line 2606

def search_sticker_sets(query)
  broadcast('@type' => 'searchStickerSets',
            'query' => query)
end

#search_stickers(emoji, limit = 100) ⇒ TD::Types::Stickers

Searches for stickers from public sticker sets that correspond to a given emoji.

Parameters:

  • emoji (String)

    String representation of emoji; must be non-empty.

  • limit (Integer) (defaults to: 100)

    Maximum number of stickers to be returned.

Returns:



2616
2617
2618
2619
2620
# File 'lib/tdlib/client_methods.rb', line 2616

def search_stickers(emoji, limit = 100)
  broadcast('@type' => 'searchStickers',
            'emoji' => emoji,
            'limit' => limit)
end

#send_bot_start_message(bot_user_id, chat_id, parameter = nil) ⇒ TD::Types::Message

Invites a bot to a chat (if it is not yet a member) and sends it the /start command. Bots can't be invited to a private chat other than the chat with the bot. Bots can't be invited to channels (although they can be added as admins) and secret chats.

Parameters:

  • bot_user_id (Integer)

    Identifier of the bot.

  • chat_id (Integer)

    Identifier of the target chat.

  • parameter (String, nil) (defaults to: nil)

    A hidden parameter sent to the bot for deep linking purposes

Returns:

See Also:



2631
2632
2633
2634
2635
2636
# File 'lib/tdlib/client_methods.rb', line 2631

def send_bot_start_message(bot_user_id, chat_id, parameter = nil)
  broadcast('@type'       => 'sendBotStartMessage',
            'bot_user_id' => bot_user_id,
            'chat_id'     => chat_id,
            'parameter'   => parameter)
end

#send_call_debug_information(call_id, debug_information) ⇒ TD::Types::Ok

Sends debug information for a call.

Parameters:

  • call_id (Integer)

    Call identifier.

  • debug_information (String)

    Debug information in application-specific format.

Returns:



2643
2644
2645
2646
2647
# File 'lib/tdlib/client_methods.rb', line 2643

def send_call_debug_information(call_id, debug_information)
  broadcast('@type'             => 'sendCallDebugInformation',
            'call_id'           => call_id,
            'debug_information' => debug_information)
end

#send_call_rating(call_id, rating, comment = nil) ⇒ TD::Types::Ok

Sends a call rating.

Parameters:

  • call_id (Integer)

    Call identifier.

  • rating (Integer)

    Call rating; 1-5.

  • comment (String, nil) (defaults to: nil)

    An optional user comment if the rating is less than 5.

Returns:



2655
2656
2657
2658
2659
2660
# File 'lib/tdlib/client_methods.rb', line 2655

def send_call_rating(call_id, rating, comment = nil)
  broadcast('@type'   => 'sendCallRating',
            'call_id' => call_id,
            'rating'  => rating,
            'comment' => comment)
end

#send_chat_action(chat_id, action) ⇒ TD::Types::Ok

Sends a notification about user activity in a chat.

Parameters:

Returns:



2667
2668
2669
2670
2671
# File 'lib/tdlib/client_methods.rb', line 2667

def send_chat_action(chat_id, action)
  broadcast('@type'   => 'sendChatAction',
            'chat_id' => chat_id,
            'action'  => action)
end

#send_chat_screenshot_taken_notification(chat_id) ⇒ TD::Types::Ok

Sends a notification about a screenshot taken in a chat. Supported only in private and secret chats.

Parameters:

  • chat_id (Integer)

    Chat identifier.

Returns:



2678
2679
2680
2681
# File 'lib/tdlib/client_methods.rb', line 2678

def send_chat_screenshot_taken_notification(chat_id)
  broadcast('@type'   => 'sendChatScreenshotTakenNotification',
            'chat_id' => chat_id)
end

#send_chat_set_ttl_message(chat_id, ttl) ⇒ TD::Types::Message

Changes the current TTL setting (sets a new self-destruct timer) in a secret chat and sends the corresponding message.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • ttl (Integer)

    New TTL value, in seconds.

Returns:



2689
2690
2691
2692
2693
# File 'lib/tdlib/client_methods.rb', line 2689

def send_chat_set_ttl_message(chat_id, ttl)
  broadcast('@type'   => 'sendChatSetTtlMessage',
            'chat_id' => chat_id,
            'ttl'     => ttl)
end

#send_custom_request(method, parameters) ⇒ TD::Types::CustomRequestResult

Sends a custom request; for bots only.

Parameters:

  • method (String)

    The method name.

  • parameters (String)

    JSON-serialized method parameters.

Returns:



2700
2701
2702
2703
2704
# File 'lib/tdlib/client_methods.rb', line 2700

def send_custom_request(method, parameters)
  broadcast('@type'      => 'sendCustomRequest',
            'method'     => method,
            'parameters' => parameters)
end

#send_email_address_verification_code(email_address) ⇒ TD::Types::EmailAddressAuthenticationCodeInfo

Sends a code to verify an email address to be added to a user's Telegram Passport.

Parameters:

  • email_address (String)

    Email address.

Returns:



2710
2711
2712
2713
# File 'lib/tdlib/client_methods.rb', line 2710

def send_email_address_verification_code(email_address)
  broadcast('@type'         => 'sendEmailAddressVerificationCode',
            'email_address' => email_address)
end

#send_inline_query_result_message(chat_id, query_id, result_id, reply_to_message_id: 0, disable_notification: false, from_background: false) ⇒ TD::Types::Message

Sends the result of an inline query as a message. Returns the sent message. Always clears a chat draft message.

Parameters:

  • chat_id (Integer)

    Target chat.

  • reply_to_message_id (Integer) (defaults to: 0)

    Identifier of a message to reply to or 0.

  • disable_notification (Boolean) (defaults to: false)

    Pass true to disable notification for the message. Not supported in secret chats.

  • from_background (Boolean) (defaults to: false)

    Pass true if the message is sent from background.

  • query_id (Integer)

    Identifier of the inline query.

  • result_id (String)

    Identifier of the inline result.

Returns:



2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
# File 'lib/tdlib/client_methods.rb', line 2727

def send_inline_query_result_message(chat_id, query_id, result_id,
                                     reply_to_message_id: 0, disable_notification: false, from_background: false)
  broadcast('@type'                => 'sendInlineQueryResultMessage',
            'chat_id'              => chat_id,
            'reply_to_message_id'  => reply_to_message_id,
            'disable_notification' => disable_notification,
            'from_background'      => from_background,
            'query_id'             => query_id,
            'result_id'            => result_id)
end

#send_message(chat_id, input_message_content, reply_to_message_id: 0, disable_notification: false, from_background: false, reply_markup: nil) ⇒ TD::Types::Message

Sends a message.

Parameters:

  • chat_id (Integer)

    Target chat.

  • reply_to_message_id (Integer) (defaults to: 0)

    Identifier of the message to reply to or 0.

  • disable_notification (Boolean) (defaults to: false)

    Pass true to disable notification for the message. Not supported in secret chats.

  • from_background (Boolean) (defaults to: false)

    Pass true if the message is sent from the background.

  • reply_markup (TD::Types::ReplyMarkup, nil) (defaults to: nil)

    Markup for replying to the message; for bots only.

  • input_message_content (TD::Types::InputMessageContent)

    The content of the message to be sent.

Returns:



2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
# File 'lib/tdlib/client_methods.rb', line 2748

def send_message(chat_id, input_message_content,
                 reply_to_message_id: 0, disable_notification: false, from_background: false, reply_markup: nil)
  broadcast('@type'                 => 'sendMessage',
            'chat_id'               => chat_id,
            'reply_to_message_id'   => reply_to_message_id,
            'disable_notification'  => disable_notification,
            'from_background'       => from_background,
            'reply_markup'          => reply_markup,
            'input_message_content' => input_message_content)
end

#send_message_album(chat_id, input_message_contents, reply_to_message_id: 0, disable_notification: false, from_background: false) ⇒ TD::Types::Messages

Sends messages grouped together into an album. Currently only photo and video messages can be grouped into an album.

Parameters:

  • chat_id (Integer)

    Target chat.

  • reply_to_message_id (Integer) (defaults to: 0)

    Identifier of a message to reply to or 0.

  • disable_notification (Boolean) (defaults to: false)

    Pass true to disable notification for the messages. Not supported in secret chats.

  • from_background (Boolean) (defaults to: false)

    Pass true if the messages are sent from the background.

  • input_message_contents (Array<TD::Types::InputMessageContent>)

    Contents of messages to be sent.

Returns:



2769
2770
2771
2772
2773
2774
2775
2776
2777
# File 'lib/tdlib/client_methods.rb', line 2769

def send_message_album(chat_id, input_message_contents,
                       reply_to_message_id: 0, disable_notification: false, from_background: false)
  broadcast('@type'                  => 'sendMessageAlbum',
            'chat_id'                => chat_id,
            'reply_to_message_id'    => reply_to_message_id,
            'disable_notification'   => disable_notification,
            'from_background'        => from_background,
            'input_message_contents' => input_message_contents)
end

#send_passport_authorization_form(autorization_form_id, types) ⇒ TD::Types::Ok

Sends a Telegram Passport authorization form, effectively sharing data with the service.

Parameters:

  • autorization_form_id (Integer)

    Authorization form identifier.

  • types (Array<TD::Types::PassportElementType>)

    Types of Telegram Passport elements chosen by user to complete the authorization form.

Returns:



2785
2786
2787
2788
2789
# File 'lib/tdlib/client_methods.rb', line 2785

def send_passport_authorization_form(autorization_form_id, types)
  broadcast('@type'                => 'sendPassportAuthorizationForm',
            'autorization_form_id' => autorization_form_id,
            'types'                => types)
end

#send_payment_form(chat_id, message_id, credentials, order_info_id: "", shipping_option_id: nil) ⇒ TD::Types::PaymentResult

Sends a filled-out payment form to the bot for final verification.

Parameters:

  • chat_id (Integer)

    Chat identifier of the Invoice message.

  • message_id (Integer)

    Message identifier.

  • order_info_id (String) (defaults to: "")

    Identifier returned by #validate_order_info, or an empty string.

  • shipping_option_id (String, nil) (defaults to: nil)

    Identifier of a chosen shipping option, if applicable.

  • credentials (TD::Types::InputCredentials)

    The credentials chosen by user for payment.

Returns:



2799
2800
2801
2802
2803
2804
2805
2806
# File 'lib/tdlib/client_methods.rb', line 2799

def send_payment_form(chat_id, message_id, credentials, order_info_id: "", shipping_option_id: nil)
  broadcast('@type'              => 'sendPaymentForm',
            'chat_id'            => chat_id,
            'message_id'         => message_id,
            'order_info_id'      => order_info_id,
            'shipping_option_id' => shipping_option_id,
            'credentials'        => credentials)
end

#send_phone_number_confirmation_code(hash, phone_number, allow_flash_call: false, is_current_phone_number: false) ⇒ TD::Types::AuthenticationCodeInfo

Sends phone number confirmation code. Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or "tg://confirmphone?phone=****&hash=*******" link.

Parameters:

  • hash (String)

    Value of the "hash" parameter from the link.

  • phone_number (String)

    Value of the "phone" parameter from the link.

  • allow_flash_call (Boolean) (defaults to: false)

    Pass true if the authentication code may be sent via flash call to the specified phone number.

  • is_current_phone_number (Boolean) (defaults to: false)

    Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false.

Returns:



2819
2820
2821
2822
2823
2824
2825
# File 'lib/tdlib/client_methods.rb', line 2819

def send_phone_number_confirmation_code(hash, phone_number, allow_flash_call: false, is_current_phone_number: false)
  broadcast('@type'                   => 'sendPhoneNumberConfirmationCode',
            'hash'                    => hash,
            'phone_number'            => phone_number,
            'allow_flash_call'        => allow_flash_call,
            'is_current_phone_number' => is_current_phone_number)
end

#send_phone_number_verification_code(phone_number, allow_flash_call: false, is_current_phone_number: false) ⇒ TD::Types::AuthenticationCodeInfo

Sends a code to verify a phone number to be added to a user's Telegram Passport.

Parameters:

  • phone_number (String)

    The phone number of the user, in international format.

  • allow_flash_call (Boolean) (defaults to: false)

    Pass true if the authentication code may be sent via flash call to the specified phone number.

  • is_current_phone_number (Boolean) (defaults to: false)

    Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false.

Returns:



2835
2836
2837
2838
2839
2840
# File 'lib/tdlib/client_methods.rb', line 2835

def send_phone_number_verification_code(phone_number, allow_flash_call: false, is_current_phone_number: false)
  broadcast('@type'                   => 'sendPhoneNumberVerificationCode',
            'phone_number'            => phone_number,
            'allow_flash_call'        => allow_flash_call,
            'is_current_phone_number' => is_current_phone_number)
end

#set_account_ttl(ttl) ⇒ TD::Types::Ok

Changes the period of inactivity after which the account of the current user will automatically be deleted.

Parameters:

Returns:



2846
2847
2848
2849
# File 'lib/tdlib/client_methods.rb', line 2846

def (ttl)
  broadcast('@type' => 'setAccountTtl',
            'ttl'   => ttl)
end

#set_alarm(seconds) ⇒ TD::Types::Ok

Succeeds after a specified amount of time has passed. Can be called before authorization. Can be called before initialization.

Parameters:

  • seconds (Float)

    Number of seconds before the function returns.

Returns:



2857
2858
2859
2860
# File 'lib/tdlib/client_methods.rb', line 2857

def set_alarm(seconds)
  broadcast('@type'   => 'setAlarm',
            'seconds' => seconds)
end

#set_authentication_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false) ⇒ TD::Types::Ok

Sets the phone number of the user and sends an authentication code to the user. Works only when the current authorization state is Types::AuthorizationState::WaitPhoneNumber.

Parameters:

  • phone_number (String)

    The phone number of the user, in international format.

  • allow_flash_call (Boolean) (defaults to: false)

    Pass true if the authentication code may be sent via flash call to the specified phone number.

  • is_current_phone_number (Boolean) (defaults to: false)

    Pass true if the phone number is used on the current device. Ignored if allow_flash_call is false.

Returns:



2871
2872
2873
2874
2875
2876
# File 'lib/tdlib/client_methods.rb', line 2871

def set_authentication_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false)
  broadcast('@type'                   => 'setAuthenticationPhoneNumber',
            'phone_number'            => phone_number,
            'allow_flash_call'        => allow_flash_call,
            'is_current_phone_number' => is_current_phone_number)
end

#set_bio(bio) ⇒ TD::Types::Ok

Changes the bio of the current user.

Parameters:

  • bio (String)

    The new value of the user bio; 0-70 characters without line feeds.

Returns:



2882
2883
2884
2885
# File 'lib/tdlib/client_methods.rb', line 2882

def set_bio(bio)
  broadcast('@type' => 'setBio',
            'bio'   => bio)
end

#set_bot_updates_status(pending_update_count, error_message) ⇒ TD::Types::Ok

Informs the server about the number of pending bot updates if they haven't been processed for a long time; for bots only.

Parameters:

  • pending_update_count (Integer)

    The number of pending updates.

  • error_message (String)

    The last error message.

Returns:



2893
2894
2895
2896
2897
# File 'lib/tdlib/client_methods.rb', line 2893

def set_bot_updates_status(pending_update_count, error_message)
  broadcast('@type'                => 'setBotUpdatesStatus',
            'pending_update_count' => pending_update_count,
            'error_message'        => error_message)
end

#set_chat_client_data(chat_id, client_data) ⇒ TD::Types::Ok

Changes client data associated with a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • client_data (String)

    New value of client_data.

Returns:



2904
2905
2906
2907
2908
# File 'lib/tdlib/client_methods.rb', line 2904

def set_chat_client_data(chat_id, client_data)
  broadcast('@type'       => 'setChatClientData',
            'chat_id'     => chat_id,
            'client_data' => client_data)
end

#set_chat_draft_message(chat_id, draft_message = nil) ⇒ TD::Types::Ok

Changes the draft message in a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • draft_message (TD::Types::DraftMessage, nil) (defaults to: nil)

    New draft message.

Returns:



2915
2916
2917
2918
2919
# File 'lib/tdlib/client_methods.rb', line 2915

def set_chat_draft_message(chat_id, draft_message = nil)
  broadcast('@type'         => 'setChatDraftMessage',
            'chat_id'       => chat_id,
            'draft_message' => draft_message)
end

#set_chat_member_status(chat_id, user_id, status) ⇒ TD::Types::Ok

Changes the status of a chat member, needs appropriate privileges. This function is currently not suitable for adding new members to the chat; instead, use #add_chat_member. The chat member status will not be changed until it has been synchronized with the server.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • user_id (Integer)

    User identifier.

  • status (TD::Types::ChatMemberStatus)

    The new status of the member in the chat.

Returns:



2929
2930
2931
2932
2933
2934
# File 'lib/tdlib/client_methods.rb', line 2929

def set_chat_member_status(chat_id, user_id, status)
  broadcast('@type'   => 'setChatMemberStatus',
            'chat_id' => chat_id,
            'user_id' => user_id,
            'status'  => status)
end

#set_chat_notification_settings(chat_id, notification_settings) ⇒ TD::Types::Ok

Changes the notification settings of a chat.

Parameters:

Returns:



2941
2942
2943
2944
2945
# File 'lib/tdlib/client_methods.rb', line 2941

def set_chat_notification_settings(chat_id, notification_settings)
  broadcast('@type'                 => 'setChatNotificationSettings',
            'chat_id'               => chat_id,
            'notification_settings' => notification_settings)
end

#set_chat_photo(chat_id, photo = InputFile::Id.new(id: 0)) ⇒ TD::Types::Ok

Changes the photo of a chat. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The photo will not be changed before request to the server has been completed.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • photo (TD::Types::InputFile) (defaults to: InputFile::Id.new(id: 0))

    New chat photo. You can use a zero Types::InputFile::Id to delete the chat photo. Files that are accessible only by HTTP URL are not acceptable.

Returns:



2957
2958
2959
2960
2961
# File 'lib/tdlib/client_methods.rb', line 2957

def set_chat_photo(chat_id, photo = InputFile::Id.new(id: 0))
  broadcast('@type'   => 'setChatPhoto',
            'chat_id' => chat_id,
            'photo'   => photo)
end

#set_chat_title(chat_id, title) ⇒ TD::Types::Ok

Changes the chat title. Supported only for basic groups, supergroups and channels. Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels. The title will not be changed until the request to the server has been completed.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • title (String)

    New title of the chat; 1-255 characters.

Returns:



2971
2972
2973
2974
2975
# File 'lib/tdlib/client_methods.rb', line 2971

def set_chat_title(chat_id, title)
  broadcast('@type'   => 'setChatTitle',
            'chat_id' => chat_id,
            'title'   => title)
end

#set_custom_language_pack(info, strings) ⇒ TD::Types::Ok

Adds or changes a custom language pack to the current localization target.

Parameters:

  • info (TD::Types::LanguagePackInfo)

    Information about the language pack. Language pack ID must start with 'X', consist only of English letters, digits and hyphens, and must not exceed 64 characters.

  • strings (Array<TD::Types::LanguagePackString>)

    Strings of the new language pack.

Returns:



2984
2985
2986
2987
2988
# File 'lib/tdlib/client_methods.rb', line 2984

def set_custom_language_pack(info, strings)
  broadcast('@type'   => 'setCustomLanguagePack',
            'info'    => info,
            'strings' => strings)
end

#set_custom_language_pack_string(language_pack_id, new_string) ⇒ TD::Types::Ok

Adds, edits or deletes a string in a custom language pack.

Parameters:

  • language_pack_id (String)

    Identifier of a previously added custom language pack in the current localization target.

  • new_string (TD::Types::LanguagePackString)

    New language pack string.

Returns:



2996
2997
2998
2999
3000
# File 'lib/tdlib/client_methods.rb', line 2996

def set_custom_language_pack_string(language_pack_id, new_string)
  broadcast('@type'            => 'setCustomLanguagePackString',
            'language_pack_id' => language_pack_id,
            'new_string'       => new_string)
end

#set_database_encryption_key(new_encryption_key) ⇒ TD::Types::Ok

Changes the database encryption key. Usually the encryption key is never changed and is stored in some OS keychain.

Parameters:

  • new_encryption_key (String)

    New encryption key.

Returns:



3007
3008
3009
3010
# File 'lib/tdlib/client_methods.rb', line 3007

def set_database_encryption_key(new_encryption_key)
  broadcast('@type'              => 'setDatabaseEncryptionKey',
            'new_encryption_key' => new_encryption_key)
end

#set_file_generation_progress(generation_id, local_prefix_size, expected_size: 0) ⇒ TD::Types::Ok

The next part of a file was generated.

Parameters:

  • generation_id (Integer)

    The identifier of the generation process.

  • expected_size (Integer) (defaults to: 0)

    Expected size of the generated file, in bytes; 0 if unknown.

  • local_prefix_size (Integer)

    The number of bytes already generated.

Returns:



3018
3019
3020
3021
3022
3023
# File 'lib/tdlib/client_methods.rb', line 3018

def set_file_generation_progress(generation_id, local_prefix_size, expected_size: 0)
  broadcast('@type'             => 'setFileGenerationProgress',
            'generation_id'     => generation_id,
            'expected_size'     => expected_size,
            'local_prefix_size' => local_prefix_size)
end

#set_game_score(chat_id, message_id, user_id, score, edit_message: false, force: false) ⇒ TD::Types::Message

Updates the game score of the specified user in the game; for bots only.

Parameters:

  • chat_id (Integer)

    The chat to which the message with the game.

  • message_id (Integer)

    Identifier of the message.

  • edit_message (Boolean) (defaults to: false)

    True, if the message should be edited.

  • user_id (Integer)

    User identifier.

  • score (Integer)

    The new score.

  • force (Boolean) (defaults to: false)

    Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table.

Returns:



3035
3036
3037
3038
3039
3040
3041
3042
3043
# File 'lib/tdlib/client_methods.rb', line 3035

def set_game_score(chat_id, message_id, user_id, score, edit_message: false, force: false)
  broadcast('@type'        => 'setGameScore',
            'chat_id'      => chat_id,
            'message_id'   => message_id,
            'edit_message' => edit_message,
            'user_id'      => user_id,
            'score'        => score,
            'force'        => force)
end

#set_inline_game_score(inline_message_id, user_id, score, edit_message: false, force: false) ⇒ TD::Types::Ok

Updates the game score of the specified user in a game; for bots only.

Parameters:

  • inline_message_id (String)

    Inline message identifier.

  • edit_message (Boolean) (defaults to: false)

    True, if the message should be edited.

  • user_id (Integer)

    User identifier.

  • score (Integer)

    The new score.

  • force (Boolean) (defaults to: false)

    Pass true to update the score even if it decreases. If the score is 0, the user will be deleted from the high score table.

Returns:



3054
3055
3056
3057
3058
3059
3060
3061
# File 'lib/tdlib/client_methods.rb', line 3054

def set_inline_game_score(inline_message_id, user_id, score, edit_message: false, force: false)
  broadcast('@type'             => 'setInlineGameScore',
            'inline_message_id' => inline_message_id,
            'edit_message'      => edit_message,
            'user_id'           => user_id,
            'score'             => score,
            'force'             => force)
end

#set_name(first_name, last_name) ⇒ TD::Types::Ok

Changes the first and last name of the current user. If something changes, Types::Update::User will be sent.

Parameters:

  • first_name (String)

    The new value of the first name for the user; 1-255 characters.

  • last_name (String)

    The new value of the optional last name for the user; 0-255 characters.

Returns:



3069
3070
3071
3072
3073
# File 'lib/tdlib/client_methods.rb', line 3069

def set_name(first_name, last_name)
  broadcast('@type'      => 'setName',
            'first_name' => first_name,
            'last_name'  => last_name)
end

#set_network_type(type = NetworkType::Other) ⇒ TD::Types::Ok

Sets the current network type. Can be called before authorization. Calling this method forces all network connections to reopen, mitigating the delay in switching between different networks, so it should be called whenever the network is changed, even if the network type remains the same. Network type is used to check whether the library can use the network at all and also for collecting detailed network data usage statistics.

Parameters:

Returns:



3085
3086
3087
3088
# File 'lib/tdlib/client_methods.rb', line 3085

def set_network_type(type = NetworkType::Other)
  broadcast('@type' => 'setNetworkType',
            'type'  => type)
end

#set_option(name, value) ⇒ TD::Types::Ok

Sets the value of an option. Only writable options can be set. Can be called before authorization.

Parameters:

Returns:

See Also:



3098
3099
3100
3101
3102
# File 'lib/tdlib/client_methods.rb', line 3098

def set_option(name, value)
  broadcast('@type' => 'setOption',
            'name'  => name,
            'value' => value)
end

#set_passport_element(element, password) ⇒ TD::Types::PassportElement

Adds an element to the user's Telegram Passport. May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the chosen phone number or the chosen email address must be verified first.

Parameters:

Returns:



3111
3112
3113
3114
3115
# File 'lib/tdlib/client_methods.rb', line 3111

def set_passport_element(element, password)
  broadcast('@type'    => 'setPassportElement',
            'element'  => element,
            'password' => password)
end

#set_passport_element_errors(user_id, errors) ⇒ TD::Types::Ok

Informs the user that some of the elements in their Telegram Passport contain errors; for bots only. The user will not be able to resend the elements, until the errors are fixed.

Parameters:

Returns:



3123
3124
3125
3126
3127
# File 'lib/tdlib/client_methods.rb', line 3123

def set_passport_element_errors(user_id, errors)
  broadcast('@type'   => 'setPassportElementErrors',
            'user_id' => user_id,
            'errors'  => errors)
end

#set_password(old_password, new_password: nil, new_hint: nil, set_recovery_email_address: false, new_recovery_email_address: nil) ⇒ TD::Types::PasswordState

Changes the password for the user. If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the password change will not be applied until the new recovery email address has been confirmed. The application should periodically call #get_password_state to check whether the new email address has been confirmed.

Parameters:

  • old_password (String)

    Previous password of the user.

  • new_password (String, nil) (defaults to: nil)

    New password of the user; may be empty to remove the password.

  • new_hint (String, nil) (defaults to: nil)

    New password hint.

  • set_recovery_email_address (Boolean) (defaults to: false)

    Pass true if the recovery email address should be changed.

  • new_recovery_email_address (String, nil) (defaults to: nil)

    New recovery email address.

Returns:



3141
3142
3143
3144
3145
3146
3147
3148
3149
# File 'lib/tdlib/client_methods.rb', line 3141

def set_password(old_password, new_password: nil, new_hint: nil, set_recovery_email_address: false,
                 new_recovery_email_address: nil)
  broadcast('@type'                      => 'setPassword',
            'old_password'               => old_password,
            'new_password'               => new_password,
            'new_hint'                   => new_hint,
            'set_recovery_email_address' => set_recovery_email_address,
            'new_recovery_email_address' => new_recovery_email_address)
end

#set_pinned_chats(chat_ids) ⇒ TD::Types::Ok

Changes the order of pinned chats.

Parameters:

  • chat_ids (Array<Integer>)

    The new list of pinned chats.

Returns:



3155
3156
3157
3158
# File 'lib/tdlib/client_methods.rb', line 3155

def set_pinned_chats(chat_ids)
  broadcast('@type'    => 'setPinnedChats',
            'chat_ids' => chat_ids)
end

#set_profile_photo(photo) ⇒ TD::Types::Ok

Uploads a new profile photo for the current user. If something changes, Types::Update::User will be sent.

Parameters:

Returns:



3166
3167
3168
3169
# File 'lib/tdlib/client_methods.rb', line 3166

def set_profile_photo(photo)
  broadcast('@type' => 'setProfilePhoto',
            'photo' => photo)
end

#set_recovery_email_address(new_recovery_email_address, password) ⇒ TD::Types::PasswordState

Changes the recovery email address of the user. If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the email address will not be changed until the new email has been confirmed. The application should periodically call #get_password_state to check whether the email address has been confirmed. If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting for an email confirmation.

Parameters:

  • password (String)

    Password of the current user.

  • new_recovery_email_address (String)

    New recovery email address.

Returns:



3182
3183
3184
3185
3186
# File 'lib/tdlib/client_methods.rb', line 3182

def set_recovery_email_address(new_recovery_email_address, password)
  broadcast('@type'                      => 'setRecoveryEmailAddress',
            'password'                   => password,
            'new_recovery_email_address' => new_recovery_email_address)
end

#set_scope_notification_settings(scope, notification_settings) ⇒ TD::Types::Ok

Changes notification settings for chats of a given type.

Parameters:

Returns:



3194
3195
3196
3197
3198
# File 'lib/tdlib/client_methods.rb', line 3194

def set_scope_notification_settings(scope, notification_settings)
  broadcast('@type'                 => 'setScopeNotificationSettings',
            'scope'                 => scope,
            'notification_settings' => notification_settings)
end

#set_sticker_position_in_set(sticker, position) ⇒ TD::Types::Ok

Changes the position of a sticker in the set to which it belongs; for bots only. The sticker set must have been created by the bot.

Parameters:

  • sticker (TD::Types::InputFile)

    Sticker.

  • position (Integer)

    New position of the sticker in the set, zero-based.

Returns:



3206
3207
3208
3209
3210
# File 'lib/tdlib/client_methods.rb', line 3206

def set_sticker_position_in_set(sticker, position)
  broadcast('@type'    => 'setStickerPositionInSet',
            'sticker'  => sticker,
            'position' => position)
end

#set_supergroup_description(supergroup_id, description) ⇒ TD::Types::Ok

Changes information about a supergroup or channel; requires appropriate administrator rights.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup or channel.

  • description (String)

    New supergroup or channel description; 0-255 characters.

Returns:



3217
3218
3219
3220
3221
# File 'lib/tdlib/client_methods.rb', line 3217

def set_supergroup_description(supergroup_id, description)
  broadcast('@type'         => 'setSupergroupDescription',
            'supergroup_id' => supergroup_id,
            'description'   => description)
end

#set_supergroup_sticker_set(supergroup_id, sticker_set_id = 0) ⇒ TD::Types::Ok

Changes the sticker set of a supergroup; requires appropriate rights in the supergroup.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup.

  • sticker_set_id (Integer) (defaults to: 0)

    New value of the supergroup sticker set identifier. Use 0 to remove the supergroup sticker set.

Returns:



3229
3230
3231
3232
3233
# File 'lib/tdlib/client_methods.rb', line 3229

def set_supergroup_sticker_set(supergroup_id, sticker_set_id = 0)
  broadcast('@type'          => 'setSupergroupStickerSet',
            'supergroup_id'  => supergroup_id,
            'sticker_set_id' => sticker_set_id)
end

#set_supergroup_username(supergroup_id, username = "") ⇒ TD::Types::Ok

Changes the username of a supergroup or channel, requires creator privileges in the supergroup or channel.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup or channel.

  • username (String) (defaults to: "")

    New value of the username. Use an empty string to remove the username.

Returns:



3241
3242
3243
3244
3245
# File 'lib/tdlib/client_methods.rb', line 3241

def set_supergroup_username(supergroup_id, username = "")
  broadcast('@type'         => 'setSupergroupUsername',
            'supergroup_id' => supergroup_id,
            'username'      => username)
end

#set_tdlib_parameters(parameters) ⇒ TD::Types::Ok

Sets the parameters for TDLib initialization. Works only when the current authorization state is Types::AuthorizationState::WaitTdlibParameters.

Parameters:

Returns:



3252
3253
3254
3255
# File 'lib/tdlib/client_methods.rb', line 3252

def set_tdlib_parameters(parameters)
  broadcast('@type'      => 'setTdlibParameters',
            'parameters' => parameters)
end

#set_user_privacy_setting_rules(setting, rules) ⇒ TD::Types::Ok

Changes user privacy settings.

Parameters:

Returns:



3262
3263
3264
3265
3266
# File 'lib/tdlib/client_methods.rb', line 3262

def set_user_privacy_setting_rules(setting, rules)
  broadcast('@type'   => 'setUserPrivacySettingRules',
            'setting' => setting,
            'rules'   => rules)
end

#set_username(username = "") ⇒ TD::Types::Ok

Changes the username of the current user. If something changes, Types::Update::User will be sent.

Parameters:

  • username (String) (defaults to: "")

    The new value of the username. Use an empty string to remove the username.

Returns:



3274
3275
3276
3277
# File 'lib/tdlib/client_methods.rb', line 3274

def set_username(username = "")
  broadcast('@type'    => 'setUsername',
            'username' => username)
end

#terminate_all_other_sessionsTD::Types::Ok

Terminates all other sessions of the current user.

Returns:



3282
3283
3284
# File 'lib/tdlib/client_methods.rb', line 3282

def terminate_all_other_sessions
  broadcast('@type' => 'terminateAllOtherSessions')
end

#terminate_session(session_id) ⇒ TD::Types::Ok

Terminates a session of the current user.

Parameters:

  • session_id (Integer)

    Session identifier.

Returns:



3290
3291
3292
3293
# File 'lib/tdlib/client_methods.rb', line 3290

def terminate_session(session_id)
  broadcast('@type'      => 'terminateSession',
            'session_id' => session_id)
end

#toggle_basic_group_administrators(basic_group_id, everyone_is_administrator) ⇒ TD::Types::Ok

Toggles the "All members are admins" setting in basic groups; requires creator privileges in the group.

Parameters:

  • basic_group_id (Integer)

    Identifier of the basic group.

  • everyone_is_administrator (Boolean)

    New value of everyone_is_administrator.

Returns:



3300
3301
3302
3303
3304
# File 'lib/tdlib/client_methods.rb', line 3300

def toggle_basic_group_administrators(basic_group_id, everyone_is_administrator)
  broadcast('@type'                     => 'toggleBasicGroupAdministrators',
            'basic_group_id'            => basic_group_id,
            'everyone_is_administrator' => everyone_is_administrator)
end

#toggle_chat_default_disable_notification(chat_id, default_disable_notification) ⇒ TD::Types::Ok

Changes the value of the default disable_notification parameter, used when a message is sent to a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • default_disable_notification (Boolean)

    New value of default_disable_notification.

Returns:



3311
3312
3313
3314
3315
# File 'lib/tdlib/client_methods.rb', line 3311

def toggle_chat_default_disable_notification(chat_id, default_disable_notification)
  broadcast('@type'                        => 'toggleChatDefaultDisableNotification',
            'chat_id'                      => chat_id,
            'default_disable_notification' => default_disable_notification)
end

#toggle_chat_is_marked_as_unread(chat_id, is_marked_as_unread) ⇒ TD::Types::Ok

Changes the marked as unread state of a chat.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • is_marked_as_unread (Boolean)

    New value of is_marked_as_unread.

Returns:



3322
3323
3324
3325
3326
# File 'lib/tdlib/client_methods.rb', line 3322

def toggle_chat_is_marked_as_unread(chat_id, is_marked_as_unread)
  broadcast('@type'               => 'toggleChatIsMarkedAsUnread',
            'chat_id'             => chat_id,
            'is_marked_as_unread' => is_marked_as_unread)
end

#toggle_chat_is_pinned(chat_id, is_pinned) ⇒ TD::Types::Ok

Changes the pinned state of a chat. You can pin up to GetOption("pinned_chat_count_max") non-secret chats and the same number of secret chats.

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • is_pinned (Boolean)

    New value of is_pinned.

Returns:



3334
3335
3336
3337
3338
# File 'lib/tdlib/client_methods.rb', line 3334

def toggle_chat_is_pinned(chat_id, is_pinned)
  broadcast('@type'     => 'toggleChatIsPinned',
            'chat_id'   => chat_id,
            'is_pinned' => is_pinned)
end

#toggle_supergroup_invites(supergroup_id, anyone_can_invite) ⇒ TD::Types::Ok

Toggles whether all members of a supergroup can add new members; requires appropriate administrator rights in the supergroup.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup.

  • anyone_can_invite (Boolean)

    New value of anyone_can_invite.

Returns:



3346
3347
3348
3349
3350
# File 'lib/tdlib/client_methods.rb', line 3346

def toggle_supergroup_invites(supergroup_id, anyone_can_invite)
  broadcast('@type'             => 'toggleSupergroupInvites',
            'supergroup_id'     => supergroup_id,
            'anyone_can_invite' => anyone_can_invite)
end

#toggle_supergroup_is_all_history_available(supergroup_id, is_all_history_available) ⇒ TD::Types::Ok

Toggles whether the message history of a supergroup is available to new members; requires appropriate administrator rights in the supergroup.

Parameters:

  • supergroup_id (Integer)

    The identifier of the supergroup.

  • is_all_history_available (Boolean)

    The new value of is_all_history_available.

Returns:



3358
3359
3360
3361
3362
# File 'lib/tdlib/client_methods.rb', line 3358

def toggle_supergroup_is_all_history_available(supergroup_id, is_all_history_available)
  broadcast('@type'                    => 'toggleSupergroupIsAllHistoryAvailable',
            'supergroup_id'            => supergroup_id,
            'is_all_history_available' => is_all_history_available)
end

#toggle_supergroup_sign_messages(supergroup_id, sign_messages) ⇒ TD::Types::Ok

Toggles sender signatures messages sent in a channel; requires appropriate administrator rights in the channel.

Parameters:

  • supergroup_id (Integer)

    Identifier of the channel.

  • sign_messages (Boolean)

    New value of sign_messages.

Returns:



3369
3370
3371
3372
3373
# File 'lib/tdlib/client_methods.rb', line 3369

def toggle_supergroup_sign_messages(supergroup_id, sign_messages)
  broadcast('@type'         => 'toggleSupergroupSignMessages',
            'supergroup_id' => supergroup_id,
            'sign_messages' => sign_messages)
end

#unblock_user(user_id) ⇒ TD::Types::Ok

Removes a user from the blacklist.

Parameters:

  • user_id (Integer)

    User identifier.

Returns:



3379
3380
3381
3382
# File 'lib/tdlib/client_methods.rb', line 3379

def unblock_user(user_id)
  broadcast('@type'   => 'unblockUser',
            'user_id' => user_id)
end

#unpin_supergroup_message(supergroup_id) ⇒ TD::Types::Ok

Removes the pinned message from a supergroup or channel; requires appropriate administrator rights in the supergroup or channel.

Parameters:

  • supergroup_id (Integer)

    Identifier of the supergroup or channel.

Returns:



3389
3390
3391
3392
# File 'lib/tdlib/client_methods.rb', line 3389

def unpin_supergroup_message(supergroup_id)
  broadcast('@type'         => 'unpinSupergroupMessage',
            'supergroup_id' => supergroup_id)
end

#upgrade_basic_group_chat_to_supergroup_chat(chat_id) ⇒ TD::Types::Chat

Creates a new supergroup from an existing basic group and sends a corresponding Types::MessageContent::UpgradeTo and Types::MessageContent::ChatUpgradeFrom. Deactivates the original basic group.

Parameters:

  • chat_id (Integer)

    Identifier of the chat to upgrade.

Returns:



3400
3401
3402
3403
# File 'lib/tdlib/client_methods.rb', line 3400

def upgrade_basic_group_chat_to_supergroup_chat(chat_id)
  broadcast('@type'   => 'upgradeBasicGroupChatToSupergroupChat',
            'chat_id' => chat_id)
end

#upload_file(file, file_type, priority = 1) ⇒ TD::Types::File

Asynchronously uploads a file to the cloud without sending it in a message. Types::Update::File will be used to notify about upload progress and successful completion of the upload. The file will not have a persistent remote identifier until it will be sent in a message.

Parameters:

  • file (TD::Types::InputFile)

    File to upload.

  • file_type (TD::Types::FileType)

    File type.

  • priority (Integer) (defaults to: 1)

    Priority of the upload (1-32). The higher the priority, the earlier the file will be uploaded. If the priorities of two files are equal, then the first one for which #upload_file was called will be uploaded first.

Returns:



3416
3417
3418
3419
3420
3421
# File 'lib/tdlib/client_methods.rb', line 3416

def upload_file(file, file_type, priority = 1)
  broadcast('@type'     => 'uploadFile',
            'file'      => file,
            'file_type' => file_type,
            'priority'  => priority)
end

#upload_sticker_file(user_id, png_sticker) ⇒ TD::Types::File

Uploads a PNG image with a sticker; for bots only

Parameters:

  • user_id (Integer)

    Sticker file owner.

  • png_sticker (TD::Types::InputFile)

    PNG image with the sticker; must be up to 512 kB in size and fit in 512x512 square.

Returns:



3429
3430
3431
3432
3433
# File 'lib/tdlib/client_methods.rb', line 3429

def upload_sticker_file(user_id, png_sticker)
  broadcast('@type'       => 'uploadStickerFile',
            'user_id'     => user_id,
            'png_sticker' => png_sticker)
end

#validate_order_info(chat_id, message_id, order_info, allow_save: false) ⇒ TD::Types::ValidatedOrderInfo

Validates the order information provided by a user and returns the available shipping options for a flexible invoice.

Parameters:

  • chat_id (Integer)

    Chat identifier of the Invoice message.

  • message_id (Integer)

    Message identifier.

  • order_info (TD::Types::OrderInfo)

    The order information, provided by the user.

  • allow_save (Boolean) (defaults to: false)

    True, if the order information can be saved.

Returns:



3443
3444
3445
3446
3447
3448
3449
# File 'lib/tdlib/client_methods.rb', line 3443

def validate_order_info(chat_id, message_id, order_info, allow_save: false)
  broadcast('@type'      => 'validateOrderInfo',
            'chat_id'    => chat_id,
            'message_id' => message_id,
            'order_info' => order_info,
            'allow_save' => allow_save)
end

#view_messages(chat_id, message_ids, force_read: false) ⇒ TD::Types::Ok

This method should be called if messages are being viewed by the user. Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels).

Parameters:

  • chat_id (Integer)

    Chat identifier.

  • message_ids (Array<Integer>)

    The identifiers of the messages being viewed.

  • force_read (Boolean) (defaults to: false)

    True, if messages in closed chats should be marked as read.

Returns:



3459
3460
3461
3462
3463
3464
# File 'lib/tdlib/client_methods.rb', line 3459

def view_messages(chat_id, message_ids, force_read: false)
  broadcast('@type'       => 'viewMessages',
            'chat_id'     => chat_id,
            'message_ids' => message_ids,
            'force_read'  => force_read)
end

Informs the server that some trending sticker sets have been viewed by the user.

Parameters:

  • sticker_set_ids (Array<Integer>)

    Identifiers of viewed trending sticker sets.

Returns:



3470
3471
3472
3473
# File 'lib/tdlib/client_methods.rb', line 3470

def view_trending_sticker_sets(sticker_set_ids)
  broadcast('@type'           => 'viewTrendingStickerSets',
            'sticker_set_ids' => sticker_set_ids)
end