tdlib-ruby 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (670) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -3
  5. data/ChangeLog.md +9 -0
  6. data/README.md +49 -46
  7. data/bin/build +12 -0
  8. data/bin/parser +447 -0
  9. data/lib/tdlib-ruby.rb +4 -1
  10. data/lib/tdlib/api.rb +20 -15
  11. data/lib/tdlib/client.rb +121 -123
  12. data/lib/tdlib/client_methods.rb +3474 -0
  13. data/lib/tdlib/errors.rb +29 -5
  14. data/lib/tdlib/types.rb +884 -0
  15. data/lib/tdlib/types/account_ttl.rb +10 -0
  16. data/lib/tdlib/types/address.rb +18 -0
  17. data/lib/tdlib/types/animation.rb +21 -0
  18. data/lib/tdlib/types/animations.rb +8 -0
  19. data/lib/tdlib/types/audio.rb +22 -0
  20. data/lib/tdlib/types/authentication_code_info.rb +15 -0
  21. data/lib/tdlib/types/authentication_code_type.rb +13 -0
  22. data/lib/tdlib/types/authentication_code_type/call.rb +8 -0
  23. data/lib/tdlib/types/authentication_code_type/flash_call.rb +9 -0
  24. data/lib/tdlib/types/authentication_code_type/sms.rb +8 -0
  25. data/lib/tdlib/types/authentication_code_type/telegram_message.rb +8 -0
  26. data/lib/tdlib/types/authorization_state.rb +18 -0
  27. data/lib/tdlib/types/authorization_state/closed.rb +9 -0
  28. data/lib/tdlib/types/authorization_state/closing.rb +7 -0
  29. data/lib/tdlib/types/authorization_state/logging_out.rb +5 -0
  30. data/lib/tdlib/types/authorization_state/ready.rb +6 -0
  31. data/lib/tdlib/types/authorization_state/wait_code.rb +13 -0
  32. data/lib/tdlib/types/authorization_state/wait_encryption_key.rb +8 -0
  33. data/lib/tdlib/types/authorization_state/wait_password.rb +13 -0
  34. data/lib/tdlib/types/authorization_state/wait_phone_number.rb +5 -0
  35. data/lib/tdlib/types/authorization_state/wait_tdlib_parameters.rb +5 -0
  36. data/lib/tdlib/types/base.rb +29 -0
  37. data/lib/tdlib/types/basic_group.rb +18 -0
  38. data/lib/tdlib/types/basic_group_full_info.rb +13 -0
  39. data/lib/tdlib/types/bot_command.rb +10 -0
  40. data/lib/tdlib/types/bot_info.rb +10 -0
  41. data/lib/tdlib/types/call.rb +14 -0
  42. data/lib/tdlib/types/call_connection.rb +16 -0
  43. data/lib/tdlib/types/call_discard_reason.rb +14 -0
  44. data/lib/tdlib/types/call_discard_reason/declined.rb +6 -0
  45. data/lib/tdlib/types/call_discard_reason/disconnected.rb +5 -0
  46. data/lib/tdlib/types/call_discard_reason/empty.rb +5 -0
  47. data/lib/tdlib/types/call_discard_reason/hung_up.rb +5 -0
  48. data/lib/tdlib/types/call_discard_reason/missed.rb +6 -0
  49. data/lib/tdlib/types/call_id.rb +8 -0
  50. data/lib/tdlib/types/call_protocol.rb +14 -0
  51. data/lib/tdlib/types/call_state.rb +15 -0
  52. data/lib/tdlib/types/call_state/discarded.rb +12 -0
  53. data/lib/tdlib/types/call_state/error.rb +9 -0
  54. data/lib/tdlib/types/call_state/exchanging_keys.rb +5 -0
  55. data/lib/tdlib/types/call_state/hanging_up.rb +5 -0
  56. data/lib/tdlib/types/call_state/pending.rb +10 -0
  57. data/lib/tdlib/types/call_state/ready.rb +16 -0
  58. data/lib/tdlib/types/callback_query_answer.rb +12 -0
  59. data/lib/tdlib/types/callback_query_payload.rb +11 -0
  60. data/lib/tdlib/types/callback_query_payload/data.rb +8 -0
  61. data/lib/tdlib/types/callback_query_payload/game.rb +8 -0
  62. data/lib/tdlib/types/chat.rb +51 -0
  63. data/lib/tdlib/types/chat_action.rb +22 -0
  64. data/lib/tdlib/types/chat_action/cancel.rb +5 -0
  65. data/lib/tdlib/types/chat_action/choosing_contact.rb +5 -0
  66. data/lib/tdlib/types/chat_action/choosing_location.rb +5 -0
  67. data/lib/tdlib/types/chat_action/recording_video.rb +5 -0
  68. data/lib/tdlib/types/chat_action/recording_video_note.rb +5 -0
  69. data/lib/tdlib/types/chat_action/recording_voice_note.rb +5 -0
  70. data/lib/tdlib/types/chat_action/start_playing_game.rb +5 -0
  71. data/lib/tdlib/types/chat_action/typing.rb +5 -0
  72. data/lib/tdlib/types/chat_action/uploading_document.rb +8 -0
  73. data/lib/tdlib/types/chat_action/uploading_photo.rb +8 -0
  74. data/lib/tdlib/types/chat_action/uploading_video.rb +8 -0
  75. data/lib/tdlib/types/chat_action/uploading_video_note.rb +8 -0
  76. data/lib/tdlib/types/chat_action/uploading_voice_note.rb +8 -0
  77. data/lib/tdlib/types/chat_event.rb +14 -0
  78. data/lib/tdlib/types/chat_event_action.rb +26 -0
  79. data/lib/tdlib/types/chat_event_action/description_changed.rb +10 -0
  80. data/lib/tdlib/types/chat_event_action/invites_toggled.rb +8 -0
  81. data/lib/tdlib/types/chat_event_action/is_all_history_available_toggled.rb +8 -0
  82. data/lib/tdlib/types/chat_event_action/member_invited.rb +10 -0
  83. data/lib/tdlib/types/chat_event_action/member_joined.rb +5 -0
  84. data/lib/tdlib/types/chat_event_action/member_left.rb +5 -0
  85. data/lib/tdlib/types/chat_event_action/member_promoted.rb +12 -0
  86. data/lib/tdlib/types/chat_event_action/member_restricted.rb +12 -0
  87. data/lib/tdlib/types/chat_event_action/message_deleted.rb +8 -0
  88. data/lib/tdlib/types/chat_event_action/message_edited.rb +10 -0
  89. data/lib/tdlib/types/chat_event_action/message_pinned.rb +8 -0
  90. data/lib/tdlib/types/chat_event_action/message_unpinned.rb +5 -0
  91. data/lib/tdlib/types/chat_event_action/photo_changed.rb +10 -0
  92. data/lib/tdlib/types/chat_event_action/sign_messages_toggled.rb +8 -0
  93. data/lib/tdlib/types/chat_event_action/sticker_set_changed.rb +10 -0
  94. data/lib/tdlib/types/chat_event_action/title_changed.rb +10 -0
  95. data/lib/tdlib/types/chat_event_action/username_changed.rb +10 -0
  96. data/lib/tdlib/types/chat_event_log_filters.rb +27 -0
  97. data/lib/tdlib/types/chat_events.rb +8 -0
  98. data/lib/tdlib/types/chat_invite_link.rb +8 -0
  99. data/lib/tdlib/types/chat_invite_link_info.rb +20 -0
  100. data/lib/tdlib/types/chat_member.rb +18 -0
  101. data/lib/tdlib/types/chat_member_status.rb +15 -0
  102. data/lib/tdlib/types/chat_member_status/administrator.rb +29 -0
  103. data/lib/tdlib/types/chat_member_status/banned.rb +11 -0
  104. data/lib/tdlib/types/chat_member_status/creator.rb +8 -0
  105. data/lib/tdlib/types/chat_member_status/left.rb +5 -0
  106. data/lib/tdlib/types/chat_member_status/member.rb +5 -0
  107. data/lib/tdlib/types/chat_member_status/restricted.rb +27 -0
  108. data/lib/tdlib/types/chat_members.rb +10 -0
  109. data/lib/tdlib/types/chat_members_filter.rb +14 -0
  110. data/lib/tdlib/types/chat_members_filter/administrators.rb +5 -0
  111. data/lib/tdlib/types/chat_members_filter/banned.rb +5 -0
  112. data/lib/tdlib/types/chat_members_filter/bots.rb +5 -0
  113. data/lib/tdlib/types/chat_members_filter/members.rb +5 -0
  114. data/lib/tdlib/types/chat_members_filter/restricted.rb +5 -0
  115. data/lib/tdlib/types/chat_notification_settings.rb +22 -0
  116. data/lib/tdlib/types/chat_photo.rb +10 -0
  117. data/lib/tdlib/types/chat_report_reason.rb +14 -0
  118. data/lib/tdlib/types/chat_report_reason/copyright.rb +5 -0
  119. data/lib/tdlib/types/chat_report_reason/custom.rb +8 -0
  120. data/lib/tdlib/types/chat_report_reason/pornography.rb +5 -0
  121. data/lib/tdlib/types/chat_report_reason/spam.rb +5 -0
  122. data/lib/tdlib/types/chat_report_reason/violence.rb +5 -0
  123. data/lib/tdlib/types/chat_report_spam_state.rb +8 -0
  124. data/lib/tdlib/types/chat_type.rb +13 -0
  125. data/lib/tdlib/types/chat_type/basic_group.rb +8 -0
  126. data/lib/tdlib/types/chat_type/private.rb +8 -0
  127. data/lib/tdlib/types/chat_type/secret.rb +10 -0
  128. data/lib/tdlib/types/chat_type/supergroup.rb +11 -0
  129. data/lib/tdlib/types/chats.rb +8 -0
  130. data/lib/tdlib/types/check_chat_username_result.rb +14 -0
  131. data/lib/tdlib/types/check_chat_username_result/ok.rb +5 -0
  132. data/lib/tdlib/types/check_chat_username_result/public_chats_too_much.rb +5 -0
  133. data/lib/tdlib/types/check_chat_username_result/public_groups_unavailable.rb +5 -0
  134. data/lib/tdlib/types/check_chat_username_result/username_invalid.rb +5 -0
  135. data/lib/tdlib/types/check_chat_username_result/username_occupied.rb +5 -0
  136. data/lib/tdlib/types/connected_website.rb +25 -0
  137. data/lib/tdlib/types/connected_websites.rb +8 -0
  138. data/lib/tdlib/types/connection_state.rb +14 -0
  139. data/lib/tdlib/types/connection_state/connecting.rb +5 -0
  140. data/lib/tdlib/types/connection_state/connecting_to_proxy.rb +5 -0
  141. data/lib/tdlib/types/connection_state/ready.rb +5 -0
  142. data/lib/tdlib/types/connection_state/updating.rb +5 -0
  143. data/lib/tdlib/types/connection_state/waiting_for_network.rb +6 -0
  144. data/lib/tdlib/types/contact.rb +16 -0
  145. data/lib/tdlib/types/count.rb +8 -0
  146. data/lib/tdlib/types/custom_request_result.rb +8 -0
  147. data/lib/tdlib/types/date.rb +12 -0
  148. data/lib/tdlib/types/dated_file.rb +10 -0
  149. data/lib/tdlib/types/deep_link_info.rb +10 -0
  150. data/lib/tdlib/types/device_token.rb +22 -0
  151. data/lib/tdlib/types/device_token/apple_push.rb +10 -0
  152. data/lib/tdlib/types/device_token/apple_push_vo_ip.rb +10 -0
  153. data/lib/tdlib/types/device_token/black_berry_push.rb +8 -0
  154. data/lib/tdlib/types/device_token/google_cloud_messaging.rb +8 -0
  155. data/lib/tdlib/types/device_token/microsoft_push.rb +8 -0
  156. data/lib/tdlib/types/device_token/microsoft_push_vo_ip.rb +8 -0
  157. data/lib/tdlib/types/device_token/simple_push.rb +9 -0
  158. data/lib/tdlib/types/device_token/tizen_push.rb +8 -0
  159. data/lib/tdlib/types/device_token/ubuntu_push.rb +8 -0
  160. data/lib/tdlib/types/device_token/web_push.rb +13 -0
  161. data/lib/tdlib/types/device_token/windows_push.rb +9 -0
  162. data/lib/tdlib/types/document.rb +14 -0
  163. data/lib/tdlib/types/draft_message.rb +11 -0
  164. data/lib/tdlib/types/email_address_authentication_code_info.rb +10 -0
  165. data/lib/tdlib/types/encrypted_credentials.rb +12 -0
  166. data/lib/tdlib/types/encrypted_passport_element.rb +25 -0
  167. data/lib/tdlib/types/error.rb +12 -0
  168. data/lib/tdlib/types/file.rb +18 -0
  169. data/lib/tdlib/types/file_type.rb +25 -0
  170. data/lib/tdlib/types/file_type/animation.rb +5 -0
  171. data/lib/tdlib/types/file_type/audio.rb +5 -0
  172. data/lib/tdlib/types/file_type/document.rb +5 -0
  173. data/lib/tdlib/types/file_type/none.rb +5 -0
  174. data/lib/tdlib/types/file_type/photo.rb +5 -0
  175. data/lib/tdlib/types/file_type/profile_photo.rb +5 -0
  176. data/lib/tdlib/types/file_type/secret.rb +5 -0
  177. data/lib/tdlib/types/file_type/secret_thumbnail.rb +5 -0
  178. data/lib/tdlib/types/file_type/secure.rb +5 -0
  179. data/lib/tdlib/types/file_type/sticker.rb +5 -0
  180. data/lib/tdlib/types/file_type/thumbnail.rb +5 -0
  181. data/lib/tdlib/types/file_type/unknown.rb +5 -0
  182. data/lib/tdlib/types/file_type/video.rb +5 -0
  183. data/lib/tdlib/types/file_type/video_note.rb +5 -0
  184. data/lib/tdlib/types/file_type/voice_note.rb +5 -0
  185. data/lib/tdlib/types/file_type/wallpaper.rb +5 -0
  186. data/lib/tdlib/types/formatted_text.rb +10 -0
  187. data/lib/tdlib/types/found_messages.rb +10 -0
  188. data/lib/tdlib/types/game.rb +21 -0
  189. data/lib/tdlib/types/game_high_score.rb +12 -0
  190. data/lib/tdlib/types/game_high_scores.rb +8 -0
  191. data/lib/tdlib/types/hashtags.rb +8 -0
  192. data/lib/tdlib/types/identity_document.rb +19 -0
  193. data/lib/tdlib/types/imported_contacts.rb +12 -0
  194. data/lib/tdlib/types/inline_keyboard_button.rb +10 -0
  195. data/lib/tdlib/types/inline_keyboard_button_type.rb +14 -0
  196. data/lib/tdlib/types/inline_keyboard_button_type/buy.rb +7 -0
  197. data/lib/tdlib/types/inline_keyboard_button_type/callback.rb +8 -0
  198. data/lib/tdlib/types/inline_keyboard_button_type/callback_game.rb +7 -0
  199. data/lib/tdlib/types/inline_keyboard_button_type/switch_inline.rb +10 -0
  200. data/lib/tdlib/types/inline_keyboard_button_type/url.rb +8 -0
  201. data/lib/tdlib/types/inline_query_result.rb +21 -0
  202. data/lib/tdlib/types/inline_query_result/animation.rb +12 -0
  203. data/lib/tdlib/types/inline_query_result/article.rb +18 -0
  204. data/lib/tdlib/types/inline_query_result/audio.rb +10 -0
  205. data/lib/tdlib/types/inline_query_result/contact.rb +12 -0
  206. data/lib/tdlib/types/inline_query_result/document.rb +14 -0
  207. data/lib/tdlib/types/inline_query_result/game.rb +10 -0
  208. data/lib/tdlib/types/inline_query_result/location.rb +14 -0
  209. data/lib/tdlib/types/inline_query_result/photo.rb +14 -0
  210. data/lib/tdlib/types/inline_query_result/sticker.rb +10 -0
  211. data/lib/tdlib/types/inline_query_result/venue.rb +12 -0
  212. data/lib/tdlib/types/inline_query_result/video.rb +14 -0
  213. data/lib/tdlib/types/inline_query_result/voice_note.rb +12 -0
  214. data/lib/tdlib/types/inline_query_results.rb +19 -0
  215. data/lib/tdlib/types/input_credentials.rb +13 -0
  216. data/lib/tdlib/types/input_credentials/android_pay.rb +8 -0
  217. data/lib/tdlib/types/input_credentials/apple_pay.rb +8 -0
  218. data/lib/tdlib/types/input_credentials/new.rb +10 -0
  219. data/lib/tdlib/types/input_credentials/saved.rb +9 -0
  220. data/lib/tdlib/types/input_file.rb +13 -0
  221. data/lib/tdlib/types/input_file/generated.rb +14 -0
  222. data/lib/tdlib/types/input_file/id.rb +8 -0
  223. data/lib/tdlib/types/input_file/local.rb +8 -0
  224. data/lib/tdlib/types/input_file/remote.rb +8 -0
  225. data/lib/tdlib/types/input_identity_document.rb +19 -0
  226. data/lib/tdlib/types/input_inline_query_result.rb +22 -0
  227. data/lib/tdlib/types/input_inline_query_result/animated_gif.rb +26 -0
  228. data/lib/tdlib/types/input_inline_query_result/animated_mpeg4.rb +27 -0
  229. data/lib/tdlib/types/input_inline_query_result/article.rb +28 -0
  230. data/lib/tdlib/types/input_inline_query_result/audio.rb +22 -0
  231. data/lib/tdlib/types/input_inline_query_result/contact.rb +22 -0
  232. data/lib/tdlib/types/input_inline_query_result/document.rb +29 -0
  233. data/lib/tdlib/types/input_inline_query_result/game.rb +12 -0
  234. data/lib/tdlib/types/input_inline_query_result/location.rb +27 -0
  235. data/lib/tdlib/types/input_inline_query_result/photo.rb +25 -0
  236. data/lib/tdlib/types/input_inline_query_result/sticker.rb +22 -0
  237. data/lib/tdlib/types/input_inline_query_result/venue.rb +22 -0
  238. data/lib/tdlib/types/input_inline_query_result/video.rb +31 -0
  239. data/lib/tdlib/types/input_inline_query_result/voice_note.rb +20 -0
  240. data/lib/tdlib/types/input_message_content.rb +24 -0
  241. data/lib/tdlib/types/input_message_content/animation.rb +18 -0
  242. data/lib/tdlib/types/input_message_content/audio.rb +18 -0
  243. data/lib/tdlib/types/input_message_content/contact.rb +8 -0
  244. data/lib/tdlib/types/input_message_content/document.rb +12 -0
  245. data/lib/tdlib/types/input_message_content/forwarded.rb +13 -0
  246. data/lib/tdlib/types/input_message_content/game.rb +10 -0
  247. data/lib/tdlib/types/input_message_content/invoice.rb +28 -0
  248. data/lib/tdlib/types/input_message_content/location.rb +11 -0
  249. data/lib/tdlib/types/input_message_content/photo.rb +22 -0
  250. data/lib/tdlib/types/input_message_content/sticker.rb +14 -0
  251. data/lib/tdlib/types/input_message_content/text.rb +14 -0
  252. data/lib/tdlib/types/input_message_content/venue.rb +8 -0
  253. data/lib/tdlib/types/input_message_content/video.rb +25 -0
  254. data/lib/tdlib/types/input_message_content/video_note.rb +14 -0
  255. data/lib/tdlib/types/input_message_content/voice_note.rb +14 -0
  256. data/lib/tdlib/types/input_passport_element.rb +22 -0
  257. data/lib/tdlib/types/input_passport_element/address.rb +8 -0
  258. data/lib/tdlib/types/input_passport_element/bank_statement.rb +8 -0
  259. data/lib/tdlib/types/input_passport_element/driver_license.rb +8 -0
  260. data/lib/tdlib/types/input_passport_element/email_address.rb +8 -0
  261. data/lib/tdlib/types/input_passport_element/identity_card.rb +8 -0
  262. data/lib/tdlib/types/input_passport_element/internal_passport.rb +8 -0
  263. data/lib/tdlib/types/input_passport_element/passport.rb +8 -0
  264. data/lib/tdlib/types/input_passport_element/passport_registration.rb +8 -0
  265. data/lib/tdlib/types/input_passport_element/personal_details.rb +8 -0
  266. data/lib/tdlib/types/input_passport_element/phone_number.rb +8 -0
  267. data/lib/tdlib/types/input_passport_element/rental_agreement.rb +8 -0
  268. data/lib/tdlib/types/input_passport_element/temporary_registration.rb +8 -0
  269. data/lib/tdlib/types/input_passport_element/utility_bill.rb +8 -0
  270. data/lib/tdlib/types/input_passport_element_error.rb +12 -0
  271. data/lib/tdlib/types/input_passport_element_error_source.rb +18 -0
  272. data/lib/tdlib/types/input_passport_element_error_source/data_field.rb +11 -0
  273. data/lib/tdlib/types/input_passport_element_error_source/file.rb +9 -0
  274. data/lib/tdlib/types/input_passport_element_error_source/files.rb +9 -0
  275. data/lib/tdlib/types/input_passport_element_error_source/front_side.rb +9 -0
  276. data/lib/tdlib/types/input_passport_element_error_source/reverse_side.rb +9 -0
  277. data/lib/tdlib/types/input_passport_element_error_source/selfie.rb +9 -0
  278. data/lib/tdlib/types/input_passport_element_error_source/translation_file.rb +9 -0
  279. data/lib/tdlib/types/input_passport_element_error_source/translation_files.rb +9 -0
  280. data/lib/tdlib/types/input_passport_element_error_source/unspecified.rb +9 -0
  281. data/lib/tdlib/types/input_personal_document.rb +11 -0
  282. data/lib/tdlib/types/input_sticker.rb +14 -0
  283. data/lib/tdlib/types/input_thumbnail.rb +16 -0
  284. data/lib/tdlib/types/invoice.rb +27 -0
  285. data/lib/tdlib/types/keyboard_button.rb +10 -0
  286. data/lib/tdlib/types/keyboard_button_type.rb +12 -0
  287. data/lib/tdlib/types/keyboard_button_type/request_location.rb +5 -0
  288. data/lib/tdlib/types/keyboard_button_type/request_phone_number.rb +5 -0
  289. data/lib/tdlib/types/keyboard_button_type/text.rb +5 -0
  290. data/lib/tdlib/types/labeled_price_part.rb +10 -0
  291. data/lib/tdlib/types/language_pack_info.rb +14 -0
  292. data/lib/tdlib/types/language_pack_string.rb +10 -0
  293. data/lib/tdlib/types/language_pack_string_value.rb +12 -0
  294. data/lib/tdlib/types/language_pack_string_value/deleted.rb +5 -0
  295. data/lib/tdlib/types/language_pack_string_value/ordinary.rb +8 -0
  296. data/lib/tdlib/types/language_pack_string_value/pluralized.rb +18 -0
  297. data/lib/tdlib/types/language_pack_strings.rb +8 -0
  298. data/lib/tdlib/types/link_state.rb +13 -0
  299. data/lib/tdlib/types/link_state/is_contact.rb +5 -0
  300. data/lib/tdlib/types/link_state/knows_phone_number.rb +5 -0
  301. data/lib/tdlib/types/link_state/none.rb +5 -0
  302. data/lib/tdlib/types/local_file.rb +25 -0
  303. data/lib/tdlib/types/localization_target_info.rb +8 -0
  304. data/lib/tdlib/types/location.rb +10 -0
  305. data/lib/tdlib/types/mask_point.rb +13 -0
  306. data/lib/tdlib/types/mask_point/chin.rb +5 -0
  307. data/lib/tdlib/types/mask_point/eyes.rb +5 -0
  308. data/lib/tdlib/types/mask_point/forehead.rb +5 -0
  309. data/lib/tdlib/types/mask_point/mouth.rb +5 -0
  310. data/lib/tdlib/types/mask_position.rb +17 -0
  311. data/lib/tdlib/types/message.rb +59 -0
  312. data/lib/tdlib/types/message_content.rb +48 -0
  313. data/lib/tdlib/types/message_content/animation.rb +13 -0
  314. data/lib/tdlib/types/message_content/audio.rb +10 -0
  315. data/lib/tdlib/types/message_content/basic_group_chat_create.rb +10 -0
  316. data/lib/tdlib/types/message_content/call.rb +10 -0
  317. data/lib/tdlib/types/message_content/chat_add_members.rb +8 -0
  318. data/lib/tdlib/types/message_content/chat_change_photo.rb +8 -0
  319. data/lib/tdlib/types/message_content/chat_change_title.rb +8 -0
  320. data/lib/tdlib/types/message_content/chat_delete_member.rb +8 -0
  321. data/lib/tdlib/types/message_content/chat_delete_photo.rb +5 -0
  322. data/lib/tdlib/types/message_content/chat_join_by_link.rb +5 -0
  323. data/lib/tdlib/types/message_content/chat_set_ttl.rb +8 -0
  324. data/lib/tdlib/types/message_content/chat_upgrade_from.rb +10 -0
  325. data/lib/tdlib/types/message_content/chat_upgrade_to.rb +8 -0
  326. data/lib/tdlib/types/message_content/contact.rb +8 -0
  327. data/lib/tdlib/types/message_content/contact_registered.rb +5 -0
  328. data/lib/tdlib/types/message_content/custom_service_action.rb +8 -0
  329. data/lib/tdlib/types/message_content/document.rb +10 -0
  330. data/lib/tdlib/types/message_content/expired_photo.rb +5 -0
  331. data/lib/tdlib/types/message_content/expired_video.rb +5 -0
  332. data/lib/tdlib/types/message_content/game.rb +8 -0
  333. data/lib/tdlib/types/message_content/game_score.rb +13 -0
  334. data/lib/tdlib/types/message_content/invoice.rb +26 -0
  335. data/lib/tdlib/types/message_content/location.rb +14 -0
  336. data/lib/tdlib/types/message_content/passport_data_received.rb +10 -0
  337. data/lib/tdlib/types/message_content/passport_data_sent.rb +8 -0
  338. data/lib/tdlib/types/message_content/payment_successful.rb +13 -0
  339. data/lib/tdlib/types/message_content/payment_successful_bot.rb +24 -0
  340. data/lib/tdlib/types/message_content/photo.rb +12 -0
  341. data/lib/tdlib/types/message_content/pin_message.rb +8 -0
  342. data/lib/tdlib/types/message_content/screenshot_taken.rb +5 -0
  343. data/lib/tdlib/types/message_content/sticker.rb +8 -0
  344. data/lib/tdlib/types/message_content/supergroup_chat_create.rb +8 -0
  345. data/lib/tdlib/types/message_content/text.rb +10 -0
  346. data/lib/tdlib/types/message_content/unsupported.rb +5 -0
  347. data/lib/tdlib/types/message_content/venue.rb +8 -0
  348. data/lib/tdlib/types/message_content/video.rb +13 -0
  349. data/lib/tdlib/types/message_content/video_note.rb +13 -0
  350. data/lib/tdlib/types/message_content/voice_note.rb +12 -0
  351. data/lib/tdlib/types/message_content/website_connected.rb +8 -0
  352. data/lib/tdlib/types/message_forward_info.rb +11 -0
  353. data/lib/tdlib/types/message_forward_info/message_forwarded_from_user.rb +16 -0
  354. data/lib/tdlib/types/message_forward_info/message_forwarded_post.rb +21 -0
  355. data/lib/tdlib/types/message_sending_state.rb +11 -0
  356. data/lib/tdlib/types/message_sending_state/failed.rb +5 -0
  357. data/lib/tdlib/types/message_sending_state/pending.rb +5 -0
  358. data/lib/tdlib/types/messages.rb +10 -0
  359. data/lib/tdlib/types/network_statistics.rb +10 -0
  360. data/lib/tdlib/types/network_statistics_entry.rb +11 -0
  361. data/lib/tdlib/types/network_statistics_entry/call.rb +15 -0
  362. data/lib/tdlib/types/network_statistics_entry/file.rb +15 -0
  363. data/lib/tdlib/types/network_type.rb +14 -0
  364. data/lib/tdlib/types/network_type/mobile.rb +5 -0
  365. data/lib/tdlib/types/network_type/mobile_roaming.rb +5 -0
  366. data/lib/tdlib/types/network_type/none.rb +5 -0
  367. data/lib/tdlib/types/network_type/other.rb +5 -0
  368. data/lib/tdlib/types/network_type/wi_fi.rb +5 -0
  369. data/lib/tdlib/types/notification_settings_scope.rb +11 -0
  370. data/lib/tdlib/types/notification_settings_scope/group_chats.rb +6 -0
  371. data/lib/tdlib/types/notification_settings_scope/private_chats.rb +6 -0
  372. data/lib/tdlib/types/ok.rb +5 -0
  373. data/lib/tdlib/types/option_value.rb +13 -0
  374. data/lib/tdlib/types/option_value/boolean.rb +8 -0
  375. data/lib/tdlib/types/option_value/empty.rb +5 -0
  376. data/lib/tdlib/types/option_value/integer.rb +8 -0
  377. data/lib/tdlib/types/option_value/string.rb +8 -0
  378. data/lib/tdlib/types/order_info.rb +14 -0
  379. data/lib/tdlib/types/page_block.rb +32 -0
  380. data/lib/tdlib/types/page_block/anchor.rb +8 -0
  381. data/lib/tdlib/types/page_block/animation.rb +12 -0
  382. data/lib/tdlib/types/page_block/audio.rb +10 -0
  383. data/lib/tdlib/types/page_block/author_date.rb +10 -0
  384. data/lib/tdlib/types/page_block/block_quote.rb +10 -0
  385. data/lib/tdlib/types/page_block/chat_link.rb +12 -0
  386. data/lib/tdlib/types/page_block/collage.rb +10 -0
  387. data/lib/tdlib/types/page_block/cover.rb +8 -0
  388. data/lib/tdlib/types/page_block/divider.rb +5 -0
  389. data/lib/tdlib/types/page_block/embedded.rb +22 -0
  390. data/lib/tdlib/types/page_block/embedded_post.rb +18 -0
  391. data/lib/tdlib/types/page_block/footer.rb +8 -0
  392. data/lib/tdlib/types/page_block/header.rb +8 -0
  393. data/lib/tdlib/types/page_block/list.rb +10 -0
  394. data/lib/tdlib/types/page_block/paragraph.rb +8 -0
  395. data/lib/tdlib/types/page_block/photo.rb +10 -0
  396. data/lib/tdlib/types/page_block/preformatted.rb +10 -0
  397. data/lib/tdlib/types/page_block/pull_quote.rb +10 -0
  398. data/lib/tdlib/types/page_block/slideshow.rb +10 -0
  399. data/lib/tdlib/types/page_block/subheader.rb +8 -0
  400. data/lib/tdlib/types/page_block/subtitle.rb +8 -0
  401. data/lib/tdlib/types/page_block/title.rb +8 -0
  402. data/lib/tdlib/types/page_block/video.rb +14 -0
  403. data/lib/tdlib/types/passport_authorization_form.rb +17 -0
  404. data/lib/tdlib/types/passport_element.rb +22 -0
  405. data/lib/tdlib/types/passport_element/address.rb +8 -0
  406. data/lib/tdlib/types/passport_element/bank_statement.rb +8 -0
  407. data/lib/tdlib/types/passport_element/driver_license.rb +8 -0
  408. data/lib/tdlib/types/passport_element/email_address.rb +8 -0
  409. data/lib/tdlib/types/passport_element/identity_card.rb +8 -0
  410. data/lib/tdlib/types/passport_element/internal_passport.rb +8 -0
  411. data/lib/tdlib/types/passport_element/passport.rb +8 -0
  412. data/lib/tdlib/types/passport_element/passport_registration.rb +8 -0
  413. data/lib/tdlib/types/passport_element/personal_details.rb +8 -0
  414. data/lib/tdlib/types/passport_element/phone_number.rb +8 -0
  415. data/lib/tdlib/types/passport_element/rental_agreement.rb +8 -0
  416. data/lib/tdlib/types/passport_element/temporary_registration.rb +8 -0
  417. data/lib/tdlib/types/passport_element/utility_bill.rb +8 -0
  418. data/lib/tdlib/types/passport_element_error.rb +12 -0
  419. data/lib/tdlib/types/passport_element_error_source.rb +18 -0
  420. data/lib/tdlib/types/passport_element_error_source/data_field.rb +9 -0
  421. data/lib/tdlib/types/passport_element_error_source/file.rb +6 -0
  422. data/lib/tdlib/types/passport_element_error_source/files.rb +6 -0
  423. data/lib/tdlib/types/passport_element_error_source/front_side.rb +6 -0
  424. data/lib/tdlib/types/passport_element_error_source/reverse_side.rb +6 -0
  425. data/lib/tdlib/types/passport_element_error_source/selfie.rb +6 -0
  426. data/lib/tdlib/types/passport_element_error_source/translation_file.rb +6 -0
  427. data/lib/tdlib/types/passport_element_error_source/translation_files.rb +6 -0
  428. data/lib/tdlib/types/passport_element_error_source/unspecified.rb +6 -0
  429. data/lib/tdlib/types/passport_element_type.rb +22 -0
  430. data/lib/tdlib/types/passport_element_type/address.rb +5 -0
  431. data/lib/tdlib/types/passport_element_type/bank_statement.rb +5 -0
  432. data/lib/tdlib/types/passport_element_type/driver_license.rb +5 -0
  433. data/lib/tdlib/types/passport_element_type/email_address.rb +5 -0
  434. data/lib/tdlib/types/passport_element_type/identity_card.rb +5 -0
  435. data/lib/tdlib/types/passport_element_type/internal_passport.rb +5 -0
  436. data/lib/tdlib/types/passport_element_type/passport.rb +5 -0
  437. data/lib/tdlib/types/passport_element_type/passport_registration.rb +5 -0
  438. data/lib/tdlib/types/passport_element_type/personal_details.rb +5 -0
  439. data/lib/tdlib/types/passport_element_type/phone_number.rb +5 -0
  440. data/lib/tdlib/types/passport_element_type/rental_agreement.rb +5 -0
  441. data/lib/tdlib/types/passport_element_type/temporary_registration.rb +5 -0
  442. data/lib/tdlib/types/passport_element_type/utility_bill.rb +5 -0
  443. data/lib/tdlib/types/passport_elements.rb +8 -0
  444. data/lib/tdlib/types/passport_required_element.rb +9 -0
  445. data/lib/tdlib/types/passport_suitable_element.rb +15 -0
  446. data/lib/tdlib/types/password_state.rb +17 -0
  447. data/lib/tdlib/types/payment_form.rb +23 -0
  448. data/lib/tdlib/types/payment_receipt.rb +18 -0
  449. data/lib/tdlib/types/payment_result.rb +11 -0
  450. data/lib/tdlib/types/payments_provider_stripe.rb +14 -0
  451. data/lib/tdlib/types/personal_details.rb +26 -0
  452. data/lib/tdlib/types/personal_document.rb +11 -0
  453. data/lib/tdlib/types/photo.rb +12 -0
  454. data/lib/tdlib/types/photo_size.rb +14 -0
  455. data/lib/tdlib/types/profile_photo.rb +13 -0
  456. data/lib/tdlib/types/proxies.rb +8 -0
  457. data/lib/tdlib/types/proxy.rb +18 -0
  458. data/lib/tdlib/types/proxy_type.rb +12 -0
  459. data/lib/tdlib/types/proxy_type/http.rb +13 -0
  460. data/lib/tdlib/types/proxy_type/mtproto.rb +8 -0
  461. data/lib/tdlib/types/proxy_type/socks5.rb +10 -0
  462. data/lib/tdlib/types/public_message_link.rb +10 -0
  463. data/lib/tdlib/types/recovery_email_address.rb +8 -0
  464. data/lib/tdlib/types/remote_file.rb +22 -0
  465. data/lib/tdlib/types/reply_markup.rb +13 -0
  466. data/lib/tdlib/types/reply_markup/force_reply.rb +10 -0
  467. data/lib/tdlib/types/reply_markup/inline_keyboard.rb +8 -0
  468. data/lib/tdlib/types/reply_markup/remove_keyboard.rb +11 -0
  469. data/lib/tdlib/types/reply_markup/show_keyboard.rb +16 -0
  470. data/lib/tdlib/types/rich_text.rb +18 -0
  471. data/lib/tdlib/types/rich_text/bold.rb +8 -0
  472. data/lib/tdlib/types/rich_text/email_address.rb +10 -0
  473. data/lib/tdlib/types/rich_text/fixed.rb +8 -0
  474. data/lib/tdlib/types/rich_text/italic.rb +8 -0
  475. data/lib/tdlib/types/rich_text/plain.rb +8 -0
  476. data/lib/tdlib/types/rich_text/s.rb +8 -0
  477. data/lib/tdlib/types/rich_text/strikethrough.rb +8 -0
  478. data/lib/tdlib/types/rich_text/underline.rb +8 -0
  479. data/lib/tdlib/types/rich_text/url.rb +10 -0
  480. data/lib/tdlib/types/saved_credentials.rb +10 -0
  481. data/lib/tdlib/types/scope_notification_settings.rb +13 -0
  482. data/lib/tdlib/types/search_messages_filter.rb +25 -0
  483. data/lib/tdlib/types/search_messages_filter/animation.rb +5 -0
  484. data/lib/tdlib/types/search_messages_filter/audio.rb +5 -0
  485. data/lib/tdlib/types/search_messages_filter/call.rb +5 -0
  486. data/lib/tdlib/types/search_messages_filter/chat_photo.rb +5 -0
  487. data/lib/tdlib/types/search_messages_filter/document.rb +5 -0
  488. data/lib/tdlib/types/search_messages_filter/empty.rb +5 -0
  489. data/lib/tdlib/types/search_messages_filter/mention.rb +5 -0
  490. data/lib/tdlib/types/search_messages_filter/missed_call.rb +5 -0
  491. data/lib/tdlib/types/search_messages_filter/photo.rb +5 -0
  492. data/lib/tdlib/types/search_messages_filter/photo_and_video.rb +5 -0
  493. data/lib/tdlib/types/search_messages_filter/unread_mention.rb +6 -0
  494. data/lib/tdlib/types/search_messages_filter/url.rb +5 -0
  495. data/lib/tdlib/types/search_messages_filter/video.rb +5 -0
  496. data/lib/tdlib/types/search_messages_filter/video_note.rb +5 -0
  497. data/lib/tdlib/types/search_messages_filter/voice_and_video_note.rb +5 -0
  498. data/lib/tdlib/types/search_messages_filter/voice_note.rb +5 -0
  499. data/lib/tdlib/types/seconds.rb +8 -0
  500. data/lib/tdlib/types/secret_chat.rb +26 -0
  501. data/lib/tdlib/types/secret_chat_state.rb +12 -0
  502. data/lib/tdlib/types/secret_chat_state/closed.rb +5 -0
  503. data/lib/tdlib/types/secret_chat_state/pending.rb +5 -0
  504. data/lib/tdlib/types/secret_chat_state/ready.rb +5 -0
  505. data/lib/tdlib/types/session.rb +39 -0
  506. data/lib/tdlib/types/sessions.rb +8 -0
  507. data/lib/tdlib/types/shipping_option.rb +13 -0
  508. data/lib/tdlib/types/sticker.rb +22 -0
  509. data/lib/tdlib/types/sticker_emojis.rb +10 -0
  510. data/lib/tdlib/types/sticker_set.rb +27 -0
  511. data/lib/tdlib/types/sticker_set_info.rb +29 -0
  512. data/lib/tdlib/types/sticker_sets.rb +10 -0
  513. data/lib/tdlib/types/stickers.rb +8 -0
  514. data/lib/tdlib/types/storage_statistics.rb +12 -0
  515. data/lib/tdlib/types/storage_statistics_by_chat.rb +14 -0
  516. data/lib/tdlib/types/storage_statistics_by_file_type.rb +12 -0
  517. data/lib/tdlib/types/storage_statistics_fast.rb +12 -0
  518. data/lib/tdlib/types/supergroup.rb +40 -0
  519. data/lib/tdlib/types/supergroup_full_info.rb +39 -0
  520. data/lib/tdlib/types/supergroup_members_filter.rb +15 -0
  521. data/lib/tdlib/types/supergroup_members_filter/administrators.rb +5 -0
  522. data/lib/tdlib/types/supergroup_members_filter/banned.rb +8 -0
  523. data/lib/tdlib/types/supergroup_members_filter/bots.rb +5 -0
  524. data/lib/tdlib/types/supergroup_members_filter/recent.rb +5 -0
  525. data/lib/tdlib/types/supergroup_members_filter/restricted.rb +8 -0
  526. data/lib/tdlib/types/supergroup_members_filter/search.rb +8 -0
  527. data/lib/tdlib/types/t_me_url.rb +10 -0
  528. data/lib/tdlib/types/t_me_url_type.rb +13 -0
  529. data/lib/tdlib/types/t_me_url_type/chat_invite.rb +8 -0
  530. data/lib/tdlib/types/t_me_url_type/sticker_set.rb +8 -0
  531. data/lib/tdlib/types/t_me_url_type/supergroup.rb +8 -0
  532. data/lib/tdlib/types/t_me_url_type/user.rb +8 -0
  533. data/lib/tdlib/types/t_me_urls.rb +8 -0
  534. data/lib/tdlib/types/tdlib_parameters.rb +46 -0
  535. data/lib/tdlib/types/temporary_password_state.rb +10 -0
  536. data/lib/tdlib/types/terms_of_service.rb +12 -0
  537. data/lib/tdlib/types/text.rb +8 -0
  538. data/lib/tdlib/types/text_entities.rb +8 -0
  539. data/lib/tdlib/types/text_entity.rb +12 -0
  540. data/lib/tdlib/types/text_entity_type.rb +23 -0
  541. data/lib/tdlib/types/text_entity_type/bold.rb +5 -0
  542. data/lib/tdlib/types/text_entity_type/bot_command.rb +6 -0
  543. data/lib/tdlib/types/text_entity_type/cashtag.rb +6 -0
  544. data/lib/tdlib/types/text_entity_type/code.rb +5 -0
  545. data/lib/tdlib/types/text_entity_type/email_address.rb +5 -0
  546. data/lib/tdlib/types/text_entity_type/hashtag.rb +5 -0
  547. data/lib/tdlib/types/text_entity_type/italic.rb +5 -0
  548. data/lib/tdlib/types/text_entity_type/mention.rb +5 -0
  549. data/lib/tdlib/types/text_entity_type/mention_name.rb +8 -0
  550. data/lib/tdlib/types/text_entity_type/phone_number.rb +5 -0
  551. data/lib/tdlib/types/text_entity_type/pre.rb +5 -0
  552. data/lib/tdlib/types/text_entity_type/pre_code.rb +8 -0
  553. data/lib/tdlib/types/text_entity_type/text_url.rb +8 -0
  554. data/lib/tdlib/types/text_entity_type/url.rb +5 -0
  555. data/lib/tdlib/types/text_parse_mode.rb +11 -0
  556. data/lib/tdlib/types/text_parse_mode/html.rb +5 -0
  557. data/lib/tdlib/types/text_parse_mode/markdown.rb +5 -0
  558. data/lib/tdlib/types/top_chat_category.rb +15 -0
  559. data/lib/tdlib/types/top_chat_category/bots.rb +5 -0
  560. data/lib/tdlib/types/top_chat_category/calls.rb +5 -0
  561. data/lib/tdlib/types/top_chat_category/channels.rb +5 -0
  562. data/lib/tdlib/types/top_chat_category/groups.rb +5 -0
  563. data/lib/tdlib/types/top_chat_category/inline_bots.rb +5 -0
  564. data/lib/tdlib/types/top_chat_category/users.rb +5 -0
  565. data/lib/tdlib/types/update.rb +70 -0
  566. data/lib/tdlib/types/update/authorization_state.rb +8 -0
  567. data/lib/tdlib/types/update/basic_group.rb +9 -0
  568. data/lib/tdlib/types/update/basic_group_full_info.rb +10 -0
  569. data/lib/tdlib/types/update/call.rb +8 -0
  570. data/lib/tdlib/types/update/chat_default_disable_notification.rb +10 -0
  571. data/lib/tdlib/types/update/chat_draft_message.rb +14 -0
  572. data/lib/tdlib/types/update/chat_is_marked_as_unread.rb +10 -0
  573. data/lib/tdlib/types/update/chat_is_pinned.rb +12 -0
  574. data/lib/tdlib/types/update/chat_is_sponsored.rb +12 -0
  575. data/lib/tdlib/types/update/chat_last_message.rb +14 -0
  576. data/lib/tdlib/types/update/chat_notification_settings.rb +10 -0
  577. data/lib/tdlib/types/update/chat_order.rb +11 -0
  578. data/lib/tdlib/types/update/chat_photo.rb +10 -0
  579. data/lib/tdlib/types/update/chat_read_inbox.rb +12 -0
  580. data/lib/tdlib/types/update/chat_read_outbox.rb +10 -0
  581. data/lib/tdlib/types/update/chat_reply_markup.rb +13 -0
  582. data/lib/tdlib/types/update/chat_title.rb +10 -0
  583. data/lib/tdlib/types/update/chat_unread_mention_count.rb +10 -0
  584. data/lib/tdlib/types/update/connection_state.rb +8 -0
  585. data/lib/tdlib/types/update/delete_messages.rb +16 -0
  586. data/lib/tdlib/types/update/favorite_stickers.rb +8 -0
  587. data/lib/tdlib/types/update/file.rb +8 -0
  588. data/lib/tdlib/types/update/file_generation_start.rb +17 -0
  589. data/lib/tdlib/types/update/file_generation_stop.rb +8 -0
  590. data/lib/tdlib/types/update/installed_sticker_sets.rb +10 -0
  591. data/lib/tdlib/types/update/language_pack_strings.rb +12 -0
  592. data/lib/tdlib/types/update/message_content.rb +12 -0
  593. data/lib/tdlib/types/update/message_content_opened.rb +12 -0
  594. data/lib/tdlib/types/update/message_edited.rb +15 -0
  595. data/lib/tdlib/types/update/message_mention_read.rb +12 -0
  596. data/lib/tdlib/types/update/message_send_acknowledged.rb +14 -0
  597. data/lib/tdlib/types/update/message_send_failed.rb +16 -0
  598. data/lib/tdlib/types/update/message_send_succeeded.rb +11 -0
  599. data/lib/tdlib/types/update/message_views.rb +12 -0
  600. data/lib/tdlib/types/update/new_callback_query.rb +18 -0
  601. data/lib/tdlib/types/update/new_chat.rb +10 -0
  602. data/lib/tdlib/types/update/new_chosen_inline_result.rb +16 -0
  603. data/lib/tdlib/types/update/new_custom_event.rb +8 -0
  604. data/lib/tdlib/types/update/new_custom_query.rb +12 -0
  605. data/lib/tdlib/types/update/new_inline_callback_query.rb +16 -0
  606. data/lib/tdlib/types/update/new_inline_query.rb +16 -0
  607. data/lib/tdlib/types/update/new_message.rb +12 -0
  608. data/lib/tdlib/types/update/new_pre_checkout_query.rb +22 -0
  609. data/lib/tdlib/types/update/new_shipping_query.rb +15 -0
  610. data/lib/tdlib/types/update/option.rb +10 -0
  611. data/lib/tdlib/types/update/recent_stickers.rb +11 -0
  612. data/lib/tdlib/types/update/saved_animations.rb +8 -0
  613. data/lib/tdlib/types/update/scope_notification_settings.rb +10 -0
  614. data/lib/tdlib/types/update/secret_chat.rb +9 -0
  615. data/lib/tdlib/types/update/service_notification.rb +13 -0
  616. data/lib/tdlib/types/update/supergroup.rb +9 -0
  617. data/lib/tdlib/types/update/supergroup_full_info.rb +10 -0
  618. data/lib/tdlib/types/update/terms_of_service.rb +12 -0
  619. data/lib/tdlib/types/update/trending_sticker_sets.rb +8 -0
  620. data/lib/tdlib/types/update/unread_chat_count.rb +16 -0
  621. data/lib/tdlib/types/update/unread_message_count.rb +11 -0
  622. data/lib/tdlib/types/update/user.rb +9 -0
  623. data/lib/tdlib/types/update/user_chat_action.rb +12 -0
  624. data/lib/tdlib/types/update/user_full_info.rb +10 -0
  625. data/lib/tdlib/types/update/user_privacy_setting_rules.rb +10 -0
  626. data/lib/tdlib/types/update/user_status.rb +10 -0
  627. data/lib/tdlib/types/user.rb +41 -0
  628. data/lib/tdlib/types/user_full_info.rb +21 -0
  629. data/lib/tdlib/types/user_privacy_setting.rb +12 -0
  630. data/lib/tdlib/types/user_privacy_setting/allow_calls.rb +5 -0
  631. data/lib/tdlib/types/user_privacy_setting/allow_chat_invites.rb +5 -0
  632. data/lib/tdlib/types/user_privacy_setting/show_status.rb +5 -0
  633. data/lib/tdlib/types/user_privacy_setting_rule.rb +15 -0
  634. data/lib/tdlib/types/user_privacy_setting_rule/allow_all.rb +5 -0
  635. data/lib/tdlib/types/user_privacy_setting_rule/allow_contacts.rb +5 -0
  636. data/lib/tdlib/types/user_privacy_setting_rule/allow_users.rb +8 -0
  637. data/lib/tdlib/types/user_privacy_setting_rule/restrict_all.rb +5 -0
  638. data/lib/tdlib/types/user_privacy_setting_rule/restrict_contacts.rb +5 -0
  639. data/lib/tdlib/types/user_privacy_setting_rule/restrict_users.rb +8 -0
  640. data/lib/tdlib/types/user_privacy_setting_rules.rb +11 -0
  641. data/lib/tdlib/types/user_profile_photos.rb +10 -0
  642. data/lib/tdlib/types/user_status.rb +15 -0
  643. data/lib/tdlib/types/user_status/empty.rb +5 -0
  644. data/lib/tdlib/types/user_status/last_month.rb +5 -0
  645. data/lib/tdlib/types/user_status/last_week.rb +5 -0
  646. data/lib/tdlib/types/user_status/offline.rb +8 -0
  647. data/lib/tdlib/types/user_status/online.rb +8 -0
  648. data/lib/tdlib/types/user_status/recently.rb +5 -0
  649. data/lib/tdlib/types/user_type.rb +14 -0
  650. data/lib/tdlib/types/user_type/bot.rb +18 -0
  651. data/lib/tdlib/types/user_type/deleted.rb +7 -0
  652. data/lib/tdlib/types/user_type/regular.rb +5 -0
  653. data/lib/tdlib/types/user_type/unknown.rb +7 -0
  654. data/lib/tdlib/types/users.rb +10 -0
  655. data/lib/tdlib/types/validated_order_info.rb +11 -0
  656. data/lib/tdlib/types/venue.rb +19 -0
  657. data/lib/tdlib/types/video.rb +24 -0
  658. data/lib/tdlib/types/video_note.rb +15 -0
  659. data/lib/tdlib/types/voice_note.rb +16 -0
  660. data/lib/tdlib/types/wallpaper.rb +14 -0
  661. data/lib/tdlib/types/wallpapers.rb +8 -0
  662. data/lib/tdlib/types/web_page.rb +51 -0
  663. data/lib/tdlib/types/web_page_instant_view.rb +11 -0
  664. data/lib/tdlib/update_handler.rb +36 -0
  665. data/lib/tdlib/update_manager.rb +21 -11
  666. data/lib/tdlib/version.rb +1 -1
  667. data/spec/integration/tdlib_spec.rb +20 -15
  668. data/tdlib-ruby.gemspec +7 -12
  669. metadata +720 -9
  670. data/lib/tdlib/utils.rb +0 -7
@@ -20,6 +20,7 @@ module TD
20
20
  setting :use_test_dc, false
21
21
  setting :database_directory, "#{Dir.home}/.tdlib-ruby/db"
22
22
  setting :files_directory, "#{Dir.home}/.tdlib-ruby/data"
23
+ setting :use_file_database, true
23
24
  setting :use_chat_info_database, true
24
25
  setting :use_secret_chats, true
25
26
  setting :use_message_database, true
@@ -34,6 +35,8 @@ end
34
35
 
35
36
  require 'tdlib/errors'
36
37
  require 'tdlib/api'
37
- require 'tdlib/utils'
38
+ require 'tdlib/types'
39
+ require 'tdlib/client_methods'
38
40
  require 'tdlib/client'
41
+ require 'tdlib/update_handler'
39
42
  require 'tdlib/update_manager'
@@ -1,5 +1,5 @@
1
- require 'fiddle/import'
2
1
  require 'json'
2
+ require 'ffi'
3
3
 
4
4
  module TD::Api
5
5
  module_function
@@ -18,7 +18,7 @@ module TD::Api
18
18
 
19
19
  def client_receive(client, timeout)
20
20
  update = Dl.td_json_client_receive(client, timeout)
21
- update.null? ? nil : JSON.parse(update.to_s)
21
+ JSON.parse(update) if update
22
22
  end
23
23
 
24
24
  def client_destroy(client)
@@ -34,7 +34,7 @@ module TD::Api
34
34
  end
35
35
 
36
36
  module Dl
37
- extend Fiddle::Importer
37
+ extend FFI::Library
38
38
 
39
39
  @mutex = Mutex.new
40
40
 
@@ -42,16 +42,18 @@ module TD::Api
42
42
 
43
43
  def method_missing(method_name, *args)
44
44
  @mutex.synchronize do
45
- return if respond_to?(method_name)
46
- dlload(find_lib)
45
+ return public_send(method_name, *args) if respond_to?(method_name)
47
46
 
48
- extern 'void* td_json_client_create()'
49
- extern 'void* td_json_client_send(void*, char*)'
50
- extern 'char* td_json_client_receive(void*, double)'
51
- extern 'char* td_json_client_execute(void*, char*)'
52
- extern 'void td_set_log_verbosity_level(int)'
53
- extern 'void td_json_client_destroy(void*)'
54
- extern 'void td_set_log_file_path(char*)'
47
+ find_lib
48
+
49
+ attach_function :td_json_client_create, [], :pointer
50
+ attach_function :td_json_client_receive, [:pointer, :double], :string, blocking: true
51
+ attach_function :td_json_client_send, [:pointer, :string], :pointer, blocking: true
52
+ attach_function :td_json_client_execute, [:pointer, :string], :string, blocking: true
53
+ attach_function :td_json_client_destroy, [:pointer], :void
54
+ attach_function :td_set_log_file_path, [:string], :int
55
+ attach_function :td_set_log_max_file_size, [:long_long], :void
56
+ attach_function :td_set_log_verbosity_level, [:int], :void
55
57
 
56
58
  undef method_missing
57
59
  public_send(method_name, *args)
@@ -66,9 +68,12 @@ module TD::Api
66
68
  elsif defined?(Rails) && File.exist?(Rails.root.join('vendor', file_name))
67
69
  Rails.root.join('vendor')
68
70
  end
69
- return `ldconfig -p | grep libtdjson`[/=> (.*?)\n/m, 1] if os == :linux && lib_path.nil?
70
- raise TD::MissingLibPathError unless lib_path
71
- File.join(lib_path, file_name)
71
+ full_path = File.join(lib_path.to_s, file_name)
72
+ ffi_lib full_path
73
+ full_path
74
+ rescue LoadError
75
+ ffi_lib 'tdjson'
76
+ ffi_libraries.first.name
72
77
  end
73
78
 
74
79
  def lib_extension
@@ -1,108 +1,91 @@
1
+ require 'securerandom'
2
+
1
3
  # Simple client for TDLib.
2
- # @example
3
- # TD.configure do |config|
4
- # config.lib_path = 'path_to_tdlibjson'
5
- # config.encryption_key = 'your_encryption_key'
6
- #
7
- # config.client.api_id = your_api_id
8
- # config.client.api_hash = 'your_api_hash'
9
- # end
10
- #
11
- # client = TD::Client.new
12
- #
13
- # begin
14
- # state = nil
15
- #
16
- # client.on('updateAuthorizationState') do |update|
17
- # next unless update.dig('authorization_state', '@type') == 'authorizationStateWaitPhoneNumber'
18
- # state = :wait_phone
19
- # end
20
- #
21
- # client.on('updateAuthorizationState') do |update|
22
- # next unless update.dig('authorization_state', '@type') == 'authorizationStateWaitCode'
23
- # state = :wait_code
24
- # end
25
- #
26
- # client.on('updateAuthorizationState') do |update|
27
- # next unless update.dig('authorization_state', '@type') == 'authorizationStateReady'
28
- # state = :ready
29
- # end
30
- #
31
- # loop do
32
- # case state
33
- # when :wait_phone
34
- # p 'Please, enter your phone number:'
35
- # phone = STDIN.gets.strip
36
- # params = {
37
- # '@type' => 'setAuthenticationPhoneNumber',
38
- # 'phone_number' => phone
39
- # }
40
- # client.broadcast_and_receive(params)
41
- # when :wait_code
42
- # p 'Please, enter code from SMS:'
43
- # code = STDIN.gets.strip
44
- # params = {
45
- # '@type' => 'checkAuthenticationCode',
46
- # 'code' => code
47
- # }
48
- # client.broadcast_and_receive(params)
49
- # when :ready
50
- # @me = client.broadcast_and_receive('@type' => 'getMe')
51
- # break
52
- # end
53
- # end
54
- #
55
- # ensure
56
- # client.close
57
- # end
58
- #
59
- # p @me
60
4
  class TD::Client
61
5
  include Concurrent
6
+ include TD::ClientMethods
62
7
 
63
8
  TIMEOUT = 20
64
9
 
10
+ def self.ready(*args)
11
+ new(*args).connect
12
+ end
13
+
14
+ # @param [FFI::Pointer] td_client
15
+ # @param [TD::UpdateManager] update_manager
16
+ # @param [Numeric] timeout
17
+ # @param [Hash] extra_config optional configuration hash that will be merged into tdlib client configuration
65
18
  def initialize(td_client = TD::Api.client_create,
66
19
  update_manager = TD::UpdateManager.new(td_client),
67
- proxy: { '@type' => 'proxyEmpty' },
20
+ timeout: TIMEOUT,
68
21
  **extra_config)
69
22
  @td_client = td_client
23
+ @ready = false
24
+ @alive = true
70
25
  @update_manager = update_manager
26
+ @timeout = timeout
71
27
  @config = TD.config.client.to_h.merge(extra_config)
72
- @proxy = proxy
73
28
  @ready_condition_mutex = Mutex.new
74
29
  @ready_condition = ConditionVariable.new
75
- authorize
30
+ end
31
+
32
+ # Adds initial authorization state handler and runs update manager
33
+ # Returns future that will be fulfilled when client is ready
34
+ # @return [Concurrent::Promises::Future]
35
+ def connect
36
+ on TD::Types::Update::AuthorizationState do |update|
37
+ case update.authorization_state
38
+ when TD::Types::AuthorizationState::WaitTdlibParameters
39
+ set_tdlib_parameters(TD::Types::TdlibParameters.new(**@config))
40
+ when TD::Types::AuthorizationState::WaitEncryptionKey
41
+ check_database_encryption_key(TD.config.encryption_key).then do
42
+ @ready_condition_mutex.synchronize do
43
+ @ready = true
44
+ @ready_condition.broadcast
45
+ end
46
+ end
47
+ else
48
+ # do nothing
49
+ end
50
+ end
51
+
76
52
  @update_manager.run
53
+ ready
77
54
  end
78
55
 
79
56
  # Sends asynchronous request to the TDLib client and returns Promise object
80
- # @see https://www.rubydoc.info/github/ruby-concurrency/concurrent-ruby/Concurrent/Promise)
57
+ # @see TD::ClientMethods List of available queries as methods
58
+ # @see https://github.com/ruby-concurrency/concurrent-ruby/blob/master/docs-source/promises.in.md
59
+ # Concurrent::Promise documentation
81
60
  # @example
82
- # client.broadcast(some_query).then { |result| puts result }.rescue
61
+ # client.broadcast(some_query).then { |result| puts result }.rescue { |error| puts [error.code, error.message] }
83
62
  # @param [Hash] query
84
- # @param [Numeric] timeout
85
- # @return [Concurrent::Promise]
86
- def broadcast(query, timeout: TIMEOUT)
87
- Promise.execute do
63
+ # @return [Concurrent::Promises::Future]
64
+ def broadcast(query)
65
+ return dead_client_promise if dead?
66
+
67
+ Promises.future do
88
68
  condition = ConditionVariable.new
89
- extra = TD::Utils.generate_extra(query)
69
+ extra = SecureRandom.uuid
90
70
  result = nil
91
71
  mutex = Mutex.new
92
- handler = ->(update) do
93
- return unless update['@extra'] == extra
72
+
73
+ @update_manager << TD::UpdateHandler.new(TD::Types::Base, extra, disposable: true) do |update|
94
74
  mutex.synchronize do
95
75
  result = update
96
- @update_manager.remove_handler(handler)
97
76
  condition.signal
98
77
  end
99
78
  end
100
- @update_manager.add_handler(handler)
79
+
101
80
  query['@extra'] = extra
81
+
102
82
  mutex.synchronize do
103
- TD::Api.client_send(@td_client, query)
104
- condition.wait(mutex, timeout)
105
- raise TD::TimeoutError if result.nil?
83
+ send_to_td_client(query)
84
+ condition.wait(mutex, @timeout)
85
+ error = nil
86
+ error = result if result.is_a?(TD::Types::Error)
87
+ error = timeout_error if result.nil?
88
+ raise TD::Error.new(error) if error
106
89
  result
107
90
  end
108
91
  end
@@ -111,8 +94,8 @@ class TD::Client
111
94
  # Sends asynchronous request to the TDLib client and returns received update synchronously
112
95
  # @param [Hash] query
113
96
  # @return [Hash]
114
- def fetch(query, timeout: TIMEOUT)
115
- broadcast(query, timeout: timeout).value
97
+ def fetch(query)
98
+ broadcast(query).value!
116
99
  end
117
100
 
118
101
  alias broadcast_and_receive fetch
@@ -121,70 +104,85 @@ class TD::Client
121
104
  # Only a few requests can be executed synchronously
122
105
  # @param [Hash] query
123
106
  def execute(query)
107
+ return dead_client_error if dead?
124
108
  TD::Api.client_execute(@td_client, query)
125
109
  end
126
110
 
127
- # Returns current authorization state (it's offline request)
128
- # @return [Hash]
129
- def authorization_state
130
- broadcast_and_receive('@type' => 'getAuthorizationState')
131
- end
132
-
133
111
  # Binds passed block as a handler for updates with type of *update_type*
134
- # @param [String] update_type
112
+ # @param [String, Class] update_type
135
113
  # @yield [update] yields update to the block as soon as it's received
136
- def on(update_type, &_)
137
- handler = ->(update) do
138
- return unless update['@type'] == update_type
139
- yield update
114
+ def on(update_type, &action)
115
+ if update_type.is_a?(String)
116
+ if (type_const = TD::Types::LOOKUP_TABLE[update_type])
117
+ update_type = TD::Types.const_get("TD::Types::#{type_const}")
118
+ else
119
+ raise ArgumentError.new("Can't find class for #{update_type}")
120
+ end
121
+ end
122
+
123
+ unless update_type < TD::Types::Base
124
+ raise ArgumentError.new("Wrong type specified (#{update_type}). Should be of kind TD::Types::Base")
140
125
  end
141
- @update_manager.add_handler(handler)
126
+
127
+ @update_manager << TD::UpdateHandler.new(update_type, &action)
142
128
  end
143
129
 
144
- def on_ready(timeout: TIMEOUT, &_)
145
- @ready_condition_mutex.synchronize do
146
- return(yield self) if @ready || (@ready_condition.wait(@ready_condition_mutex, timeout) && @ready)
147
- raise TD::TimeoutError
130
+ # returns future that will be fulfilled when client is ready
131
+ # @return [Concurrent::Promises::Future]
132
+ def ready
133
+ return dead_client_promise if dead?
134
+ return Promises.fulfilled_future(self) if ready?
135
+
136
+ Promises.future do
137
+ @ready_condition_mutex.synchronize do
138
+ next self if @ready || (@ready_condition.wait(@ready_condition_mutex, @timeout) && @ready)
139
+ raise TD::Error.new(timeout_error)
140
+ end
148
141
  end
149
142
  end
150
143
 
144
+ # @deprecated
145
+ def on_ready(&action)
146
+ ready.then(&action).value!
147
+ end
148
+
151
149
  # Stops update manager and destroys TDLib client
152
- def close
150
+ def dispose
151
+ return if dead?
153
152
  @update_manager.stop
153
+ @alive = false
154
+ @ready = false
154
155
  TD::Api.client_destroy(@td_client)
155
156
  end
156
157
 
158
+ def alive?
159
+ @alive
160
+ end
161
+
162
+ def dead?
163
+ !alive?
164
+ end
165
+
166
+ def ready?
167
+ @ready
168
+ end
169
+
157
170
  private
158
171
 
159
- def authorize
160
- tdlib_params_query = {
161
- '@type' => 'setTdlibParameters',
162
- parameters: { '@type' => 'tdlibParameters', **@config }
163
- }
164
- encryption_key_query = {
165
- '@type' => 'checkDatabaseEncryptionKey',
166
- }
167
-
168
- if TD.config.encryption_key
169
- encryption_key_query['encryption_key'] = TD.config.encryption_key
170
- end
172
+ def send_to_td_client(query)
173
+ return unless alive?
174
+ TD::Api.client_send(@td_client, query)
175
+ end
171
176
 
172
- handler = ->(update) do
173
- return unless update['@type'] == 'updateAuthorizationState'
174
- case update.dig('authorization_state', '@type')
175
- when 'authorizationStateWaitTdlibParameters'
176
- broadcast(tdlib_params_query)
177
- when 'authorizationStateWaitEncryptionKey'
178
- broadcast(encryption_key_query)
179
- else
180
- broadcast('@type' => 'setProxy', 'proxy' => @proxy)
181
- @update_manager.remove_handler(handler)
182
- @ready_condition_mutex.synchronize do
183
- @ready = true
184
- @ready_condition.broadcast
185
- end
186
- end
187
- end
188
- @update_manager.add_handler(handler)
177
+ def timeout_error
178
+ TD::Types::Error.new(code: 0, message: 'Timeout error')
179
+ end
180
+
181
+ def dead_client_promise
182
+ Promises.rejected_future(dead_client_error)
183
+ end
184
+
185
+ def dead_client_error
186
+ TD::Error.new(TD::Types::Error.new(code: 0, message: 'TD client is dead'))
189
187
  end
190
188
  end
@@ -0,0 +1,3474 @@
1
+ # This is a generated module from current TDLib scheme
2
+ # It contains all available TDLib methods
3
+ module TD::ClientMethods
4
+ # Accepts an incoming call.
5
+ #
6
+ # @param call_id [Integer] Call identifier.
7
+ # @param protocol [TD::Types::CallProtocol] Description of the call protocols supported by the client.
8
+ # @return [TD::Types::Ok]
9
+ def accept_call(call_id, protocol)
10
+ broadcast('@type' => 'acceptCall',
11
+ 'call_id' => call_id,
12
+ 'protocol' => protocol)
13
+ end
14
+
15
+ # Accepts Telegram terms of services.
16
+ #
17
+ # @param terms_of_service_id [String] Terms of service identifier.
18
+ # @return [TD::Types::Ok]
19
+ def accept_terms_of_service(terms_of_service_id)
20
+ broadcast('@type' => 'acceptTermsOfService',
21
+ 'terms_of_service_id' => terms_of_service_id)
22
+ end
23
+
24
+ # Adds a new member to a chat.
25
+ # Members can't be added to private or secret chats.
26
+ # Members will not be added until the chat state has been synchronized with the server.
27
+ #
28
+ # @param chat_id [Integer] Chat identifier.
29
+ # @param user_id [Integer] Identifier of the user.
30
+ # @param forward_limit [Integer] The number of earlier messages from the chat to be forwarded to the new member; up
31
+ # to 300.
32
+ # Ignored for supergroups and channels.
33
+ # @return [TD::Types::Ok]
34
+ def add_chat_member(chat_id, user_id, forward_limit: 300)
35
+ broadcast('@type' => 'addChatMember',
36
+ 'chat_id' => chat_id,
37
+ 'user_id' => user_id,
38
+ 'forward_limit' => forward_limit)
39
+ end
40
+
41
+ # Adds multiple new members to a chat.
42
+ # Currently this option is only available for supergroups and channels.
43
+ # This option can't be used to join a chat.
44
+ # Members can't be added to a channel if it has more than 200 members.
45
+ # Members will not be added until the chat state has been synchronized with the server.
46
+ #
47
+ # @param chat_id [Integer] Chat identifier.
48
+ # @param user_ids [Array<Integer>] Identifiers of the users to be added to the chat.
49
+ # @return [TD::Types::Ok]
50
+ def add_chat_members(chat_id, user_ids)
51
+ broadcast('@type' => 'addChatMembers',
52
+ 'chat_id' => chat_id,
53
+ 'user_ids' => user_ids)
54
+ end
55
+
56
+ # Adds a new sticker to the list of favorite stickers.
57
+ # The new sticker is added to the top of the list.
58
+ # If the sticker was already in the list, it is removed from the list first.
59
+ # Only stickers belonging to a sticker set can be added to this list.
60
+ #
61
+ # @param sticker [TD::Types::InputFile] Sticker file to add.
62
+ # @return [TD::Types::Ok]
63
+ def add_favorite_sticker(sticker)
64
+ broadcast('@type' => 'addFavoriteSticker',
65
+ 'sticker' => sticker)
66
+ end
67
+
68
+ # Adds a local message to a chat.
69
+ # The message is persistent across application restarts only if the message database is used.
70
+ #
71
+ # @param chat_id [Integer] Target chat.
72
+ # @param sender_user_id [Integer] Identifier of the user who will be shown as the sender of the message; may be 0 for
73
+ # channel posts.
74
+ # @param reply_to_message_id [Integer] Identifier of the message to reply to or 0.
75
+ # @param disable_notification [Boolean] Pass true to disable notification for the message.
76
+ # @param input_message_content [TD::Types::InputMessageContent] The content of the message to be added.
77
+ # @return [TD::Types::Message] the added message.
78
+ def add_local_message(chat_id, input_message_content,
79
+ sender_user_id: 0, reply_to_message_id: 0, disable_notification: false)
80
+ broadcast('@type' => 'addLocalMessage',
81
+ 'chat_id' => chat_id,
82
+ 'sender_user_id' => sender_user_id,
83
+ 'reply_to_message_id' => reply_to_message_id,
84
+ 'disable_notification' => disable_notification,
85
+ 'input_message_content' => input_message_content)
86
+ end
87
+
88
+ # Adds the specified data to data usage statistics.
89
+ # Can be called before authorization.
90
+ #
91
+ # @param entry [TD::Types::NetworkStatisticsEntry] The network statistics entry with the data to be added to
92
+ # statistics.
93
+ # @return [TD::Types::Ok]
94
+ def add_network_statistics(entry)
95
+ broadcast('@type' => 'addNetworkStatistics',
96
+ 'entry' => entry)
97
+ end
98
+
99
+ # Adds a proxy server for network requests.
100
+ # Can be called before authorization.
101
+ #
102
+ # @param server [String] Proxy server IP address.
103
+ # @param port [Integer] Proxy server port.
104
+ # @param enable [Boolean] True, if the proxy should be enabled.
105
+ # @param type [TD::Types::ProxyType] Proxy type.
106
+ # @return [TD::Types::Proxy]
107
+ def add_proxy(server, port, type, enable = false)
108
+ broadcast('@type' => 'addProxy',
109
+ 'server' => server,
110
+ 'port' => port,
111
+ 'enable' => enable,
112
+ 'type' => type)
113
+ end
114
+
115
+ # Manually adds a new sticker to the list of recently used stickers.
116
+ # The new sticker is added to the top of the list.
117
+ # If the sticker was already in the list, it is removed from the list first.
118
+ # Only stickers belonging to a sticker set can be added to this list.
119
+ #
120
+ # @param is_attached [Boolean] Pass true to add the sticker to the list of stickers recently attached to photo or
121
+ # video files; pass false to add the sticker to the list of recently sent stickers.
122
+ # @param sticker [TD::Types::InputFile] Sticker file to add.
123
+ # @return [TD::Types::Stickers]
124
+ def add_recent_sticker(sticker, is_attached: false)
125
+ broadcast('@type' => 'addRecentSticker',
126
+ 'is_attached' => is_attached,
127
+ 'sticker' => sticker)
128
+ end
129
+
130
+ # Adds a chat to the list of recently found chats.
131
+ # The chat is added to the beginning of the list.
132
+ # If the chat is already in the list, it will be removed from the list first.
133
+ #
134
+ # @param chat_id [Integer] Identifier of the chat to add.
135
+ # @return [TD::Types::Ok]
136
+ def add_recently_found_chat(chat_id)
137
+ broadcast('@type' => 'addRecentlyFoundChat',
138
+ 'chat_id' => chat_id)
139
+ end
140
+
141
+ # Manually adds a new animation to the list of saved animations.
142
+ # The new animation is added to the beginning of the list.
143
+ # If the animation was already in the list, it is removed first.
144
+ # Only non-secret video animations with MIME type "video/mp4" can be added to the list.
145
+ #
146
+ # @param animation [TD::Types::InputFile] The animation file to be added.
147
+ # Only animations known to the server (i.e. successfully sent via a message) can be added to the list.
148
+ # @return [TD::Types::Ok]
149
+ def add_saved_animation(animation)
150
+ broadcast('@type' => 'addSavedAnimation',
151
+ 'animation' => animation)
152
+ end
153
+
154
+ # Adds a new sticker to a set; for bots only.
155
+ #
156
+ # @param user_id [Integer] Sticker set owner.
157
+ # @param name [String] Sticker set name.
158
+ # @param sticker [TD::Types::InputSticker] Sticker to add to the set.
159
+ # @return [TD::Types::StickerSet] the sticker set.
160
+ def add_sticker_to_set(user_id, name, sticker)
161
+ broadcast('@type' => 'addStickerToSet',
162
+ 'user_id' => user_id,
163
+ 'name' => name,
164
+ 'sticker' => sticker)
165
+ end
166
+
167
+ # Sets the result of a callback query; for bots only.
168
+ #
169
+ # @param callback_query_id [Integer] Identifier of the callback query.
170
+ # @param text [String] Text of the answer.
171
+ # @param show_alert [Boolean] If true, an alert should be shown to the user instead of a toast notification.
172
+ # @param url [String] URL to be opened.
173
+ # @param cache_time [Integer] Time during which the result of the query can be cached, in seconds.
174
+ # @return [TD::Types::Ok]
175
+ def answer_callback_query(callback_query_id, text, show_alert, url, cache_time)
176
+ broadcast('@type' => 'answerCallbackQuery',
177
+ 'callback_query_id' => callback_query_id,
178
+ 'text' => text,
179
+ 'show_alert' => show_alert,
180
+ 'url' => url,
181
+ 'cache_time' => cache_time)
182
+ end
183
+
184
+ # Answers a custom query; for bots only.
185
+ #
186
+ # @param custom_query_id [Integer] Identifier of a custom query.
187
+ # @param data [String] JSON-serialized answer to the query.
188
+ # @return [TD::Types::Ok]
189
+ def answer_custom_query(custom_query_id, data)
190
+ broadcast('@type' => 'answerCustomQuery',
191
+ 'custom_query_id' => custom_query_id,
192
+ 'data' => data)
193
+ end
194
+
195
+ # Sets the result of an inline query; for bots only.
196
+ #
197
+ # @param inline_query_id [Integer] Identifier of the inline query.
198
+ # @param is_personal [Boolean] True, if the result of the query can be cached for the specified user.
199
+ # @param results [Array<TD::Types::InputInlineQueryResult>] The results of the query.
200
+ # @param cache_time [Integer] Allowed time to cache the results of the query, in seconds.
201
+ # @param next_offset [String] Offset for the next inline query; pass an empty string if there are no more results.
202
+ # @param switch_pm_text [String] If non-empty, this text should be shown on the button that opens a private chat with
203
+ # the bot and sends a start message to the bot with the parameter switch_pm_parameter.
204
+ # @param switch_pm_parameter [String] The parameter for the bot start message.
205
+ # @return [TD::Types::Ok]
206
+ def answer_inline_query(inline_query_id, is_personal, results, cache_time, next_offset, switch_pm_text,
207
+ switch_pm_parameter)
208
+ broadcast('@type' => 'answerInlineQuery',
209
+ 'inline_query_id' => inline_query_id,
210
+ 'is_personal' => is_personal,
211
+ 'results' => results,
212
+ 'cache_time' => cache_time,
213
+ 'next_offset' => next_offset,
214
+ 'switch_pm_text' => switch_pm_text,
215
+ 'switch_pm_parameter' => switch_pm_parameter)
216
+ end
217
+
218
+ # Sets the result of a pre-checkout query; for bots only.
219
+ #
220
+ # @param pre_checkout_query_id [Integer] Identifier of the pre-checkout query.
221
+ # @param error_message [String, nil] An error message, empty on success.
222
+ # @return [TD::Types::Ok]
223
+ def answer_pre_checkout_query(pre_checkout_query_id, error_message: nil)
224
+ broadcast('@type' => 'answerPreCheckoutQuery',
225
+ 'pre_checkout_query_id' => pre_checkout_query_id,
226
+ 'error_message' => error_message)
227
+ end
228
+
229
+ # Sets the result of a shipping query; for bots only.
230
+ #
231
+ # @param shipping_query_id [Integer] Identifier of the shipping query.
232
+ # @param shipping_options [Array<TD::Types::ShippingOption>] Available shipping options.
233
+ # @param error_message [String, nil] An error message, empty on success.
234
+ # @return [TD::Types::Ok]
235
+ def answer_shipping_query(shipping_query_id, shipping_options, error_message: nil)
236
+ broadcast('@type' => 'answerShippingQuery',
237
+ 'shipping_query_id' => shipping_query_id,
238
+ 'shipping_options' => shipping_options,
239
+ 'error_message' => error_message)
240
+ end
241
+
242
+ # Adds a user to the blacklist.
243
+ #
244
+ # @param user_id [Integer] User identifier.
245
+ # @return [TD::Types::Ok]
246
+ def block_user(user_id)
247
+ broadcast('@type' => 'blockUser',
248
+ 'user_id' => user_id)
249
+ end
250
+
251
+ # Stops the downloading of a file.
252
+ # If a file has already been downloaded, does nothing.
253
+ #
254
+ # @param file_id [Integer] Identifier of a file to stop downloading.
255
+ # @param only_if_pending [Boolean] Pass true to stop downloading only if it hasn't been started, i.e.
256
+ # request hasn't been sent to server.
257
+ # @return [TD::Types::Ok]
258
+ def cancel_download_file(file_id, only_if_pending: false)
259
+ broadcast('@type' => 'cancelDownloadFile',
260
+ 'file_id' => file_id,
261
+ 'only_if_pending' => only_if_pending)
262
+ end
263
+
264
+ # Stops the uploading of a file.
265
+ # Supported only for files uploaded by using {#upload_file}.
266
+ # For other files the behavior is undefined.
267
+ #
268
+ # @param file_id [Integer] Identifier of the file to stop uploading.
269
+ # @return [TD::Types::Ok]
270
+ def cancel_upload_file(file_id)
271
+ broadcast('@type' => 'cancelUploadFile',
272
+ 'file_id' => file_id)
273
+ end
274
+
275
+ # Used to let the server know whether a chat is spam or not.
276
+ # Can be used only if {TD::Types::ChatReportSpamState#can_report_spam} is true.
277
+ # After this request, {TD::Types::ChatReportSpamState#can_report_spam} becomes false forever.
278
+ #
279
+ # @param chat_id [Integer] Chat identifier.
280
+ # @param is_spam_chat [Boolean] If true, the chat will be reported as spam; otherwise it will be marked as not spam.
281
+ # @return [TD::Types::Ok]
282
+ def change_chat_report_spam_state(chat_id, is_spam_chat)
283
+ broadcast('@type' => 'changeChatReportSpamState',
284
+ 'chat_id' => chat_id,
285
+ 'is_spam_chat' => is_spam_chat)
286
+ end
287
+
288
+ # Changes imported contacts using the list of current user contacts saved on the device.
289
+ # Imports newly added contacts and, if at least the file database is enabled, deletes recently deleted contacts.
290
+ # Query result depends on the result of the previous query, so only one query is possible at the same time.
291
+ #
292
+ # @param contacts [Array<TD::Types::Contact>] The new list of contacts, contact's vCard are ignored and are not
293
+ # imported.
294
+ # @return [TD::Types::ImportedContacts]
295
+ def change_imported_contacts(contacts)
296
+ broadcast('@type' => 'changeImportedContacts',
297
+ 'contacts' => contacts)
298
+ end
299
+
300
+ # Changes the phone number of the user and sends an authentication code to the user's new phone number.
301
+ #
302
+ # @param phone_number [String] The new phone number of the user in international format.
303
+ # @param allow_flash_call [Boolean] Pass true if the code can be sent via flash call to the specified phone number.
304
+ # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device.
305
+ # Ignored if allow_flash_call is false.
306
+ # @return [TD::Types::AuthenticationCodeInfo] On success, returns information about the sent code.
307
+ def change_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false)
308
+ broadcast('@type' => 'changePhoneNumber',
309
+ 'phone_number' => phone_number,
310
+ 'allow_flash_call' => allow_flash_call,
311
+ 'is_current_phone_number' => is_current_phone_number)
312
+ end
313
+
314
+ # Installs/uninstalls or activates/archives a sticker set.
315
+ #
316
+ # @param set_id [Integer] Identifier of the sticker set.
317
+ # @param is_installed [Boolean] The new value of is_installed.
318
+ # @param is_archived [Boolean] The new value of is_archived.
319
+ # A sticker set can't be installed and archived simultaneously.
320
+ # @return [TD::Types::Ok]
321
+ def change_sticker_set(set_id, is_installed, is_archived)
322
+ broadcast('@type' => 'changeStickerSet',
323
+ 'set_id' => set_id,
324
+ 'is_installed' => is_installed,
325
+ 'is_archived' => is_archived)
326
+ end
327
+
328
+ # Checks the authentication token of a bot; to log in as a bot.
329
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPhoneNumber}.
330
+ # Can be used instead of {#set_authentication_phone_number} and {#check_authentication_code} to log in.
331
+ #
332
+ # @param token [String] The bot token.
333
+ # @return [TD::Types::Ok]
334
+ def check_authentication_bot_token(token)
335
+ broadcast('@type' => 'checkAuthenticationBotToken',
336
+ 'token' => token)
337
+ end
338
+
339
+ # Checks the authentication code.
340
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitCode}.
341
+ #
342
+ # @param code [String] The verification code received via SMS, Telegram message, phone call, or flash call.
343
+ # @param first_name [String, nil] If the user is not yet registered, the first name of the user; 1-255 characters.
344
+ # @param last_name [String, nil] If the user is not yet registered; the last name of the user; optional; 0-255
345
+ # characters.
346
+ # @return [TD::Types::Ok]
347
+ def check_authentication_code(code, first_name = nil, last_name = nil)
348
+ broadcast('@type' => 'checkAuthenticationCode',
349
+ 'code' => code,
350
+ 'first_name' => first_name,
351
+ 'last_name' => last_name)
352
+ end
353
+
354
+ # Checks the authentication password for correctness.
355
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}.
356
+ #
357
+ # @param password [String] The password to check.
358
+ # @return [TD::Types::Ok]
359
+ def check_authentication_password(password)
360
+ broadcast('@type' => 'checkAuthenticationPassword',
361
+ 'password' => password)
362
+ end
363
+
364
+ # Checks the authentication code sent to confirm a new phone number of the user.
365
+ #
366
+ # @param code [String] Verification code received by SMS, phone call or flash call.
367
+ # @return [TD::Types::Ok]
368
+ def check_change_phone_number_code(code)
369
+ broadcast('@type' => 'checkChangePhoneNumberCode',
370
+ 'code' => code)
371
+ end
372
+
373
+ # Checks the validity of an invite link for a chat and returns information about the corresponding chat.
374
+ #
375
+ # @param invite_link [String] Invite link to be checked; should begin with "https://t.me/joinchat/",
376
+ # "https://telegram.me/joinchat/", or "https://telegram.dog/joinchat/".
377
+ # @return [TD::Types::ChatInviteLinkInfo]
378
+ def check_chat_invite_link(invite_link)
379
+ broadcast('@type' => 'checkChatInviteLink',
380
+ 'invite_link' => invite_link)
381
+ end
382
+
383
+ # Checks whether a username can be set for a chat.
384
+ #
385
+ # @param chat_id [Integer] Chat identifier; should be identifier of a supergroup chat, or a channel chat, or a
386
+ # private chat with self, or zero if chat is being created.
387
+ # @param username [String] Username to be checked.
388
+ # @return [TD::Types::CheckChatUsernameResult]
389
+ def check_chat_username(chat_id, username)
390
+ broadcast('@type' => 'checkChatUsername',
391
+ 'chat_id' => chat_id,
392
+ 'username' => username)
393
+ end
394
+
395
+ # Checks the database encryption key for correctness.
396
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitEncryptionKey}.
397
+ #
398
+ # @param encryption_key [String] Encryption key to check or set up.
399
+ # @return [TD::Types::Ok]
400
+ def check_database_encryption_key(encryption_key)
401
+ broadcast('@type' => 'checkDatabaseEncryptionKey',
402
+ 'encryption_key' => encryption_key)
403
+ end
404
+
405
+ # Checks the email address verification code for Telegram Passport.
406
+ #
407
+ # @param code [String] Verification code.
408
+ # @return [TD::Types::Ok]
409
+ def check_email_address_verification_code(code)
410
+ broadcast('@type' => 'checkEmailAddressVerificationCode',
411
+ 'code' => code)
412
+ end
413
+
414
+ # Checks phone number confirmation code.
415
+ #
416
+ # @param code [String] The phone number confirmation code.
417
+ # @return [TD::Types::Ok]
418
+ def check_phone_number_confirmation_code(code)
419
+ broadcast('@type' => 'checkPhoneNumberConfirmationCode',
420
+ 'code' => code)
421
+ end
422
+
423
+ # Checks the phone number verification code for Telegram Passport.
424
+ #
425
+ # @param code [String] Verification code.
426
+ # @return [TD::Types::Ok]
427
+ def check_phone_number_verification_code(code)
428
+ broadcast('@type' => 'checkPhoneNumberVerificationCode',
429
+ 'code' => code)
430
+ end
431
+
432
+ # Removes potentially dangerous characters from the name of a file.
433
+ # The encoding of the file name is supposed to be UTF-8.
434
+ # Returns an empty string on failure.
435
+ # This is an offline method.
436
+ # Can be called before authorization.
437
+ # Can be called synchronously.
438
+ #
439
+ # @param file_name [String] File name or path to the file.
440
+ # @return [TD::Types::Text]
441
+ def clean_file_name(file_name)
442
+ broadcast('@type' => 'cleanFileName',
443
+ 'file_name' => file_name)
444
+ end
445
+
446
+ # Clears draft messages in all chats.
447
+ #
448
+ # @param exclude_secret_chats [Boolean] If true, local draft messages in secret chats will not be cleared.
449
+ # @return [TD::Types::Ok]
450
+ def clear_all_draft_messages(exclude_secret_chats)
451
+ broadcast('@type' => 'clearAllDraftMessages',
452
+ 'exclude_secret_chats' => exclude_secret_chats)
453
+ end
454
+
455
+ # Clears all imported contacts, contacts list remains unchanged.
456
+ #
457
+ # @return [TD::Types::Ok]
458
+ def clear_imported_contacts
459
+ broadcast('@type' => 'clearImportedContacts')
460
+ end
461
+
462
+ # Clears the list of recently used stickers.
463
+ #
464
+ # @param is_attached [Boolean] Pass true to clear the list of stickers recently attached to photo or video files;
465
+ # pass false to clear the list of recently sent stickers.
466
+ # @return [TD::Types::Ok]
467
+ def clear_recent_stickers(is_attached = false)
468
+ broadcast('@type' => 'clearRecentStickers',
469
+ 'is_attached' => is_attached)
470
+ end
471
+
472
+ # Clears the list of recently found chats.
473
+ #
474
+ # @return [TD::Types::Ok]
475
+ def clear_recently_found_chats
476
+ broadcast('@type' => 'clearRecentlyFoundChats')
477
+ end
478
+
479
+ # Closes the TDLib instance.
480
+ # All databases will be flushed to disk and properly closed.
481
+ # After the close completes, {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed}
482
+ # will be sent.
483
+ #
484
+ # @return [TD::Types::Ok]
485
+ def close
486
+ broadcast('@type' => 'close')
487
+ end
488
+
489
+ # This method should be called if the chat is closed by the user.
490
+ # Many useful activities depend on the chat being opened or closed.
491
+ #
492
+ # @param chat_id [Integer] Chat identifier.
493
+ # @return [TD::Types::Ok]
494
+ def close_chat(chat_id)
495
+ broadcast('@type' => 'closeChat',
496
+ 'chat_id' => chat_id)
497
+ end
498
+
499
+ # Closes a secret chat, effectively transfering its state to {TD::Types::SecretChatState::Closed}.
500
+ #
501
+ # @param secret_chat_id [Integer] Secret chat identifier.
502
+ # @return [TD::Types::Ok]
503
+ def close_secret_chat(secret_chat_id)
504
+ broadcast('@type' => 'closeSecretChat',
505
+ 'secret_chat_id' => secret_chat_id)
506
+ end
507
+
508
+ # Returns an existing chat corresponding to a known basic group.
509
+ #
510
+ # @param basic_group_id [Integer] Basic group identifier.
511
+ # @param force [Boolean] If true, the chat will be created without network request.
512
+ # In this case all information about the chat except its type, title and photo can be incorrect.
513
+ # @return [TD::Types::Chat]
514
+ def create_basic_group_chat(basic_group_id, force = false)
515
+ broadcast('@type' => 'createBasicGroupChat',
516
+ 'basic_group_id' => basic_group_id,
517
+ 'force' => force)
518
+ end
519
+
520
+ # Creates a new call.
521
+ #
522
+ # @param user_id [Integer] Identifier of the user to be called.
523
+ # @param protocol [TD::Types::CallProtocol] Description of the call protocols supported by the client.
524
+ # @return [TD::Types::CallId]
525
+ def create_call(user_id, protocol)
526
+ broadcast('@type' => 'createCall',
527
+ 'user_id' => user_id,
528
+ 'protocol' => protocol)
529
+ end
530
+
531
+ # Creates a new basic group and sends a corresponding {TD::Types::MessageContent::BasicGroupChatCreate}.
532
+ #
533
+ # @param user_ids [Array<Integer>] Identifiers of users to be added to the basic group.
534
+ # @param title [String] Title of the new basic group; 1-255 characters.
535
+ # @return [TD::Types::Chat] the newly created chat.
536
+ def create_new_basic_group_chat(user_ids, title)
537
+ broadcast('@type' => 'createNewBasicGroupChat',
538
+ 'user_ids' => user_ids,
539
+ 'title' => title)
540
+ end
541
+
542
+ # Creates a new secret chat.
543
+ #
544
+ # @param user_id [Integer] Identifier of the target user.
545
+ # @return [TD::Types::Chat] the newly created chat.
546
+ def create_new_secret_chat(user_id)
547
+ broadcast('@type' => 'createNewSecretChat',
548
+ 'user_id' => user_id)
549
+ end
550
+
551
+ # Creates a new sticker set; for bots only.
552
+ #
553
+ # @param user_id [Integer] Sticker set owner.
554
+ # @param title [String] Sticker set title; 1-64 characters.
555
+ # @param name [String] Sticker set name.
556
+ # Can contain only English letters, digits and underscores.
557
+ # Must end with *"_by_<bot username>"* (*<bot_username>* is case insensitive); 1-64 characters.
558
+ # @param is_masks [Boolean] True, if stickers are masks.
559
+ # @param stickers [Array<TD::Types::InputSticker>] List of stickers to be added to the set.
560
+ # @return [TD::Types::StickerSet] the newly created sticker set.
561
+ def create_new_sticker_set(user_id, title, name, stickers, is_masks: false)
562
+ broadcast('@type' => 'createNewStickerSet',
563
+ 'user_id' => user_id,
564
+ 'title' => title,
565
+ 'name' => name,
566
+ 'is_masks' => is_masks,
567
+ 'stickers' => stickers)
568
+ end
569
+
570
+ # Creates a new supergroup or channel and sends a corresponding {TD::Types::MessageContent::SupergroupChatCreate}.
571
+ #
572
+ # @param title [String] Title of the new chat; 1-255 characters.
573
+ # @param is_channel [Boolean] True, if a channel chat should be created.
574
+ # @param description [String] Chat description; 0-255 characters.
575
+ # @return [TD::Types::Chat] the newly created chat.
576
+ def create_new_supergroup_chat(title, description, is_channel: false)
577
+ broadcast('@type' => 'createNewSupergroupChat',
578
+ 'title' => title,
579
+ 'is_channel' => is_channel,
580
+ 'description' => description)
581
+ end
582
+
583
+ # Returns an existing chat corresponding to a given user.
584
+ #
585
+ # @param user_id [Integer] User identifier.
586
+ # @param force [Boolean] If true, the chat will be created without network request.
587
+ # In this case all information about the chat except its type, title and photo can be incorrect.
588
+ # @return [TD::Types::Chat]
589
+ def create_private_chat(user_id, force = false)
590
+ broadcast('@type' => 'createPrivateChat',
591
+ 'user_id' => user_id,
592
+ 'force' => force)
593
+ end
594
+
595
+ # Returns an existing chat corresponding to a known secret chat.
596
+ #
597
+ # @param secret_chat_id [Integer] Secret chat identifier.
598
+ # @return [TD::Types::Chat]
599
+ def create_secret_chat(secret_chat_id)
600
+ broadcast('@type' => 'createSecretChat',
601
+ 'secret_chat_id' => secret_chat_id)
602
+ end
603
+
604
+ # Returns an existing chat corresponding to a known supergroup or channel.
605
+ #
606
+ # @param supergroup_id [Integer] Supergroup or channel identifier.
607
+ # @param force [Boolean] If true, the chat will be created without network request.
608
+ # In this case all information about the chat except its type, title and photo can be incorrect.
609
+ # @return [TD::Types::Chat]
610
+ def create_supergroup_chat(supergroup_id, force = false)
611
+ broadcast('@type' => 'createSupergroupChat',
612
+ 'supergroup_id' => supergroup_id,
613
+ 'force' => force)
614
+ end
615
+
616
+ # Creates a new temporary password for processing payments.
617
+ #
618
+ # @param password [String] Persistent user password.
619
+ # @param valid_for [Integer] Time during which the temporary password will be valid, in seconds; should be between 60
620
+ # and 86400.
621
+ # @return [TD::Types::TemporaryPasswordState]
622
+ def create_temporary_password(password, valid_for)
623
+ broadcast('@type' => 'createTemporaryPassword',
624
+ 'password' => password,
625
+ 'valid_for' => valid_for)
626
+ end
627
+
628
+ # Deletes the account of the current user, deleting all information associated with the user from the server.
629
+ # The phone number of the account can be used to create a new account.
630
+ # Can be called before authorization when the current authorization state is
631
+ # {TD::Types::AuthorizationState::WaitPassword}.
632
+ #
633
+ # @param reason [String, nil] The reason why the account was deleted; optional.
634
+ # @return [TD::Types::Ok]
635
+ def delete_account(reason = nil)
636
+ broadcast('@type' => 'deleteAccount',
637
+ 'reason' => reason)
638
+ end
639
+
640
+ # Deletes all messages in the chat only for the user.
641
+ # Cannot be used in channels and public supergroups.
642
+ #
643
+ # @param chat_id [Integer] Chat identifier.
644
+ # @param remove_from_chat_list [Boolean] Pass true if the chat should be removed from the chats list.
645
+ # @return [TD::Types::Ok]
646
+ def delete_chat_history(chat_id, remove_from_chat_list = false)
647
+ broadcast('@type' => 'deleteChatHistory',
648
+ 'chat_id' => chat_id,
649
+ 'remove_from_chat_list' => remove_from_chat_list)
650
+ end
651
+
652
+ # Deletes all messages sent by the specified user to a chat.
653
+ # Supported only in supergroups; requires can_delete_messages administrator privileges.
654
+ #
655
+ # @param chat_id [Integer] Chat identifier.
656
+ # @param user_id [Integer] User identifier.
657
+ # @return [TD::Types::Ok]
658
+ def delete_chat_messages_from_user(chat_id, user_id)
659
+ broadcast('@type' => 'deleteChatMessagesFromUser',
660
+ 'chat_id' => chat_id,
661
+ 'user_id' => user_id)
662
+ end
663
+
664
+ # Deletes the default reply markup from a chat.
665
+ # Must be called after a one-time keyboard or a ForceReply reply markup has been used.
666
+ # UpdateChatReplyMarkup will be sent if the reply markup will be changed.
667
+ #
668
+ # @param chat_id [Integer] Chat identifier.
669
+ # @param message_id [Integer] The message identifier of the used keyboard.
670
+ # @return [TD::Types::Ok]
671
+ def delete_chat_reply_markup(chat_id, message_id)
672
+ broadcast('@type' => 'deleteChatReplyMarkup',
673
+ 'chat_id' => chat_id,
674
+ 'message_id' => message_id)
675
+ end
676
+
677
+ # Deletes a file from the TDLib file cache.
678
+ #
679
+ # @param file_id [Integer] Identifier of the file to delete.
680
+ # @return [TD::Types::Ok]
681
+ def delete_file(file_id)
682
+ broadcast('@type' => 'deleteFile',
683
+ 'file_id' => file_id)
684
+ end
685
+
686
+ # Deletes all information about a language pack in the current localization target.
687
+ # The language pack that is currently in use can't be deleted.
688
+ #
689
+ # @param language_pack_id [String] Identifier of the language pack to delete.
690
+ # @return [TD::Types::Ok]
691
+ def delete_language_pack(language_pack_id)
692
+ broadcast('@type' => 'deleteLanguagePack',
693
+ 'language_pack_id' => language_pack_id)
694
+ end
695
+
696
+ # Deletes messages.
697
+ #
698
+ # @param chat_id [Integer] Chat identifier.
699
+ # @param message_ids [Array<Integer>] Identifiers of the messages to be deleted.
700
+ # @param revoke [Boolean] Pass true to try to delete outgoing messages for all chat members (may fail if messages are
701
+ # too old).
702
+ # Always true for supergroups, channels and secret chats.
703
+ # @return [TD::Types::Ok]
704
+ def delete_messages(chat_id, message_ids, revoke = false)
705
+ broadcast('@type' => 'deleteMessages',
706
+ 'chat_id' => chat_id,
707
+ 'message_ids' => message_ids,
708
+ 'revoke' => revoke)
709
+ end
710
+
711
+ # Deletes a Telegram Passport element.
712
+ #
713
+ # @param type [TD::Types::PassportElementType] Element type.
714
+ # @return [TD::Types::Ok]
715
+ def delete_passport_element(type)
716
+ broadcast('@type' => 'deletePassportElement',
717
+ 'type' => type)
718
+ end
719
+
720
+ # Deletes a profile photo.
721
+ # If something changes, {TD::Types::Update::User} will be sent.
722
+ #
723
+ # @param profile_photo_id [Integer] Identifier of the profile photo to delete.
724
+ # @return [TD::Types::Ok]
725
+ def delete_profile_photo(profile_photo_id)
726
+ broadcast('@type' => 'deleteProfilePhoto',
727
+ 'profile_photo_id' => profile_photo_id)
728
+ end
729
+
730
+ # Deletes saved credentials for all payment provider bots.
731
+ #
732
+ # @return [TD::Types::Ok]
733
+ def delete_saved_credentials
734
+ broadcast('@type' => 'deleteSavedCredentials')
735
+ end
736
+
737
+ # Deletes saved order info.
738
+ #
739
+ # @return [TD::Types::Ok]
740
+ def delete_saved_order_info
741
+ broadcast('@type' => 'deleteSavedOrderInfo')
742
+ end
743
+
744
+ # Deletes a supergroup or channel along with all messages in the corresponding chat.
745
+ # This will release the supergroup or channel username and remove all members; requires creator privileges in the
746
+ # supergroup or channel.
747
+ # Chats with more than 1000 members can't be deleted using this method.
748
+ #
749
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
750
+ # @return [TD::Types::Ok]
751
+ def delete_supergroup(supergroup_id)
752
+ broadcast('@type' => 'deleteSupergroup',
753
+ 'supergroup_id' => supergroup_id)
754
+ end
755
+
756
+ # Closes the TDLib instance, destroying all local data without a proper logout.
757
+ # The current user session will remain in the list of all active sessions.
758
+ # All local data will be destroyed.
759
+ # After the destruction completes {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed}
760
+ # will be sent.
761
+ #
762
+ # @return [TD::Types::Ok]
763
+ def destroy
764
+ broadcast('@type' => 'destroy')
765
+ end
766
+
767
+ # Disables the currently enabled proxy.
768
+ # Can be called before authorization.
769
+ #
770
+ # @return [TD::Types::Ok]
771
+ def disable_proxy
772
+ broadcast('@type' => 'disableProxy')
773
+ end
774
+
775
+ # Discards a call.
776
+ #
777
+ # @param call_id [Integer] Call identifier.
778
+ # @param is_disconnected [Boolean] True, if the user was disconnected.
779
+ # @param duration [Integer] The call duration, in seconds.
780
+ # @param connection_id [Integer] Identifier of the connection used during the call.
781
+ # @return [TD::Types::Ok]
782
+ def discard_call(call_id, duration, connection_id, is_disconnected: false)
783
+ broadcast('@type' => 'discardCall',
784
+ 'call_id' => call_id,
785
+ 'is_disconnected' => is_disconnected,
786
+ 'duration' => duration,
787
+ 'connection_id' => connection_id)
788
+ end
789
+
790
+ # Disconnects all websites from the current user's Telegram account.
791
+ #
792
+ # @return [TD::Types::Ok]
793
+ def disconnect_all_websites
794
+ broadcast('@type' => 'disconnectAllWebsites')
795
+ end
796
+
797
+ # Disconnects website from the current user's Telegram account.
798
+ #
799
+ # @param website_id [Integer] Website identifier.
800
+ # @return [TD::Types::Ok]
801
+ def disconnect_website(website_id)
802
+ broadcast('@type' => 'disconnectWebsite',
803
+ 'website_id' => website_id)
804
+ end
805
+
806
+ # Asynchronously downloads a file from the cloud.
807
+ # {TD::Types::Update::File} will be used to notify about the download progress and successful completion of the
808
+ # download.
809
+ # Returns file state just after the download has been started.
810
+ #
811
+ # @param file_id [Integer] Identifier of the file to download.
812
+ # @param priority [Integer] Priority of the download (1-32).
813
+ # The higher the priority, the earlier the file will be downloaded.
814
+ # If the priorities of two files are equal, then the last one for which {#download_file} was called will be
815
+ # downloaded first.
816
+ # @return [TD::Types::File]
817
+ def download_file(file_id, priority = 1)
818
+ broadcast('@type' => 'downloadFile',
819
+ 'file_id' => file_id,
820
+ 'priority' => priority)
821
+ end
822
+
823
+ # Edits information about a custom language pack in the current localization target.
824
+ #
825
+ # @param info [TD::Types::LanguagePackInfo] New information about the custom language pack.
826
+ # @return [TD::Types::Ok]
827
+ def edit_custom_language_pack_info(info)
828
+ broadcast('@type' => 'editCustomLanguagePackInfo',
829
+ 'info' => info)
830
+ end
831
+
832
+ # Edits the caption of an inline message sent via a bot; for bots only.
833
+ #
834
+ # @param inline_message_id [String] Inline message identifier.
835
+ # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup.
836
+ # @param caption [TD::Types::FormattedText] New message content caption; 0-GetOption("message_caption_length_max")
837
+ # characters.
838
+ # @return [TD::Types::Ok]
839
+ def edit_inline_message_caption(inline_message_id, reply_markup, caption)
840
+ broadcast('@type' => 'editInlineMessageCaption',
841
+ 'inline_message_id' => inline_message_id,
842
+ 'reply_markup' => reply_markup,
843
+ 'caption' => caption)
844
+ end
845
+
846
+ # Edits the content of a live location in an inline message sent via a bot; for bots only.
847
+ #
848
+ # @param inline_message_id [String] Inline message identifier.
849
+ # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup.
850
+ # @param location [TD::Types::Location, nil] New location content of the message.
851
+ # Pass nil to stop sharing the live location.
852
+ # @return [TD::Types::Ok]
853
+ def edit_inline_message_live_location(inline_message_id, reply_markup, location = nil)
854
+ broadcast('@type' => 'editInlineMessageLiveLocation',
855
+ 'inline_message_id' => inline_message_id,
856
+ 'reply_markup' => reply_markup,
857
+ 'location' => location)
858
+ end
859
+
860
+ # Edits the content of a message with an animation, an audio, a document, a photo or a video in an inline message
861
+ # sent via a bot; for bots only.
862
+ #
863
+ # @param inline_message_id [String] Inline message identifier.
864
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only.
865
+ # @param input_message_content [TD::Types::InputMessageContent::Animation, TD::Types::InputMessageContent::Audio,
866
+ # TD::Types::InputMessageContent::Document, TD::Types::InputMessageContent::Photo,
867
+ # TD::Types::InputMessageContent::Video] New content of the message.
868
+ # @return [TD::Types::Ok]
869
+ def edit_inline_message_media(inline_message_id, input_message_content, reply_markup: nil)
870
+ broadcast('@type' => 'editInlineMessageMedia',
871
+ 'inline_message_id' => inline_message_id,
872
+ 'reply_markup' => reply_markup,
873
+ 'input_message_content' => input_message_content)
874
+ end
875
+
876
+ # Edits the reply markup of an inline message sent via a bot; for bots only.
877
+ #
878
+ # @param inline_message_id [String] Inline message identifier.
879
+ # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup.
880
+ # @return [TD::Types::Ok]
881
+ def edit_inline_message_reply_markup(inline_message_id, reply_markup)
882
+ broadcast('@type' => 'editInlineMessageReplyMarkup',
883
+ 'inline_message_id' => inline_message_id,
884
+ 'reply_markup' => reply_markup)
885
+ end
886
+
887
+ # Edits the text of an inline text or game message sent via a bot; for bots only.
888
+ #
889
+ # @param inline_message_id [String] Inline message identifier.
890
+ # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup.
891
+ # @param input_message_content [TD::Types::InputMessageContent::Text] New text content of the message.
892
+ # @return [TD::Types::Ok]
893
+ def edit_inline_message_text(inline_message_id, input_message_content, reply_markup)
894
+ broadcast('@type' => 'editInlineMessageText',
895
+ 'inline_message_id' => inline_message_id,
896
+ 'reply_markup' => reply_markup,
897
+ 'input_message_content' => input_message_content)
898
+ end
899
+
900
+ # Edits the message content caption.
901
+ #
902
+ # @param chat_id [Integer] The chat the message belongs to.
903
+ # @param message_id [Integer] Identifier of the message.
904
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only.
905
+ # @param caption [TD::Types::FormattedText] New message content caption; 0-GetOption("message_caption_length_max")
906
+ # characters.
907
+ # @return [TD::Types::Message] the edited message after the edit is completed on the server side.
908
+ def edit_message_caption(chat_id, message_id, caption, reply_markup: nil)
909
+ broadcast('@type' => 'editMessageCaption',
910
+ 'chat_id' => chat_id,
911
+ 'message_id' => message_id,
912
+ 'reply_markup' => reply_markup,
913
+ 'caption' => caption)
914
+ end
915
+
916
+ # Edits the message content of a live location.
917
+ # Messages can be edited for a limited period of time specified in the live location.
918
+ #
919
+ # @param chat_id [Integer] The chat the message belongs to.
920
+ # @param message_id [Integer] Identifier of the message.
921
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only.
922
+ # @param location [TD::Types::Location, nil] New location content of the message.
923
+ # Pass nil to stop sharing the live location.
924
+ # @return [TD::Types::Message] the edited message after the edit is completed on the server side.
925
+ def edit_message_live_location(chat_id, message_id, location = nil, reply_markup: nil)
926
+ broadcast('@type' => 'editMessageLiveLocation',
927
+ 'chat_id' => chat_id,
928
+ 'message_id' => message_id,
929
+ 'reply_markup' => reply_markup,
930
+ 'location' => location)
931
+ end
932
+
933
+ # Edits the content of a message with an animation, an audio, a document, a photo or a video.
934
+ # The media in the message can't be replaced if the message was set to self-destruct.
935
+ # Media can't be replaced by self-destructing media.
936
+ # Media in an album can be edited only to contain a photo or a video.
937
+ #
938
+ # @param chat_id [Integer] The chat the message belongs to.
939
+ # @param message_id [Integer] Identifier of the message.
940
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only.
941
+ # @param input_message_content [TD::Types::InputMessageContent::Animation, TD::Types::InputMessageContent::Audio,
942
+ # TD::Types::InputMessageContent::Document, TD::Types::InputMessageContent::Photo,
943
+ # TD::Types::InputMessageContent::Video] New content of the message.
944
+ # @return [TD::Types::Message] the edited message after the edit is completed on the server side.
945
+ def edit_message_media(chat_id, message_id, input_message_content, reply_markup: nil)
946
+ broadcast('@type' => 'editMessageMedia',
947
+ 'chat_id' => chat_id,
948
+ 'message_id' => message_id,
949
+ 'reply_markup' => reply_markup,
950
+ 'input_message_content' => input_message_content)
951
+ end
952
+
953
+ # Edits the message reply markup; for bots only.
954
+ #
955
+ # @param chat_id [Integer] The chat the message belongs to.
956
+ # @param message_id [Integer] Identifier of the message.
957
+ # @param reply_markup [TD::Types::ReplyMarkup] The new message reply markup.
958
+ # @return [TD::Types::Message] the edited message after the edit is completed on the server side.
959
+ def edit_message_reply_markup(chat_id, message_id, reply_markup)
960
+ broadcast('@type' => 'editMessageReplyMarkup',
961
+ 'chat_id' => chat_id,
962
+ 'message_id' => message_id,
963
+ 'reply_markup' => reply_markup)
964
+ end
965
+
966
+ # Edits the text of a message (or a text of a game message).
967
+ #
968
+ # @param chat_id [Integer] The chat the message belongs to.
969
+ # @param message_id [Integer] Identifier of the message.
970
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] The new message reply markup; for bots only.
971
+ # @param input_message_content [TD::Types::InputMessageContent::Text] New text content of the message.
972
+ # @return [TD::Types::Message] the edited message after the edit is completed on the server side.
973
+ def edit_message_text(chat_id, message_id, input_message_content, reply_markup: nil)
974
+ broadcast('@type' => 'editMessageText',
975
+ 'chat_id' => chat_id,
976
+ 'message_id' => message_id,
977
+ 'reply_markup' => reply_markup,
978
+ 'input_message_content' => input_message_content)
979
+ end
980
+
981
+ # Edits an existing proxy server for network requests.
982
+ # Can be called before authorization.
983
+ #
984
+ # @param proxy_id [Integer] Proxy identifier.
985
+ # @param server [String] Proxy server IP address.
986
+ # @param port [Integer] Proxy server port.
987
+ # @param enable [Boolean] True, if the proxy should be enabled.
988
+ # @param type [TD::Types::ProxyType] Proxy type.
989
+ # @return [TD::Types::Proxy]
990
+ def edit_proxy(proxy_id, server, port, type, enable = false)
991
+ broadcast('@type' => 'editProxy',
992
+ 'proxy_id' => proxy_id,
993
+ 'server' => server,
994
+ 'port' => port,
995
+ 'enable' => enable,
996
+ 'type' => type)
997
+ end
998
+
999
+ # Enables a proxy.
1000
+ # Only one proxy can be enabled at a time.
1001
+ # Can be called before authorization.
1002
+ #
1003
+ # @param proxy_id [Integer] Proxy identifier.
1004
+ # @return [TD::Types::Ok]
1005
+ def enable_proxy(proxy_id)
1006
+ broadcast('@type' => 'enableProxy',
1007
+ 'proxy_id' => proxy_id)
1008
+ end
1009
+
1010
+ # Finishes the file generation.
1011
+ #
1012
+ # @param generation_id [Integer] The identifier of the generation process.
1013
+ # @param error [TD::Types::Error, nil] If set, means that file generation has failed and should be terminated.
1014
+ # @return [TD::Types::Ok]
1015
+ def finish_file_generation(generation_id, error: nil)
1016
+ broadcast('@type' => 'finishFileGeneration',
1017
+ 'generation_id' => generation_id,
1018
+ 'error' => error)
1019
+ end
1020
+
1021
+ # Forwards previously sent messages.
1022
+ #
1023
+ # @param chat_id [Integer] Identifier of the chat to which to forward messages.
1024
+ # @param from_chat_id [Integer] Identifier of the chat from which to forward messages.
1025
+ # @param message_ids [Array<Integer>] Identifiers of the messages to forward.
1026
+ # @param disable_notification [Boolean] Pass true to disable notification for the message, doesn't work if messages
1027
+ # are forwarded to a secret chat.
1028
+ # @param from_background [Boolean] Pass true if the message is sent from the background.
1029
+ # @param as_album [Boolean] True, if the messages should be grouped into an album after forwarding.
1030
+ # For this to work, no more than 10 messages may be forwarded, and all of them must be photo or video messages.
1031
+ # @return [TD::Types::Messages, nil] the forwarded messages in the same order as the message identifiers passed in
1032
+ # message_ids.
1033
+ # If a message can't be forwarded, nil will be returned instead of the message.
1034
+ def forward_messages(chat_id, from_chat_id, message_ids,
1035
+ disable_notification: false, from_background: false, as_album: false)
1036
+ broadcast('@type' => 'forwardMessages',
1037
+ 'chat_id' => chat_id,
1038
+ 'from_chat_id' => from_chat_id,
1039
+ 'message_ids' => message_ids,
1040
+ 'disable_notification' => disable_notification,
1041
+ 'from_background' => from_background,
1042
+ 'as_album' => as_album)
1043
+ end
1044
+
1045
+ # Generates a new invite link for a chat; the previously generated link is revoked.
1046
+ # Available for basic groups, supergroups, and channels.
1047
+ # In basic groups this can be called only by the group's creator; in supergroups and channels this requires
1048
+ # appropriate administrator rights.
1049
+ #
1050
+ # @param chat_id [Integer] Chat identifier.
1051
+ # @return [TD::Types::ChatInviteLink]
1052
+ def generate_chat_invite_link(chat_id)
1053
+ broadcast('@type' => 'generateChatInviteLink',
1054
+ 'chat_id' => chat_id)
1055
+ end
1056
+
1057
+ # Returns the period of inactivity after which the account of the current user will automatically be deleted.
1058
+ #
1059
+ # @return [TD::Types::AccountTtl]
1060
+ def get_account_ttl
1061
+ broadcast('@type' => 'getAccountTtl')
1062
+ end
1063
+
1064
+ # Returns all active live locations that should be updated by the client.
1065
+ # The list is persistent across application restarts only if the message database is used.
1066
+ #
1067
+ # @return [TD::Types::Messages]
1068
+ def get_active_live_location_messages
1069
+ broadcast('@type' => 'getActiveLiveLocationMessages')
1070
+ end
1071
+
1072
+ # Returns all active sessions of the current user.
1073
+ #
1074
+ # @return [TD::Types::Sessions]
1075
+ def get_active_sessions
1076
+ broadcast('@type' => 'getActiveSessions')
1077
+ end
1078
+
1079
+ # Returns all available Telegram Passport elements.
1080
+ #
1081
+ # @param password [String] Password of the current user.
1082
+ # @return [TD::Types::PassportElements]
1083
+ def get_all_passport_elements(password)
1084
+ broadcast('@type' => 'getAllPassportElements',
1085
+ 'password' => password)
1086
+ end
1087
+
1088
+ # Returns a list of archived sticker sets.
1089
+ #
1090
+ # @param is_masks [Boolean] Pass true to return mask stickers sets; pass false to return ordinary sticker sets.
1091
+ # @param offset_sticker_set_id [Integer] Identifier of the sticker set from which to return the result.
1092
+ # @param limit [Integer] Maximum number of sticker sets to return.
1093
+ # @return [TD::Types::StickerSets]
1094
+ def get_archived_sticker_sets(offset_sticker_set_id, limit = 100, is_masks: false)
1095
+ broadcast('@type' => 'getArchivedStickerSets',
1096
+ 'is_masks' => is_masks,
1097
+ 'offset_sticker_set_id' => offset_sticker_set_id,
1098
+ 'limit' => limit)
1099
+ end
1100
+
1101
+ # Returns a list of sticker sets attached to a file.
1102
+ # Currently only photos and videos can have attached sticker sets.
1103
+ #
1104
+ # @param file_id [Integer] File identifier.
1105
+ # @return [TD::Types::StickerSets]
1106
+ def get_attached_sticker_sets(file_id)
1107
+ broadcast('@type' => 'getAttachedStickerSets',
1108
+ 'file_id' => file_id)
1109
+ end
1110
+
1111
+ # Returns the current authorization state; this is an offline request.
1112
+ # For informational purposes only.
1113
+ # Use {TD::Types::Update::AuthorizationState} instead to maintain the current authorization state.
1114
+ #
1115
+ # @return [TD::Types::AuthorizationState]
1116
+ def get_authorization_state
1117
+ broadcast('@type' => 'getAuthorizationState')
1118
+ end
1119
+
1120
+ # Returns information about a basic group by its identifier.
1121
+ # This is an offline request if the current user is not a bot.
1122
+ #
1123
+ # @param basic_group_id [Integer] Basic group identifier.
1124
+ # @return [TD::Types::BasicGroup]
1125
+ def get_basic_group(basic_group_id)
1126
+ broadcast('@type' => 'getBasicGroup',
1127
+ 'basic_group_id' => basic_group_id)
1128
+ end
1129
+
1130
+ # Returns full information about a basic group by its identifier.
1131
+ #
1132
+ # @param basic_group_id [Integer] Basic group identifier.
1133
+ # @return [TD::Types::BasicGroupFullInfo]
1134
+ def get_basic_group_full_info(basic_group_id)
1135
+ broadcast('@type' => 'getBasicGroupFullInfo',
1136
+ 'basic_group_id' => basic_group_id)
1137
+ end
1138
+
1139
+ # Returns users that were blocked by the current user.
1140
+ #
1141
+ # @param offset [Integer] Number of users to skip in the result; must be non-negative.
1142
+ # @param limit [Integer] Maximum number of users to return; up to 100.
1143
+ # @return [TD::Types::Users]
1144
+ def get_blocked_users(offset, limit = 100)
1145
+ broadcast('@type' => 'getBlockedUsers',
1146
+ 'offset' => offset,
1147
+ 'limit' => limit)
1148
+ end
1149
+
1150
+ # Sends a callback query to a bot and returns an answer.
1151
+ # Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.
1152
+ #
1153
+ # @param chat_id [Integer] Identifier of the chat with the message.
1154
+ # @param message_id [Integer] Identifier of the message from which the query originated.
1155
+ # @param payload [TD::Types::CallbackQueryPayload] Query payload.
1156
+ # @return [TD::Types::CallbackQueryAnswer]
1157
+ def get_callback_query_answer(chat_id, message_id, payload)
1158
+ broadcast('@type' => 'getCallbackQueryAnswer',
1159
+ 'chat_id' => chat_id,
1160
+ 'message_id' => message_id,
1161
+ 'payload' => payload)
1162
+ end
1163
+
1164
+ # Returns information about a chat by its identifier, this is an offline request if the current user is not a bot.
1165
+ #
1166
+ # @param chat_id [Integer] Chat identifier.
1167
+ # @return [TD::Types::Chat]
1168
+ def get_chat(chat_id)
1169
+ broadcast('@type' => 'getChat',
1170
+ 'chat_id' => chat_id)
1171
+ end
1172
+
1173
+ # Returns a list of users who are administrators of the chat.
1174
+ #
1175
+ # @param chat_id [Integer] Chat identifier.
1176
+ # @return [TD::Types::Users]
1177
+ def get_chat_administrators(chat_id)
1178
+ broadcast('@type' => 'getChatAdministrators',
1179
+ 'chat_id' => chat_id)
1180
+ end
1181
+
1182
+ # Returns a list of service actions taken by chat members and administrators in the last 48 hours.
1183
+ # Available only in supergroups and channels.
1184
+ # Requires administrator rights.
1185
+ # Returns results in reverse chronological order (i.e., in order of decreasing event_id).
1186
+ #
1187
+ # @param chat_id [Integer] Chat identifier.
1188
+ # @param query [String] Search query by which to filter events.
1189
+ # @param from_event_id [Integer] Identifier of an event from which to return results.
1190
+ # Use 0 to get results from the latest events.
1191
+ # @param limit [Integer] Maximum number of events to return; up to 100.
1192
+ # @param filters [TD::Types::ChatEventLogFilters] The types of events to return.
1193
+ # By default, all types will be returned.
1194
+ # @param user_ids [Array<Integer>] User identifiers by which to filter events.
1195
+ # By default, events relating to all users will be returned.
1196
+ # @return [TD::Types::ChatEvents]
1197
+ def get_chat_event_log(chat_id, query, from_event_id, limit, filters, user_ids)
1198
+ broadcast('@type' => 'getChatEventLog',
1199
+ 'chat_id' => chat_id,
1200
+ 'query' => query,
1201
+ 'from_event_id' => from_event_id,
1202
+ 'limit' => limit,
1203
+ 'filters' => filters,
1204
+ 'user_ids' => user_ids)
1205
+ end
1206
+
1207
+ # Returns messages in a chat.
1208
+ # The messages are returned in a reverse chronological order (i.e., in order of decreasing message_id).
1209
+ # For optimal performance the number of returned messages is chosen by the library.
1210
+ # This is an offline request if only_local is true.
1211
+ #
1212
+ # @param chat_id [Integer] Chat identifier.
1213
+ # @param from_message_id [Integer] Identifier of the message starting from which history must be fetched; use 0 to
1214
+ # get results from the last message.
1215
+ # @param offset [Integer] Specify 0 to get results from exactly the from_message_id or a negative offset to get the
1216
+ # specified message and some newer messages.
1217
+ # @param limit [Integer] The maximum number of messages to be returned; must be positive and can't be greater than
1218
+ # 100.
1219
+ # If the offset is negative, the limit must be greater than -offset.
1220
+ # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been
1221
+ # reached.
1222
+ # @param only_local [Boolean] If true, returns only messages that are available locally without sending network
1223
+ # requests.
1224
+ # @return [TD::Types::Messages]
1225
+ def get_chat_history(chat_id, from_message_id, offset = 0, limit = 100, only_local: false)
1226
+ broadcast('@type' => 'getChatHistory',
1227
+ 'chat_id' => chat_id,
1228
+ 'from_message_id' => from_message_id,
1229
+ 'offset' => offset,
1230
+ 'limit' => limit,
1231
+ 'only_local' => only_local)
1232
+ end
1233
+
1234
+ # Returns information about a single member of a chat.
1235
+ #
1236
+ # @param chat_id [Integer] Chat identifier.
1237
+ # @param user_id [Integer] User identifier.
1238
+ # @return [TD::Types::ChatMember]
1239
+ def get_chat_member(chat_id, user_id)
1240
+ broadcast('@type' => 'getChatMember',
1241
+ 'chat_id' => chat_id,
1242
+ 'user_id' => user_id)
1243
+ end
1244
+
1245
+ # Returns the last message sent in a chat no later than the specified date.
1246
+ #
1247
+ # @param chat_id [Integer] Chat identifier.
1248
+ # @param date [Integer] Point in time (Unix timestamp) relative to which to search for messages.
1249
+ # @return [TD::Types::Message]
1250
+ def get_chat_message_by_date(chat_id, date)
1251
+ broadcast('@type' => 'getChatMessageByDate',
1252
+ 'chat_id' => chat_id,
1253
+ 'date' => date)
1254
+ end
1255
+
1256
+ # Returns approximate number of messages of the specified type in the chat.
1257
+ #
1258
+ # @param chat_id [Integer] Identifier of the chat in which to count messages.
1259
+ # @param filter [TD::Types::SearchMessagesFilter, nil] Filter for message content;
1260
+ # {TD::Types::SearchMessagesFilter::Empty} is unsupported in this function.
1261
+ # @param return_local [Boolean] If true, returns count that is available locally without sending network requests,
1262
+ # returning -1 if the number of messages is unknown.
1263
+ # @return [TD::Types::Count]
1264
+ def get_chat_message_count(chat_id, filter = nil, return_local: false)
1265
+ broadcast('@type' => 'getChatMessageCount',
1266
+ 'chat_id' => chat_id,
1267
+ 'filter' => filter,
1268
+ 'return_local' => return_local)
1269
+ end
1270
+
1271
+ # Returns information about a pinned chat message.
1272
+ #
1273
+ # @param chat_id [Integer] Identifier of the chat the message belongs to.
1274
+ # @return [TD::Types::Message]
1275
+ def get_chat_pinned_message(chat_id)
1276
+ broadcast('@type' => 'getChatPinnedMessage',
1277
+ 'chat_id' => chat_id)
1278
+ end
1279
+
1280
+ # Returns information on whether the current chat can be reported as spam.
1281
+ #
1282
+ # @param chat_id [Integer] Chat identifier.
1283
+ # @return [TD::Types::ChatReportSpamState]
1284
+ def get_chat_report_spam_state(chat_id)
1285
+ broadcast('@type' => 'getChatReportSpamState',
1286
+ 'chat_id' => chat_id)
1287
+ end
1288
+
1289
+ # Returns an ordered list of chats.
1290
+ # Chats are sorted by the pair (order, chat_id) in decreasing order.
1291
+ # (For example, to get a list of chats from the beginning, the offset_order should be equal to 2^63 - 1).
1292
+ # For optimal performance the number of returned chats is chosen by the library.
1293
+ #
1294
+ # @param offset_order [Integer] Chat order to return chats from.
1295
+ # @param offset_chat_id [Integer] Chat identifier to return chats from.
1296
+ # @param limit [Integer] The maximum number of chats to be returned.
1297
+ # It is possible that fewer chats than the limit are returned even if the end of the list is not reached.
1298
+ # @return [TD::Types::Chats]
1299
+ def get_chats(offset_chat_id = 0, limit = 100, offset_order: 9223372036854775807)
1300
+ broadcast('@type' => 'getChats',
1301
+ 'offset_order' => offset_order,
1302
+ 'offset_chat_id' => offset_chat_id,
1303
+ 'limit' => limit)
1304
+ end
1305
+
1306
+ # Returns all website where the current user used Telegram to log in.
1307
+ #
1308
+ # @return [TD::Types::ConnectedWebsites]
1309
+ def get_connected_websites
1310
+ broadcast('@type' => 'getConnectedWebsites')
1311
+ end
1312
+
1313
+ # Returns all user contacts.
1314
+ #
1315
+ # @return [TD::Types::Users]
1316
+ def get_contacts
1317
+ broadcast('@type' => 'getContacts')
1318
+ end
1319
+
1320
+ # Uses current user IP to found his country.
1321
+ # Can be called before authorization.
1322
+ #
1323
+ # @return [TD::Types::Text] two-letter ISO 3166-1 alpha-2 country code.
1324
+ def get_country_code
1325
+ broadcast('@type' => 'getCountryCode')
1326
+ end
1327
+
1328
+ # Returns a list of public chats created by the user.
1329
+ #
1330
+ # @return [TD::Types::Chats]
1331
+ def get_created_public_chats
1332
+ broadcast('@type' => 'getCreatedPublicChats')
1333
+ end
1334
+
1335
+ # Returns information about a tg:// deep link.
1336
+ # Use "tg://need_update_for_some_feature" or "tg:some_unsupported_feature" for testing.
1337
+ # Returns a 404 error for unknown links.
1338
+ # Can be called before authorization.
1339
+ #
1340
+ # @param link [String] The link.
1341
+ # @return [TD::Types::DeepLinkInfo]
1342
+ def get_deep_link_info(link)
1343
+ broadcast('@type' => 'getDeepLinkInfo',
1344
+ 'link' => link)
1345
+ end
1346
+
1347
+ # Returns favorite stickers.
1348
+ #
1349
+ # @return [TD::Types::Stickers]
1350
+ def get_favorite_stickers
1351
+ broadcast('@type' => 'getFavoriteStickers')
1352
+ end
1353
+
1354
+ # Returns information about a file; this is an offline request.
1355
+ #
1356
+ # @param file_id [Integer] Identifier of the file to get.
1357
+ # @return [TD::Types::File]
1358
+ def get_file(file_id)
1359
+ broadcast('@type' => 'getFile',
1360
+ 'file_id' => file_id)
1361
+ end
1362
+
1363
+ # Returns the extension of a file, guessed by its MIME type.
1364
+ # Returns an empty string on failure.
1365
+ # This is an offline method.
1366
+ # Can be called before authorization.
1367
+ # Can be called synchronously.
1368
+ #
1369
+ # @param mime_type [String] The MIME type of the file.
1370
+ # @return [TD::Types::Text]
1371
+ def get_file_extension(mime_type)
1372
+ broadcast('@type' => 'getFileExtension',
1373
+ 'mime_type' => mime_type)
1374
+ end
1375
+
1376
+ # Returns the MIME type of a file, guessed by its extension.
1377
+ # Returns an empty string on failure.
1378
+ # This is an offline method.
1379
+ # Can be called before authorization.
1380
+ # Can be called synchronously.
1381
+ #
1382
+ # @param file_name [String] The name of the file or path to the file.
1383
+ # @return [TD::Types::Text]
1384
+ def get_file_mime_type(file_name)
1385
+ broadcast('@type' => 'getFileMimeType',
1386
+ 'file_name' => file_name)
1387
+ end
1388
+
1389
+ # Returns the high scores for a game and some part of the high score table in the range of the specified user; for
1390
+ # bots only.
1391
+ #
1392
+ # @param chat_id [Integer] The chat that contains the message with the game.
1393
+ # @param message_id [Integer] Identifier of the message.
1394
+ # @param user_id [Integer] User identifier.
1395
+ # @return [TD::Types::GameHighScores]
1396
+ def get_game_high_scores(chat_id, message_id, user_id)
1397
+ broadcast('@type' => 'getGameHighScores',
1398
+ 'chat_id' => chat_id,
1399
+ 'message_id' => message_id,
1400
+ 'user_id' => user_id)
1401
+ end
1402
+
1403
+ # Returns a list of common chats with a given user.
1404
+ # Chats are sorted by their type and creation date.
1405
+ #
1406
+ # @param user_id [Integer] User identifier.
1407
+ # @param offset_chat_id [Integer] Chat identifier starting from which to return chats; use 0 for the first request.
1408
+ # @param limit [Integer] Maximum number of chats to be returned; up to 100.
1409
+ # @return [TD::Types::Chats]
1410
+ def get_groups_in_common(user_id, offset_chat_id = 0, limit = 100)
1411
+ broadcast('@type' => 'getGroupsInCommon',
1412
+ 'user_id' => user_id,
1413
+ 'offset_chat_id' => offset_chat_id,
1414
+ 'limit' => limit)
1415
+ end
1416
+
1417
+ # Returns the total number of imported contacts.
1418
+ #
1419
+ # @return [TD::Types::Count]
1420
+ def get_imported_contact_count
1421
+ broadcast('@type' => 'getImportedContactCount')
1422
+ end
1423
+
1424
+ # Returns game high scores and some part of the high score table in the range of the specified user; for bots only.
1425
+ #
1426
+ # @param inline_message_id [String] Inline message identifier.
1427
+ # @param user_id [Integer] User identifier.
1428
+ # @return [TD::Types::GameHighScores]
1429
+ def get_inline_game_high_scores(inline_message_id, user_id)
1430
+ broadcast('@type' => 'getInlineGameHighScores',
1431
+ 'inline_message_id' => inline_message_id,
1432
+ 'user_id' => user_id)
1433
+ end
1434
+
1435
+ # Sends an inline query to a bot and returns its results.
1436
+ # Returns an error with code 502 if the bot fails to answer the query before the query timeout expires.
1437
+ #
1438
+ # @param bot_user_id [Integer] The identifier of the target bot.
1439
+ # @param chat_id [Integer] Identifier of the chat, where the query was sent.
1440
+ # @param user_location [TD::Types::Location, nil] Location of the user, only if needed.
1441
+ # @param query [String] Text of the query.
1442
+ # @param offset [String] Offset of the first entry to return.
1443
+ # @return [TD::Types::InlineQueryResults]
1444
+ def get_inline_query_results(bot_user_id, chat_id, query, offset = '0', user_location: nil)
1445
+ broadcast('@type' => 'getInlineQueryResults',
1446
+ 'bot_user_id' => bot_user_id,
1447
+ 'chat_id' => chat_id,
1448
+ 'user_location' => user_location,
1449
+ 'query' => query,
1450
+ 'offset' => offset)
1451
+ end
1452
+
1453
+ # Returns a list of installed sticker sets.
1454
+ #
1455
+ # @param is_masks [Boolean] Pass true to return mask sticker sets; pass false to return ordinary sticker sets.
1456
+ # @return [TD::Types::StickerSets]
1457
+ def get_installed_sticker_sets(is_masks = false)
1458
+ broadcast('@type' => 'getInstalledStickerSets',
1459
+ 'is_masks' => is_masks)
1460
+ end
1461
+
1462
+ # Returns the default text for invitation messages to be used as a placeholder when the current user invites friends
1463
+ # to Telegram.
1464
+ #
1465
+ # @return [TD::Types::Text]
1466
+ def get_invite_text
1467
+ broadcast('@type' => 'getInviteText')
1468
+ end
1469
+
1470
+ # Returns a string stored in the local database from the specified localization target and language pack by its key.
1471
+ # Returns a 404 error if the string is not found.
1472
+ # This is an offline method.
1473
+ # Can be called before authorization.
1474
+ # Can be called synchronously.
1475
+ #
1476
+ # @param language_pack_database_path [String] Path to the language pack database in which strings are stored.
1477
+ # @param localization_target [String] Localization target to which the language pack belongs.
1478
+ # @param language_pack_id [String] Language pack identifier.
1479
+ # @param key [String] Language pack key of the string to be returned.
1480
+ # @return [TD::Types::LanguagePackStringValue]
1481
+ def get_language_pack_string(language_pack_database_path, localization_target, language_pack_id, key)
1482
+ broadcast('@type' => 'getLanguagePackString',
1483
+ 'language_pack_database_path' => language_pack_database_path,
1484
+ 'localization_target' => localization_target,
1485
+ 'language_pack_id' => language_pack_id,
1486
+ 'key' => key)
1487
+ end
1488
+
1489
+ # Returns strings from a language pack in the current localization target by their keys.
1490
+ #
1491
+ # @param language_pack_id [String] Language pack identifier of the strings to be returned.
1492
+ # @param keys [Array<String>] Language pack keys of the strings to be returned; leave empty to request all available
1493
+ # strings.
1494
+ # @return [TD::Types::LanguagePackStrings]
1495
+ def get_language_pack_strings(language_pack_id, keys)
1496
+ broadcast('@type' => 'getLanguagePackStrings',
1497
+ 'language_pack_id' => language_pack_id,
1498
+ 'keys' => keys)
1499
+ end
1500
+
1501
+ # Returns information about the current localization target.
1502
+ # This is an offline request if only_local is true.
1503
+ #
1504
+ # @param only_local [Boolean] If true, returns only locally available information without sending network requests.
1505
+ # @return [TD::Types::LocalizationTargetInfo]
1506
+ def get_localization_target_info(only_local = false)
1507
+ broadcast('@type' => 'getLocalizationTargetInfo',
1508
+ 'only_local' => only_local)
1509
+ end
1510
+
1511
+ # Returns information about a file with a map thumbnail in PNG format.
1512
+ # Only map thumbnail files with size less than 1MB can be downloaded.
1513
+ #
1514
+ # @param location [TD::Types::Location] Location of the map center.
1515
+ # @param zoom [Integer] Map zoom level; 13-20.
1516
+ # @param width [Integer] Map width in pixels before applying scale; 16-1024.
1517
+ # @param height [Integer] Map height in pixels before applying scale; 16-1024.
1518
+ # @param scale [Integer] Map scale; 1-3.
1519
+ # @param chat_id [Integer] Identifier of a chat, in which the thumbnail will be shown.
1520
+ # Use 0 if unknown.
1521
+ # @return [TD::Types::File]
1522
+ def get_map_thumbnail_file(location, zoom = 13, width = 1024, height = 1024, scale = 1, chat_id: 0)
1523
+ broadcast('@type' => 'getMapThumbnailFile',
1524
+ 'location' => location,
1525
+ 'zoom' => zoom,
1526
+ 'width' => width,
1527
+ 'height' => height,
1528
+ 'scale' => scale,
1529
+ 'chat_id' => chat_id)
1530
+ end
1531
+
1532
+ # Returns the current user.
1533
+ #
1534
+ # @return [TD::Types::User]
1535
+ def get_me
1536
+ broadcast('@type' => 'getMe')
1537
+ end
1538
+
1539
+ # Returns information about a message.
1540
+ #
1541
+ # @param chat_id [Integer] Identifier of the chat the message belongs to.
1542
+ # @param message_id [Integer] Identifier of the message to get.
1543
+ # @return [TD::Types::Message]
1544
+ def get_message(chat_id, message_id)
1545
+ broadcast('@type' => 'getMessage',
1546
+ 'chat_id' => chat_id,
1547
+ 'message_id' => message_id)
1548
+ end
1549
+
1550
+ # Returns information about messages.
1551
+ # If a message is not found, returns nil on the corresponding position of the result.
1552
+ #
1553
+ # @param chat_id [Integer] Identifier of the chat the messages belong to.
1554
+ # @param message_ids [Array<Integer>] Identifiers of the messages to get.
1555
+ # @return [TD::Types::Messages]
1556
+ def get_messages(chat_id, message_ids)
1557
+ broadcast('@type' => 'getMessages',
1558
+ 'chat_id' => chat_id,
1559
+ 'message_ids' => message_ids)
1560
+ end
1561
+
1562
+ # Returns network data usage statistics.
1563
+ # Can be called before authorization.
1564
+ #
1565
+ # @param only_current [Boolean] If true, returns only data for the current library launch.
1566
+ # @return [TD::Types::NetworkStatistics]
1567
+ def get_network_statistics(only_current = false)
1568
+ broadcast('@type' => 'getNetworkStatistics',
1569
+ 'only_current' => only_current)
1570
+ end
1571
+
1572
+ # Returns the value of an option by its name.
1573
+ # Can be called before authorization.
1574
+ #
1575
+ # @param name [String] The name of the option.
1576
+ # @see https://core.telegram.org/tdlib/options List of available options
1577
+ # @return [TD::Types::OptionValue]
1578
+ def get_option(name)
1579
+ broadcast('@type' => 'getOption',
1580
+ 'name' => name)
1581
+ end
1582
+
1583
+ # Returns a Telegram Passport authorization form for sharing data with a service.
1584
+ #
1585
+ # @param bot_user_id [Integer] User identifier of the service's bot.
1586
+ # @param scope [String] Telegram Passport element types requested by the service.
1587
+ # @param public_key [String] Service's public_key.
1588
+ # @param nonce [String] Authorization form nonce provided by the service.
1589
+ # @param password [String] Password of the current user.
1590
+ # @return [TD::Types::PassportAuthorizationForm]
1591
+ def get_passport_authorization_form(bot_user_id, scope, public_key, nonce, password)
1592
+ broadcast('@type' => 'getPassportAuthorizationForm',
1593
+ 'bot_user_id' => bot_user_id,
1594
+ 'scope' => scope,
1595
+ 'public_key' => public_key,
1596
+ 'nonce' => nonce,
1597
+ 'password' => password)
1598
+ end
1599
+
1600
+ # Returns one of the available Telegram Passport elements.
1601
+ #
1602
+ # @param type [TD::Types::PassportElementType] Telegram Passport element type.
1603
+ # @param password [String] Password of the current user.
1604
+ # @return [TD::Types::PassportElement]
1605
+ def get_passport_element(type, password)
1606
+ broadcast('@type' => 'getPassportElement',
1607
+ 'type' => type,
1608
+ 'password' => password)
1609
+ end
1610
+
1611
+ # Returns the current state of 2-step verification.
1612
+ #
1613
+ # @return [TD::Types::PasswordState]
1614
+ def get_password_state
1615
+ broadcast('@type' => 'getPasswordState')
1616
+ end
1617
+
1618
+ # Returns an invoice payment form.
1619
+ # This method should be called when the user presses {TD::Types::InlineKeyboardButton::Buy}.
1620
+ #
1621
+ # @param chat_id [Integer] Chat identifier of the Invoice message.
1622
+ # @param message_id [Integer] Message identifier.
1623
+ # @return [TD::Types::PaymentForm]
1624
+ def get_payment_form(chat_id, message_id)
1625
+ broadcast('@type' => 'getPaymentForm',
1626
+ 'chat_id' => chat_id,
1627
+ 'message_id' => message_id)
1628
+ end
1629
+
1630
+ # Returns information about a successful payment.
1631
+ #
1632
+ # @param chat_id [Integer] Chat identifier of the PaymentSuccessful message.
1633
+ # @param message_id [Integer] Message identifier.
1634
+ # @return [TD::Types::PaymentReceipt]
1635
+ def get_payment_receipt(chat_id, message_id)
1636
+ broadcast('@type' => 'getPaymentReceipt',
1637
+ 'chat_id' => chat_id,
1638
+ 'message_id' => message_id)
1639
+ end
1640
+
1641
+ # Returns an IETF language tag of the language preferred in the country, which should be used to fill native fields
1642
+ # in Telegram Passport personal details.
1643
+ # Returns a 404 error if unknown.
1644
+ #
1645
+ # @param country_code [String] A two-letter ISO 3166-1 alpha-2 country code.
1646
+ # @return [TD::Types::Text]
1647
+ def get_preferred_country_language(country_code)
1648
+ broadcast('@type' => 'getPreferredCountryLanguage',
1649
+ 'country_code' => country_code)
1650
+ end
1651
+
1652
+ # Returns list of proxies that are currently set up.
1653
+ # Can be called before authorization.
1654
+ #
1655
+ # @return [TD::Types::Proxies]
1656
+ def get_proxies
1657
+ broadcast('@type' => 'getProxies')
1658
+ end
1659
+
1660
+ # Returns an HTTPS link, which can be used to add a proxy.
1661
+ # Available only for SOCKS5 and MTProto proxies.
1662
+ # Can be called before authorization.
1663
+ #
1664
+ # @param proxy_id [Integer] Proxy identifier.
1665
+ # @return [TD::Types::Text]
1666
+ def get_proxy_link(proxy_id)
1667
+ broadcast('@type' => 'getProxyLink',
1668
+ 'proxy_id' => proxy_id)
1669
+ end
1670
+
1671
+ # Returns a public HTTPS link to a message.
1672
+ # Available only for messages in public supergroups and channels.
1673
+ #
1674
+ # @param chat_id [Integer] Identifier of the chat to which the message belongs.
1675
+ # @param message_id [Integer] Identifier of the message.
1676
+ # @param for_album [Boolean] Pass true if a link for a whole media album should be returned.
1677
+ # @return [TD::Types::PublicMessageLink]
1678
+ def get_public_message_link(chat_id, message_id, for_album: false)
1679
+ broadcast('@type' => 'getPublicMessageLink',
1680
+ 'chat_id' => chat_id,
1681
+ 'message_id' => message_id,
1682
+ 'for_album' => for_album)
1683
+ end
1684
+
1685
+ # Returns up to 20 recently used inline bots in the order of their last usage.
1686
+ #
1687
+ # @return [TD::Types::Users]
1688
+ def get_recent_inline_bots
1689
+ broadcast('@type' => 'getRecentInlineBots')
1690
+ end
1691
+
1692
+ # Returns a list of recently used stickers.
1693
+ #
1694
+ # @param is_attached [Boolean] Pass true to return stickers and masks that were recently attached to photos or video
1695
+ # files; pass false to return recently sent stickers.
1696
+ # @return [TD::Types::Stickers]
1697
+ def get_recent_stickers(is_attached = false)
1698
+ broadcast('@type' => 'getRecentStickers',
1699
+ 'is_attached' => is_attached)
1700
+ end
1701
+
1702
+ # Returns t.me URLs recently visited by a newly registered user.
1703
+ #
1704
+ # @param referrer [String] Google Play referrer to identify the user.
1705
+ # @return [TD::Types::TMeUrls]
1706
+ def get_recently_visited_t_me_urls(referrer)
1707
+ broadcast('@type' => 'getRecentlyVisitedTMeUrls',
1708
+ 'referrer' => referrer)
1709
+ end
1710
+
1711
+ # Returns a recovery email address that was previously set up.
1712
+ # This method can be used to verify a password provided by the user.
1713
+ #
1714
+ # @param password [String] The password for the current user.
1715
+ # @return [TD::Types::RecoveryEmailAddress]
1716
+ def get_recovery_email_address(password)
1717
+ broadcast('@type' => 'getRecoveryEmailAddress',
1718
+ 'password' => password)
1719
+ end
1720
+
1721
+ # Returns information about a file by its remote ID; this is an offline request.
1722
+ # Can be used to register a URL as a file for further uploading, or sending as a message.
1723
+ #
1724
+ # @param remote_file_id [String] Remote identifier of the file to get.
1725
+ # @param file_type [TD::Types::FileType, nil] File type, if known.
1726
+ # @return [TD::Types::File]
1727
+ def get_remote_file(remote_file_id, file_type = nil)
1728
+ broadcast('@type' => 'getRemoteFile',
1729
+ 'remote_file_id' => remote_file_id,
1730
+ 'file_type' => file_type)
1731
+ end
1732
+
1733
+ # Returns information about a message that is replied by given message.
1734
+ #
1735
+ # @param chat_id [Integer] Identifier of the chat the message belongs to.
1736
+ # @param message_id [Integer] Identifier of the message reply to which get.
1737
+ # @return [TD::Types::Message]
1738
+ def get_replied_message(chat_id, message_id)
1739
+ broadcast('@type' => 'getRepliedMessage',
1740
+ 'chat_id' => chat_id,
1741
+ 'message_id' => message_id)
1742
+ end
1743
+
1744
+ # Returns saved animations.
1745
+ #
1746
+ # @return [TD::Types::Animations]
1747
+ def get_saved_animations
1748
+ broadcast('@type' => 'getSavedAnimations')
1749
+ end
1750
+
1751
+ # Returns saved order info, if any.
1752
+ #
1753
+ # @return [TD::Types::OrderInfo]
1754
+ def get_saved_order_info
1755
+ broadcast('@type' => 'getSavedOrderInfo')
1756
+ end
1757
+
1758
+ # Returns the notification settings for chats of a given type.
1759
+ #
1760
+ # @param scope [TD::Types::NotificationSettingsScope] Types of chats for which to return the notification settings
1761
+ # information.
1762
+ # @return [TD::Types::ScopeNotificationSettings]
1763
+ def get_scope_notification_settings(scope)
1764
+ broadcast('@type' => 'getScopeNotificationSettings',
1765
+ 'scope' => scope)
1766
+ end
1767
+
1768
+ # Returns information about a secret chat by its identifier.
1769
+ # This is an offline request.
1770
+ #
1771
+ # @param secret_chat_id [Integer] Secret chat identifier.
1772
+ # @return [TD::Types::SecretChat]
1773
+ def get_secret_chat(secret_chat_id)
1774
+ broadcast('@type' => 'getSecretChat',
1775
+ 'secret_chat_id' => secret_chat_id)
1776
+ end
1777
+
1778
+ # Returns emoji corresponding to a sticker.
1779
+ #
1780
+ # @param sticker [TD::Types::InputFile] Sticker file identifier.
1781
+ # @return [TD::Types::StickerEmojis]
1782
+ def get_sticker_emojis(sticker)
1783
+ broadcast('@type' => 'getStickerEmojis',
1784
+ 'sticker' => sticker)
1785
+ end
1786
+
1787
+ # Returns information about a sticker set by its identifier.
1788
+ #
1789
+ # @param set_id [Integer] Identifier of the sticker set.
1790
+ # @return [TD::Types::StickerSet]
1791
+ def get_sticker_set(set_id)
1792
+ broadcast('@type' => 'getStickerSet',
1793
+ 'set_id' => set_id)
1794
+ end
1795
+
1796
+ # Returns stickers from the installed sticker sets that correspond to a given emoji.
1797
+ # If the emoji is not empty, favorite and recently used stickers may also be returned.
1798
+ #
1799
+ # @param emoji [String] String representation of emoji.
1800
+ # If empty, returns all known installed stickers.
1801
+ # @param limit [Integer] Maximum number of stickers to be returned.
1802
+ # @return [TD::Types::Stickers]
1803
+ def get_stickers(emoji, limit = 100)
1804
+ broadcast('@type' => 'getStickers',
1805
+ 'emoji' => emoji,
1806
+ 'limit' => limit)
1807
+ end
1808
+
1809
+ # Returns storage usage statistics.
1810
+ #
1811
+ # @param chat_limit [Integer] Maximum number of chats with the largest storage usage for which separate statistics
1812
+ # should be returned.
1813
+ # All other chats will be grouped in entries with chat_id == 0.
1814
+ # If the chat info database is not used, the chat_limit is ignored and is always set to 0.
1815
+ # @return [TD::Types::StorageStatistics]
1816
+ def get_storage_statistics(chat_limit)
1817
+ broadcast('@type' => 'getStorageStatistics',
1818
+ 'chat_limit' => chat_limit)
1819
+ end
1820
+
1821
+ # Quickly returns approximate storage usage statistics.
1822
+ #
1823
+ # @return [TD::Types::StorageStatisticsFast]
1824
+ def get_storage_statistics_fast
1825
+ broadcast('@type' => 'getStorageStatisticsFast')
1826
+ end
1827
+
1828
+ # Returns information about a supergroup or channel by its identifier.
1829
+ # This is an offline request if the current user is not a bot.
1830
+ #
1831
+ # @param supergroup_id [Integer] Supergroup or channel identifier.
1832
+ # @return [TD::Types::Supergroup]
1833
+ def get_supergroup(supergroup_id)
1834
+ broadcast('@type' => 'getSupergroup',
1835
+ 'supergroup_id' => supergroup_id)
1836
+ end
1837
+
1838
+ # Returns full information about a supergroup or channel by its identifier, cached for up to 1 minute.
1839
+ #
1840
+ # @param supergroup_id [Integer] Supergroup or channel identifier.
1841
+ # @return [TD::Types::SupergroupFullInfo]
1842
+ def get_supergroup_full_info(supergroup_id)
1843
+ broadcast('@type' => 'getSupergroupFullInfo',
1844
+ 'supergroup_id' => supergroup_id)
1845
+ end
1846
+
1847
+ # Returns information about members or banned users in a supergroup or channel.
1848
+ # Can be used only if SupergroupFullInfo.can_get_members == true; additionally, administrator privileges may be
1849
+ # required for some filters.
1850
+ #
1851
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
1852
+ # @param filter [TD::Types::SupergroupMembersFilter] The type of users to return.
1853
+ # By default, {TD::Types::SupergroupMembersFilter::Recent}.
1854
+ # @param offset [Integer] Number of users to skip.
1855
+ # @param limit [Integer] The maximum number of users be returned; up to 200.
1856
+ # @return [TD::Types::ChatMembers]
1857
+ def get_supergroup_members(supergroup_id, filter, offset, limit)
1858
+ broadcast('@type' => 'getSupergroupMembers',
1859
+ 'supergroup_id' => supergroup_id,
1860
+ 'filter' => filter,
1861
+ 'offset' => offset,
1862
+ 'limit' => limit)
1863
+ end
1864
+
1865
+ # Returns a user that can be contacted to get support.
1866
+ #
1867
+ # @return [TD::Types::User]
1868
+ def get_support_user
1869
+ broadcast('@type' => 'getSupportUser')
1870
+ end
1871
+
1872
+ # Returns information about the current temporary password.
1873
+ #
1874
+ # @return [TD::Types::TemporaryPasswordState]
1875
+ def get_temporary_password_state
1876
+ broadcast('@type' => 'getTemporaryPasswordState')
1877
+ end
1878
+
1879
+ # Returns all entities (mentions, hashtags, cashtags, bot commands, URLs, and email addresses) contained in the text.
1880
+ # This is an offline method.
1881
+ # Can be called before authorization.
1882
+ # Can be called synchronously.
1883
+ #
1884
+ # @param text [String] The text in which to look for entites.
1885
+ # @return [TD::Types::TextEntities]
1886
+ def get_text_entities(text)
1887
+ broadcast('@type' => 'getTextEntities',
1888
+ 'text' => text)
1889
+ end
1890
+
1891
+ # Returns a list of frequently used chats.
1892
+ # Supported only if the chat info database is enabled.
1893
+ #
1894
+ # @param category [TD::Types::TopChatCategory] Category of chats to be returned.
1895
+ # @param limit [Integer] Maximum number of chats to be returned; up to 30.
1896
+ # @return [TD::Types::Chats]
1897
+ def get_top_chats(category, limit = 30)
1898
+ broadcast('@type' => 'getTopChats',
1899
+ 'category' => category,
1900
+ 'limit' => limit)
1901
+ end
1902
+
1903
+ # Returns a list of trending sticker sets.
1904
+ #
1905
+ # @return [TD::Types::StickerSets]
1906
+ def get_trending_sticker_sets
1907
+ broadcast('@type' => 'getTrendingStickerSets')
1908
+ end
1909
+
1910
+ # Returns information about a user by their identifier.
1911
+ # This is an offline request if the current user is not a bot.
1912
+ #
1913
+ # @param user_id [Integer] User identifier.
1914
+ # @return [TD::Types::User]
1915
+ def get_user(user_id)
1916
+ broadcast('@type' => 'getUser',
1917
+ 'user_id' => user_id)
1918
+ end
1919
+
1920
+ # Returns full information about a user by their identifier.
1921
+ #
1922
+ # @param user_id [Integer] User identifier.
1923
+ # @return [TD::Types::UserFullInfo]
1924
+ def get_user_full_info(user_id)
1925
+ broadcast('@type' => 'getUserFullInfo',
1926
+ 'user_id' => user_id)
1927
+ end
1928
+
1929
+ # Returns the current privacy settings.
1930
+ #
1931
+ # @param setting [TD::Types::UserPrivacySetting] The privacy setting.
1932
+ # @return [TD::Types::UserPrivacySettingRules]
1933
+ def get_user_privacy_setting_rules(setting)
1934
+ broadcast('@type' => 'getUserPrivacySettingRules',
1935
+ 'setting' => setting)
1936
+ end
1937
+
1938
+ # Returns the profile photos of a user.
1939
+ # The result of this query may be outdated: some photos might have been deleted already.
1940
+ #
1941
+ # @param user_id [Integer] User identifier.
1942
+ # @param offset [Integer] The number of photos to skip; must be non-negative.
1943
+ # @param limit [Integer] Maximum number of photos to be returned; up to 100.
1944
+ # @return [TD::Types::UserProfilePhotos]
1945
+ def get_user_profile_photos(user_id, offset = 0, limit = 100)
1946
+ broadcast('@type' => 'getUserProfilePhotos',
1947
+ 'user_id' => user_id,
1948
+ 'offset' => offset,
1949
+ 'limit' => limit)
1950
+ end
1951
+
1952
+ # Returns background wallpapers.
1953
+ #
1954
+ # @return [TD::Types::Wallpapers]
1955
+ def get_wallpapers
1956
+ broadcast('@type' => 'getWallpapers')
1957
+ end
1958
+
1959
+ # Returns an instant view version of a web page if available.
1960
+ # Returns a 404 error if the web page has no instant view page.
1961
+ #
1962
+ # @param url [String] The web page URL.
1963
+ # @param force_full [Boolean] If true, the full instant view for the web page will be returned.
1964
+ # @return [TD::Types::WebPageInstantView]
1965
+ def get_web_page_instant_view(url, force_full = false)
1966
+ broadcast('@type' => 'getWebPageInstantView',
1967
+ 'url' => url,
1968
+ 'force_full' => force_full)
1969
+ end
1970
+
1971
+ # Returns a web page preview by the text of the message.
1972
+ # Do not call this function too often.
1973
+ # Returns a 404 error if the web page has no preview.
1974
+ #
1975
+ # @param text [TD::Types::FormattedText] Message text with formatting.
1976
+ # @return [TD::Types::WebPage]
1977
+ def get_web_page_preview(text)
1978
+ broadcast('@type' => 'getWebPagePreview',
1979
+ 'text' => text)
1980
+ end
1981
+
1982
+ # Adds new contacts or edits existing contacts; contacts' user identifiers are ignored.
1983
+ #
1984
+ # @param contacts [Array<TD::Types::Contact>] The list of contacts to import or edit, contact's vCard are ignored and
1985
+ # are not imported.
1986
+ # @return [TD::Types::ImportedContacts]
1987
+ def import_contacts(contacts)
1988
+ broadcast('@type' => 'importContacts',
1989
+ 'contacts' => contacts)
1990
+ end
1991
+
1992
+ # Adds current user as a new member to a chat.
1993
+ # Private and secret chats can't be joined using this method.
1994
+ #
1995
+ # @param chat_id [Integer] Chat identifier.
1996
+ # @return [TD::Types::Ok]
1997
+ def join_chat(chat_id)
1998
+ broadcast('@type' => 'joinChat',
1999
+ 'chat_id' => chat_id)
2000
+ end
2001
+
2002
+ # Uses an invite link to add the current user to the chat if possible.
2003
+ # The new member will not be added until the chat state has been synchronized with the server.
2004
+ #
2005
+ # @param invite_link [String] Invite link to import; should begin with "https://t.me/joinchat/",
2006
+ # "https://telegram.me/joinchat/", or "https://telegram.dog/joinchat/".
2007
+ # @return [TD::Types::Chat]
2008
+ def join_chat_by_invite_link(invite_link)
2009
+ broadcast('@type' => 'joinChatByInviteLink',
2010
+ 'invite_link' => invite_link)
2011
+ end
2012
+
2013
+ # Removes current user from chat members.
2014
+ # Private and secret chats can't be left using this method.
2015
+ #
2016
+ # @param chat_id [Integer] Chat identifier.
2017
+ # @return [TD::Types::Ok]
2018
+ def leave_chat(chat_id)
2019
+ broadcast('@type' => 'leaveChat',
2020
+ 'chat_id' => chat_id)
2021
+ end
2022
+
2023
+ # Closes the TDLib instance after a proper logout.
2024
+ # Requires an available network connection.
2025
+ # All local data will be destroyed.
2026
+ # After the logout completes, {TD::Types::Update::AuthorizationState} with {TD::Types::AuthorizationState::Closed}
2027
+ # will be sent.
2028
+ #
2029
+ # @return [TD::Types::Ok]
2030
+ def log_out
2031
+ broadcast('@type' => 'logOut')
2032
+ end
2033
+
2034
+ # This method should be called if the chat is opened by the user.
2035
+ # Many useful activities depend on the chat being opened or closed (e.g., in supergroups and channels all updates are
2036
+ # received only for opened chats).
2037
+ #
2038
+ # @param chat_id [Integer] Chat identifier.
2039
+ # @return [TD::Types::Ok]
2040
+ def open_chat(chat_id)
2041
+ broadcast('@type' => 'openChat',
2042
+ 'chat_id' => chat_id)
2043
+ end
2044
+
2045
+ # This method should be called if the message content has been opened (e.g., the user has opened a photo, video,
2046
+ # document, location or venue, or has listened to an audio file or voice note message).
2047
+ # An {TD::Types::Update::MessageContentOpened} will be generated if something has changed.
2048
+ #
2049
+ # @param chat_id [Integer] Chat identifier of the message.
2050
+ # @param message_id [Integer] Identifier of the message with the opened content.
2051
+ # @return [TD::Types::Ok]
2052
+ def open_message_content(chat_id, message_id)
2053
+ broadcast('@type' => 'openMessageContent',
2054
+ 'chat_id' => chat_id,
2055
+ 'message_id' => message_id)
2056
+ end
2057
+
2058
+ # Optimizes storage usage, i.e. deletes some files and returns new storage usage statistics.
2059
+ # Secret thumbnails can't be deleted.
2060
+ #
2061
+ # @param size [Integer] Limit on the total size of files after deletion.
2062
+ # Pass -1 to use the default limit.
2063
+ # @param ttl [Integer] Limit on the time that has passed since the last time a file was accessed (or creation time
2064
+ # for some filesystems).
2065
+ # Pass -1 to use the default limit.
2066
+ # @param count [Integer] Limit on the total count of files after deletion.
2067
+ # Pass -1 to use the default limit.
2068
+ # @param immunity_delay [Integer] The amount of time after the creation of a file during which it can't be deleted,
2069
+ # in seconds.
2070
+ # Pass -1 to use the default value.
2071
+ # @param file_types [Array<TD::Types::FileType>, nil] If not empty, only files with the given type(s) are considered.
2072
+ # By default, all types except thumbnails, profile photos, stickers and wallpapers are deleted.
2073
+ # @param chat_ids [Array<Integer>, nil] If not empty, only files from the given chats are considered.
2074
+ # Use 0 as chat identifier to delete files not belonging to any chat (e.g., profile photos).
2075
+ # @param exclude_chat_ids [Array<Integer>, nil] If not empty, files from the given chats are excluded.
2076
+ # Use 0 as chat identifier to exclude all files not belonging to any chat (e.g., profile photos).
2077
+ # @param chat_limit [Integer, nil] Same as in {#get_storage_statistics}.
2078
+ # Affects only returned statistics.
2079
+ # @return [TD::Types::StorageStatistics]
2080
+ def optimize_storage(size: -1, ttl: -1, count: -1, immunity_delay: -1,
2081
+ file_types: nil, chat_ids: nil, exclude_chat_ids: nil, chat_limit: nil)
2082
+ broadcast('@type' => 'optimizeStorage',
2083
+ 'size' => size,
2084
+ 'ttl' => ttl,
2085
+ 'count' => count,
2086
+ 'immunity_delay' => immunity_delay,
2087
+ 'file_types' => file_types,
2088
+ 'chat_ids' => chat_ids,
2089
+ 'exclude_chat_ids' => exclude_chat_ids,
2090
+ 'chat_limit' => chat_limit)
2091
+ end
2092
+
2093
+ # Parses Bold, Italic, Code, Pre, PreCode and TextUrl entities contained in the text.
2094
+ # This is an offline method.
2095
+ # Can be called before authorization.
2096
+ # Can be called synchronously.
2097
+ #
2098
+ # @param text [String] The text which should be parsed.
2099
+ # @param parse_mode [TD::Types::TextParseMode] Text parse mode.
2100
+ # @return [TD::Types::FormattedText]
2101
+ def parse_text_entities(text, parse_mode)
2102
+ broadcast('@type' => 'parseTextEntities',
2103
+ 'text' => text,
2104
+ 'parse_mode' => parse_mode)
2105
+ end
2106
+
2107
+ # Pins a message in a supergroup or channel; requires appropriate administrator rights in the supergroup or channel.
2108
+ #
2109
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
2110
+ # @param message_id [Integer] Identifier of the new pinned message.
2111
+ # @param disable_notification [Boolean] True, if there should be no notification about the pinned message.
2112
+ # @return [TD::Types::Ok]
2113
+ def pin_supergroup_message(supergroup_id, message_id, disable_notification: false)
2114
+ broadcast('@type' => 'pinSupergroupMessage',
2115
+ 'supergroup_id' => supergroup_id,
2116
+ 'message_id' => message_id,
2117
+ 'disable_notification' => disable_notification)
2118
+ end
2119
+
2120
+ # Computes time needed to receive a response from a Telegram server through a proxy.
2121
+ # Can be called before authorization.
2122
+ #
2123
+ # @param proxy_id [Integer] Proxy identifier.
2124
+ # Use 0 to ping a Telegram server without a proxy.
2125
+ # @return [TD::Types::Seconds]
2126
+ def ping_proxy(proxy_id)
2127
+ broadcast('@type' => 'pingProxy',
2128
+ 'proxy_id' => proxy_id)
2129
+ end
2130
+
2131
+ # Handles a DC_UPDATE push service notification.
2132
+ # Can be called before authorization.
2133
+ #
2134
+ # @param dc [String] Value of the "dc" parameter of the notification.
2135
+ # @param addr [String] Value of the "addr" parameter of the notification.
2136
+ # @return [TD::Types::Ok]
2137
+ def process_dc_update(dc, addr)
2138
+ broadcast('@type' => 'processDcUpdate',
2139
+ 'dc' => dc,
2140
+ 'addr' => addr)
2141
+ end
2142
+
2143
+ # Marks all mentions in a chat as read.
2144
+ #
2145
+ # @param chat_id [Integer] Chat identifier.
2146
+ # @return [TD::Types::Ok]
2147
+ def read_all_chat_mentions(chat_id)
2148
+ broadcast('@type' => 'readAllChatMentions',
2149
+ 'chat_id' => chat_id)
2150
+ end
2151
+
2152
+ # Recovers the password with a password recovery code sent to an email address that was previously set up.
2153
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}.
2154
+ #
2155
+ # @param recovery_code [String] Recovery code to check.
2156
+ # @return [TD::Types::Ok]
2157
+ def recover_authentication_password(recovery_code)
2158
+ broadcast('@type' => 'recoverAuthenticationPassword',
2159
+ 'recovery_code' => recovery_code)
2160
+ end
2161
+
2162
+ # Recovers the password using a recovery code sent to an email address that was previously set up.
2163
+ #
2164
+ # @param recovery_code [String] Recovery code to check.
2165
+ # @return [TD::Types::PasswordState]
2166
+ def recover_password(recovery_code)
2167
+ broadcast('@type' => 'recoverPassword',
2168
+ 'recovery_code' => recovery_code)
2169
+ end
2170
+
2171
+ # Registers the currently used device for receiving push notifications.
2172
+ #
2173
+ # @param device_token [TD::Types::DeviceToken] Device token.
2174
+ # @param other_user_ids [Array<Integer>] List of at most 100 user identifiers of other users currently using the
2175
+ # client.
2176
+ # @return [TD::Types::Ok]
2177
+ def register_device(device_token, other_user_ids = [])
2178
+ broadcast('@type' => 'registerDevice',
2179
+ 'device_token' => device_token,
2180
+ 'other_user_ids' => other_user_ids)
2181
+ end
2182
+
2183
+ # Removes users from the contacts list.
2184
+ #
2185
+ # @param user_ids [Array<Integer>] Identifiers of users to be deleted.
2186
+ # @return [TD::Types::Ok]
2187
+ def remove_contacts(user_ids)
2188
+ broadcast('@type' => 'removeContacts',
2189
+ 'user_ids' => user_ids)
2190
+ end
2191
+
2192
+ # Removes a sticker from the list of favorite stickers.
2193
+ #
2194
+ # @param sticker [TD::Types::InputFile] Sticker file to delete from the list.
2195
+ # @return [TD::Types::Ok]
2196
+ def remove_favorite_sticker(sticker)
2197
+ broadcast('@type' => 'removeFavoriteSticker',
2198
+ 'sticker' => sticker)
2199
+ end
2200
+
2201
+ # Removes a proxy server.
2202
+ # Can be called before authorization.
2203
+ #
2204
+ # @param proxy_id [Integer] Proxy identifier.
2205
+ # @return [TD::Types::Ok]
2206
+ def remove_proxy(proxy_id)
2207
+ broadcast('@type' => 'removeProxy',
2208
+ 'proxy_id' => proxy_id)
2209
+ end
2210
+
2211
+ # Removes a hashtag from the list of recently used hashtags.
2212
+ #
2213
+ # @param hashtag [String] Hashtag to delete.
2214
+ # @return [TD::Types::Ok]
2215
+ def remove_recent_hashtag(hashtag)
2216
+ broadcast('@type' => 'removeRecentHashtag',
2217
+ 'hashtag' => hashtag)
2218
+ end
2219
+
2220
+ # Removes a sticker from the list of recently used stickers.
2221
+ #
2222
+ # @param is_attached [Boolean] Pass true to remove the sticker from the list of stickers recently attached to photo
2223
+ # or video files; pass false to remove the sticker from the list of recently sent stickers.
2224
+ # @param sticker [TD::Types::InputFile] Sticker file to delete.
2225
+ # @return [TD::Types::Ok]
2226
+ def remove_recent_sticker(sticker, is_attached: false)
2227
+ broadcast('@type' => 'removeRecentSticker',
2228
+ 'is_attached' => is_attached,
2229
+ 'sticker' => sticker)
2230
+ end
2231
+
2232
+ # Removes a chat from the list of recently found chats.
2233
+ #
2234
+ # @param chat_id [Integer] Identifier of the chat to be removed.
2235
+ # @return [TD::Types::Ok]
2236
+ def remove_recently_found_chat(chat_id)
2237
+ broadcast('@type' => 'removeRecentlyFoundChat',
2238
+ 'chat_id' => chat_id)
2239
+ end
2240
+
2241
+ # Removes an animation from the list of saved animations.
2242
+ #
2243
+ # @param animation [TD::Types::InputFile] Animation file to be removed.
2244
+ # @return [TD::Types::Ok]
2245
+ def remove_saved_animation(animation)
2246
+ broadcast('@type' => 'removeSavedAnimation',
2247
+ 'animation' => animation)
2248
+ end
2249
+
2250
+ # Removes a sticker from the set to which it belongs; for bots only.
2251
+ # The sticker set must have been created by the bot.
2252
+ #
2253
+ # @param sticker [TD::Types::InputFile] Sticker.
2254
+ # @return [TD::Types::Ok]
2255
+ def remove_sticker_from_set(sticker)
2256
+ broadcast('@type' => 'removeStickerFromSet',
2257
+ 'sticker' => sticker)
2258
+ end
2259
+
2260
+ # Removes a chat from the list of frequently used chats.
2261
+ # Supported only if the chat info database is enabled.
2262
+ #
2263
+ # @param category [TD::Types::TopChatCategory] Category of frequently used chats.
2264
+ # @param chat_id [Integer] Chat identifier.
2265
+ # @return [TD::Types::Ok]
2266
+ def remove_top_chat(category, chat_id)
2267
+ broadcast('@type' => 'removeTopChat',
2268
+ 'category' => category,
2269
+ 'chat_id' => chat_id)
2270
+ end
2271
+
2272
+ # Changes the order of installed sticker sets.
2273
+ #
2274
+ # @param is_masks [Boolean] Pass true to change the order of mask sticker sets; pass false to change the order of
2275
+ # ordinary sticker sets.
2276
+ # @param sticker_set_ids [Array<Integer>] Identifiers of installed sticker sets in the new correct order.
2277
+ # @return [TD::Types::Ok]
2278
+ def reorder_installed_sticker_sets(sticker_set_ids, is_masks: false)
2279
+ broadcast('@type' => 'reorderInstalledStickerSets',
2280
+ 'is_masks' => is_masks,
2281
+ 'sticker_set_ids' => sticker_set_ids)
2282
+ end
2283
+
2284
+ # Reports a chat to the Telegram moderators.
2285
+ # Supported only for supergroups, channels, or private chats with bots, since other chats can't be checked by
2286
+ # moderators.
2287
+ #
2288
+ # @param chat_id [Integer] Chat identifier.
2289
+ # @param reason [TD::Types::ChatReportReason] The reason for reporting the chat.
2290
+ # @param message_ids [Array<Integer>] Identifiers of reported messages, if any.
2291
+ # @return [TD::Types::Ok]
2292
+ def report_chat(chat_id, reason, message_ids = [])
2293
+ broadcast('@type' => 'reportChat',
2294
+ 'chat_id' => chat_id,
2295
+ 'reason' => reason,
2296
+ 'message_ids' => message_ids)
2297
+ end
2298
+
2299
+ # Reports some messages from a user in a supergroup as spam; requires administrator rights in the supergroup.
2300
+ #
2301
+ # @param supergroup_id [Integer] Supergroup identifier.
2302
+ # @param user_id [Integer] User identifier.
2303
+ # @param message_ids [Array<Integer>] Identifiers of messages sent in the supergroup by the user.
2304
+ # This list must be non-empty.
2305
+ # @return [TD::Types::Ok]
2306
+ def report_supergroup_spam(supergroup_id, user_id, message_ids = [])
2307
+ broadcast('@type' => 'reportSupergroupSpam',
2308
+ 'supergroup_id' => supergroup_id,
2309
+ 'user_id' => user_id,
2310
+ 'message_ids' => message_ids)
2311
+ end
2312
+
2313
+ # Requests to send a password recovery code to an email address that was previously set up.
2314
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPassword}.
2315
+ #
2316
+ # @return [TD::Types::Ok]
2317
+ def request_authentication_password_recovery
2318
+ broadcast('@type' => 'requestAuthenticationPasswordRecovery')
2319
+ end
2320
+
2321
+ # Requests to send a password recovery code to an email address that was previously set up.
2322
+ #
2323
+ # @return [TD::Types::EmailAddressAuthenticationCodeInfo]
2324
+ def request_password_recovery
2325
+ broadcast('@type' => 'requestPasswordRecovery')
2326
+ end
2327
+
2328
+ # Re-sends an authentication code to the user.
2329
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitCode} and the
2330
+ # {TD::Types::AuthenticationCodeInfo#next_type} of the result is not nil.
2331
+ #
2332
+ # @return [TD::Types::Ok]
2333
+ def resend_authentication_code
2334
+ broadcast('@type' => 'resendAuthenticationCode')
2335
+ end
2336
+
2337
+ # Re-sends the authentication code sent to confirm a new phone number for the user.
2338
+ # Works only if the previously received {TD::Types::AuthenticationCodeInfo#next_type} was not nil.
2339
+ #
2340
+ # @return [TD::Types::AuthenticationCodeInfo]
2341
+ def resend_change_phone_number_code
2342
+ broadcast('@type' => 'resendChangePhoneNumberCode')
2343
+ end
2344
+
2345
+ # Re-sends the code to verify an email address to be added to a user's Telegram Passport.
2346
+ #
2347
+ # @return [TD::Types::EmailAddressAuthenticationCodeInfo]
2348
+ def resend_email_address_verification_code
2349
+ broadcast('@type' => 'resendEmailAddressVerificationCode')
2350
+ end
2351
+
2352
+ # Resends phone number confirmation code.
2353
+ #
2354
+ # @return [TD::Types::AuthenticationCodeInfo]
2355
+ def resend_phone_number_confirmation_code
2356
+ broadcast('@type' => 'resendPhoneNumberConfirmationCode')
2357
+ end
2358
+
2359
+ # Re-sends the code to verify a phone number to be added to a user's Telegram Passport.
2360
+ #
2361
+ # @return [TD::Types::AuthenticationCodeInfo]
2362
+ def resend_phone_number_verification_code
2363
+ broadcast('@type' => 'resendPhoneNumberVerificationCode')
2364
+ end
2365
+
2366
+ # Resets all notification settings to their default values.
2367
+ # By default, all chats are unmuted, the sound is set to "default" and message previews are shown.
2368
+ #
2369
+ # @return [TD::Types::Ok]
2370
+ def reset_all_notification_settings
2371
+ broadcast('@type' => 'resetAllNotificationSettings')
2372
+ end
2373
+
2374
+ # Resets all network data usage statistics to zero.
2375
+ # Can be called before authorization.
2376
+ #
2377
+ # @return [TD::Types::Ok]
2378
+ def reset_network_statistics
2379
+ broadcast('@type' => 'resetNetworkStatistics')
2380
+ end
2381
+
2382
+ # Searches for call messages.
2383
+ # Returns the results in reverse chronological order (i.e., in order of decreasing message_id).
2384
+ # For optimal performance the number of returned messages is chosen by the library.
2385
+ #
2386
+ # @param from_message_id [Integer] Identifier of the message from which to search; use 0 to get results from the last
2387
+ # message.
2388
+ # @param limit [Integer] The maximum number of messages to be returned; up to 100.
2389
+ # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been
2390
+ # reached.
2391
+ # @param only_missed [Boolean] If true, returns only messages with missed calls.
2392
+ # @return [TD::Types::Messages]
2393
+ def search_call_messages(from_message_id, limit = 100, only_missed: false)
2394
+ broadcast('@type' => 'searchCallMessages',
2395
+ 'from_message_id' => from_message_id,
2396
+ 'limit' => limit,
2397
+ 'only_missed' => only_missed)
2398
+ end
2399
+
2400
+ # Searches for a specified query in the first name, last name and username of the members of a specified chat.
2401
+ # Requires administrator rights in channels.
2402
+ #
2403
+ # @param chat_id [Integer] Chat identifier.
2404
+ # @param query [String, nil] Query to search for.
2405
+ # @param limit [Integer] The maximum number of users to be returned.
2406
+ # @param filter [TD::Types::ChatMembersFilter] The type of users to return.
2407
+ # By default, {TD::Types::ChatMembersFilter::Members}.
2408
+ # @return [TD::Types::ChatMembers]
2409
+ def search_chat_members(chat_id, limit = 100, query: nil, filter: ChatMembersFilter::Members.new)
2410
+ broadcast('@type' => 'searchChatMembers',
2411
+ 'chat_id' => chat_id,
2412
+ 'query' => query,
2413
+ 'limit' => limit,
2414
+ 'filter' => filter)
2415
+ end
2416
+
2417
+ # Searches for messages with given words in the chat.
2418
+ # Returns the results in reverse chronological order, i.e. in order of decreasing message_id.
2419
+ # Cannot be used in secret chats with a non-empty query (searchSecretMessages should be used instead), or without an
2420
+ # enabled message database.
2421
+ # For optimal performance the number of returned messages is chosen by the library.
2422
+ #
2423
+ # @param chat_id [Integer] Identifier of the chat in which to search messages.
2424
+ # @param query [String, nil] Query to search for.
2425
+ # @param sender_user_id [Integer] If not 0, only messages sent by the specified user will be returned.
2426
+ # Not supported in secret chats.
2427
+ # @param from_message_id [Integer] Identifier of the message starting from which history must be fetched; use 0 to
2428
+ # get results from the last message.
2429
+ # @param offset [Integer] Specify 0 to get results from exactly the from_message_id or a negative offset to get the
2430
+ # specified message and some newer messages.
2431
+ # @param limit [Integer] The maximum number of messages to be returned; must be positive and can't be greater than
2432
+ # 100.
2433
+ # If the offset is negative, the limit must be greater than -offset.
2434
+ # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been
2435
+ # reached.
2436
+ # @param filter [TD::Types::SearchMessagesFilter] Filter for message content in the search results.
2437
+ # @return [TD::Types::Messages]
2438
+ def search_chat_messages(chat_id, offset = 0, limit = 100,
2439
+ query: nil, sender_user_id: 0, from_message_id: 0, filter: SearchMessagesFilter::Empty.new)
2440
+ broadcast('@type' => 'searchChatMessages',
2441
+ 'chat_id' => chat_id,
2442
+ 'query' => query,
2443
+ 'sender_user_id' => sender_user_id,
2444
+ 'from_message_id' => from_message_id,
2445
+ 'offset' => offset,
2446
+ 'limit' => limit,
2447
+ 'filter' => filter)
2448
+ end
2449
+
2450
+ # Returns information about the recent locations of chat members that were sent to the chat.
2451
+ # Returns up to 1 location message per user.
2452
+ #
2453
+ # @param chat_id [Integer] Chat identifier.
2454
+ # @param limit [Integer] Maximum number of messages to be returned.
2455
+ # @return [TD::Types::Messages]
2456
+ def search_chat_recent_location_messages(chat_id, limit = 100)
2457
+ broadcast('@type' => 'searchChatRecentLocationMessages',
2458
+ 'chat_id' => chat_id,
2459
+ 'limit' => limit)
2460
+ end
2461
+
2462
+ # Searches for the specified query in the title and username of already known chats, this is an offline request.
2463
+ # Returns chats in the order seen in the chat list.
2464
+ #
2465
+ # @param query [String, nil] Query to search for.
2466
+ # If the query is empty, returns up to 20 recently found chats.
2467
+ # @param limit [Integer] Maximum number of chats to be returned.
2468
+ # @return [TD::Types::Chats]
2469
+ def search_chats(query = nil, limit = 100)
2470
+ broadcast('@type' => 'searchChats',
2471
+ 'query' => query,
2472
+ 'limit' => limit)
2473
+ end
2474
+
2475
+ # Searches for the specified query in the title and username of already known chats via request to the server.
2476
+ # Returns chats in the order seen in the chat list.
2477
+ #
2478
+ # @param query [String] Query to search for.
2479
+ # @param limit [Integer] Maximum number of chats to be returned.
2480
+ # @return [TD::Types::Chats]
2481
+ def search_chats_on_server(query, limit = 100)
2482
+ broadcast('@type' => 'searchChatsOnServer',
2483
+ 'query' => query,
2484
+ 'limit' => limit)
2485
+ end
2486
+
2487
+ # Searches for the specified query in the first names, last names and usernames of the known user contacts.
2488
+ #
2489
+ # @param query [String, nil] Query to search for; can be empty to return all contacts.
2490
+ # @param limit [Integer] Maximum number of users to be returned.
2491
+ # @return [TD::Types::Users]
2492
+ def search_contacts(query = nil, limit = 100)
2493
+ broadcast('@type' => 'searchContacts',
2494
+ 'query' => query,
2495
+ 'limit' => limit)
2496
+ end
2497
+
2498
+ # Searches for recently used hashtags by their prefix.
2499
+ #
2500
+ # @param prefix [String, nil] Hashtag prefix to search for.
2501
+ # @param limit [Integer] Maximum number of hashtags to be returned.
2502
+ # @return [TD::Types::Hashtags]
2503
+ def search_hashtags(prefix = nil, limit = 100)
2504
+ broadcast('@type' => 'searchHashtags',
2505
+ 'prefix' => prefix,
2506
+ 'limit' => limit)
2507
+ end
2508
+
2509
+ # Searches for installed sticker sets by looking for specified query in their title and name.
2510
+ #
2511
+ # @param is_masks [Boolean] Pass true to return mask sticker sets; pass false to return ordinary sticker sets.
2512
+ # @param query [String, nil] Query to search for.
2513
+ # @param limit [Integer] Maximum number of sticker sets to return.
2514
+ # @return [TD::Types::StickerSets]
2515
+ def search_installed_sticker_sets(query = nil, limit = 100, is_masks: false)
2516
+ broadcast('@type' => 'searchInstalledStickerSets',
2517
+ 'is_masks' => is_masks,
2518
+ 'query' => query,
2519
+ 'limit' => limit)
2520
+ end
2521
+
2522
+ # Searches for messages in all chats except secret chats.
2523
+ # Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)).
2524
+ # For optimal performance the number of returned messages is chosen by the library.
2525
+ #
2526
+ # @param query [String] Query to search for.
2527
+ # @param offset_date [Integer] The date of the message starting from which the results should be fetched.
2528
+ # Use 0 or any date in the future to get results from the last message.
2529
+ # @param offset_chat_id [Integer] The chat identifier of the last found message, or 0 for the first request.
2530
+ # @param offset_message_id [Integer] The message identifier of the last found message, or 0 for the first request.
2531
+ # @param limit [Integer] The maximum number of messages to be returned, up to 100.
2532
+ # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been
2533
+ # reached.
2534
+ # @return [TD::Types::Messages]
2535
+ def search_messages(query, limit = 100, offset_date: 0, offset_chat_id: 0, offset_message_id: 0)
2536
+ broadcast('@type' => 'searchMessages',
2537
+ 'query' => query,
2538
+ 'offset_date' => offset_date,
2539
+ 'offset_chat_id' => offset_chat_id,
2540
+ 'offset_message_id' => offset_message_id,
2541
+ 'limit' => limit)
2542
+ end
2543
+
2544
+ # Searches a public chat by its username.
2545
+ # Currently only private chats, supergroups and channels can be public.
2546
+ # Returns the chat if found; otherwise an error is returned.
2547
+ #
2548
+ # @param username [String] Username to be resolved.
2549
+ # @return [TD::Types::Chat]
2550
+ def search_public_chat(username)
2551
+ broadcast('@type' => 'searchPublicChat',
2552
+ 'username' => username)
2553
+ end
2554
+
2555
+ # Searches public chats by looking for specified query in their username and title.
2556
+ # Currently only private chats, supergroups and channels can be public.
2557
+ # Returns a meaningful number of results.
2558
+ # Returns nothing if the length of the searched username prefix is less than 5.
2559
+ # Excludes private chats with contacts and chats from the chat list from the results.
2560
+ #
2561
+ # @param query [String] Query to search for.
2562
+ # @return [TD::Types::Chats]
2563
+ def search_public_chats(query)
2564
+ broadcast('@type' => 'searchPublicChats',
2565
+ 'query' => query)
2566
+ end
2567
+
2568
+ # Searches for messages in secret chats.
2569
+ # Returns the results in reverse chronological order.
2570
+ # For optimal performance the number of returned messages is chosen by the library.
2571
+ #
2572
+ # @param chat_id [Integer] Identifier of the chat in which to search.
2573
+ # Specify 0 to search in all secret chats.
2574
+ # @param query [String] Query to search for.
2575
+ # If empty, {#search_chat_messages} should be used instead.
2576
+ # @param from_search_id [Integer] The identifier from the result of a previous request, use 0 to get results from the
2577
+ # last message.
2578
+ # @param limit [Integer] Maximum number of messages to be returned; up to 100.
2579
+ # Fewer messages may be returned than specified by the limit, even if the end of the message history has not been
2580
+ # reached.
2581
+ # @param filter [TD::Types::SearchMessagesFilter] A filter for the content of messages in the search results.
2582
+ # @return [TD::Types::FoundMessages]
2583
+ def search_secret_messages(chat_id, query, limit = 100, from_search_id: 0, filter: SearchMessagesFilter::Empty.new)
2584
+ broadcast('@type' => 'searchSecretMessages',
2585
+ 'chat_id' => chat_id,
2586
+ 'query' => query,
2587
+ 'from_search_id' => from_search_id,
2588
+ 'limit' => limit,
2589
+ 'filter' => filter)
2590
+ end
2591
+
2592
+ # Searches for a sticker set by its name.
2593
+ #
2594
+ # @param name [String] Name of the sticker set.
2595
+ # @return [TD::Types::StickerSet]
2596
+ def search_sticker_set(name)
2597
+ broadcast('@type' => 'searchStickerSet',
2598
+ 'name' => name)
2599
+ end
2600
+
2601
+ # Searches for ordinary sticker sets by looking for specified query in their title and name.
2602
+ # Excludes installed sticker sets from the results.
2603
+ #
2604
+ # @param query [String] Query to search for.
2605
+ # @return [TD::Types::StickerSets]
2606
+ def search_sticker_sets(query)
2607
+ broadcast('@type' => 'searchStickerSets',
2608
+ 'query' => query)
2609
+ end
2610
+
2611
+ # Searches for stickers from public sticker sets that correspond to a given emoji.
2612
+ #
2613
+ # @param emoji [String] String representation of emoji; must be non-empty.
2614
+ # @param limit [Integer] Maximum number of stickers to be returned.
2615
+ # @return [TD::Types::Stickers]
2616
+ def search_stickers(emoji, limit = 100)
2617
+ broadcast('@type' => 'searchStickers',
2618
+ 'emoji' => emoji,
2619
+ 'limit' => limit)
2620
+ end
2621
+
2622
+ # Invites a bot to a chat (if it is not yet a member) and sends it the /start command.
2623
+ # Bots can't be invited to a private chat other than the chat with the bot.
2624
+ # Bots can't be invited to channels (although they can be added as admins) and secret chats.
2625
+ #
2626
+ # @param bot_user_id [Integer] Identifier of the bot.
2627
+ # @param chat_id [Integer] Identifier of the target chat.
2628
+ # @param parameter [String, nil] A hidden parameter sent to the bot for deep linking purposes
2629
+ # @see https://api.telegram.org/bots#deep-linking
2630
+ # @return [TD::Types::Message] the sent message.
2631
+ def send_bot_start_message(bot_user_id, chat_id, parameter = nil)
2632
+ broadcast('@type' => 'sendBotStartMessage',
2633
+ 'bot_user_id' => bot_user_id,
2634
+ 'chat_id' => chat_id,
2635
+ 'parameter' => parameter)
2636
+ end
2637
+
2638
+ # Sends debug information for a call.
2639
+ #
2640
+ # @param call_id [Integer] Call identifier.
2641
+ # @param debug_information [String] Debug information in application-specific format.
2642
+ # @return [TD::Types::Ok]
2643
+ def send_call_debug_information(call_id, debug_information)
2644
+ broadcast('@type' => 'sendCallDebugInformation',
2645
+ 'call_id' => call_id,
2646
+ 'debug_information' => debug_information)
2647
+ end
2648
+
2649
+ # Sends a call rating.
2650
+ #
2651
+ # @param call_id [Integer] Call identifier.
2652
+ # @param rating [Integer] Call rating; 1-5.
2653
+ # @param comment [String, nil] An optional user comment if the rating is less than 5.
2654
+ # @return [TD::Types::Ok]
2655
+ def send_call_rating(call_id, rating, comment = nil)
2656
+ broadcast('@type' => 'sendCallRating',
2657
+ 'call_id' => call_id,
2658
+ 'rating' => rating,
2659
+ 'comment' => comment)
2660
+ end
2661
+
2662
+ # Sends a notification about user activity in a chat.
2663
+ #
2664
+ # @param chat_id [Integer] Chat identifier.
2665
+ # @param action [TD::Types::ChatAction] The action description.
2666
+ # @return [TD::Types::Ok]
2667
+ def send_chat_action(chat_id, action)
2668
+ broadcast('@type' => 'sendChatAction',
2669
+ 'chat_id' => chat_id,
2670
+ 'action' => action)
2671
+ end
2672
+
2673
+ # Sends a notification about a screenshot taken in a chat.
2674
+ # Supported only in private and secret chats.
2675
+ #
2676
+ # @param chat_id [Integer] Chat identifier.
2677
+ # @return [TD::Types::Ok]
2678
+ def send_chat_screenshot_taken_notification(chat_id)
2679
+ broadcast('@type' => 'sendChatScreenshotTakenNotification',
2680
+ 'chat_id' => chat_id)
2681
+ end
2682
+
2683
+ # Changes the current TTL setting (sets a new self-destruct timer) in a secret chat and sends the corresponding
2684
+ # message.
2685
+ #
2686
+ # @param chat_id [Integer] Chat identifier.
2687
+ # @param ttl [Integer] New TTL value, in seconds.
2688
+ # @return [TD::Types::Message]
2689
+ def send_chat_set_ttl_message(chat_id, ttl)
2690
+ broadcast('@type' => 'sendChatSetTtlMessage',
2691
+ 'chat_id' => chat_id,
2692
+ 'ttl' => ttl)
2693
+ end
2694
+
2695
+ # Sends a custom request; for bots only.
2696
+ #
2697
+ # @param method [String] The method name.
2698
+ # @param parameters [String] JSON-serialized method parameters.
2699
+ # @return [TD::Types::CustomRequestResult]
2700
+ def send_custom_request(method, parameters)
2701
+ broadcast('@type' => 'sendCustomRequest',
2702
+ 'method' => method,
2703
+ 'parameters' => parameters)
2704
+ end
2705
+
2706
+ # Sends a code to verify an email address to be added to a user's Telegram Passport.
2707
+ #
2708
+ # @param email_address [String] Email address.
2709
+ # @return [TD::Types::EmailAddressAuthenticationCodeInfo]
2710
+ def send_email_address_verification_code(email_address)
2711
+ broadcast('@type' => 'sendEmailAddressVerificationCode',
2712
+ 'email_address' => email_address)
2713
+ end
2714
+
2715
+ # Sends the result of an inline query as a message.
2716
+ # Returns the sent message.
2717
+ # Always clears a chat draft message.
2718
+ #
2719
+ # @param chat_id [Integer] Target chat.
2720
+ # @param reply_to_message_id [Integer] Identifier of a message to reply to or 0.
2721
+ # @param disable_notification [Boolean] Pass true to disable notification for the message.
2722
+ # Not supported in secret chats.
2723
+ # @param from_background [Boolean] Pass true if the message is sent from background.
2724
+ # @param query_id [Integer] Identifier of the inline query.
2725
+ # @param result_id [String] Identifier of the inline result.
2726
+ # @return [TD::Types::Message]
2727
+ def send_inline_query_result_message(chat_id, query_id, result_id,
2728
+ reply_to_message_id: 0, disable_notification: false, from_background: false)
2729
+ broadcast('@type' => 'sendInlineQueryResultMessage',
2730
+ 'chat_id' => chat_id,
2731
+ 'reply_to_message_id' => reply_to_message_id,
2732
+ 'disable_notification' => disable_notification,
2733
+ 'from_background' => from_background,
2734
+ 'query_id' => query_id,
2735
+ 'result_id' => result_id)
2736
+ end
2737
+
2738
+ # Sends a message.
2739
+ #
2740
+ # @param chat_id [Integer] Target chat.
2741
+ # @param reply_to_message_id [Integer] Identifier of the message to reply to or 0.
2742
+ # @param disable_notification [Boolean] Pass true to disable notification for the message.
2743
+ # Not supported in secret chats.
2744
+ # @param from_background [Boolean] Pass true if the message is sent from the background.
2745
+ # @param reply_markup [TD::Types::ReplyMarkup, nil] Markup for replying to the message; for bots only.
2746
+ # @param input_message_content [TD::Types::InputMessageContent] The content of the message to be sent.
2747
+ # @return [TD::Types::Message] the sent message.
2748
+ def send_message(chat_id, input_message_content,
2749
+ reply_to_message_id: 0, disable_notification: false, from_background: false, reply_markup: nil)
2750
+ broadcast('@type' => 'sendMessage',
2751
+ 'chat_id' => chat_id,
2752
+ 'reply_to_message_id' => reply_to_message_id,
2753
+ 'disable_notification' => disable_notification,
2754
+ 'from_background' => from_background,
2755
+ 'reply_markup' => reply_markup,
2756
+ 'input_message_content' => input_message_content)
2757
+ end
2758
+
2759
+ # Sends messages grouped together into an album.
2760
+ # Currently only photo and video messages can be grouped into an album.
2761
+ #
2762
+ # @param chat_id [Integer] Target chat.
2763
+ # @param reply_to_message_id [Integer] Identifier of a message to reply to or 0.
2764
+ # @param disable_notification [Boolean] Pass true to disable notification for the messages.
2765
+ # Not supported in secret chats.
2766
+ # @param from_background [Boolean] Pass true if the messages are sent from the background.
2767
+ # @param input_message_contents [Array<TD::Types::InputMessageContent>] Contents of messages to be sent.
2768
+ # @return [TD::Types::Messages] the sent messages.
2769
+ def send_message_album(chat_id, input_message_contents,
2770
+ reply_to_message_id: 0, disable_notification: false, from_background: false)
2771
+ broadcast('@type' => 'sendMessageAlbum',
2772
+ 'chat_id' => chat_id,
2773
+ 'reply_to_message_id' => reply_to_message_id,
2774
+ 'disable_notification' => disable_notification,
2775
+ 'from_background' => from_background,
2776
+ 'input_message_contents' => input_message_contents)
2777
+ end
2778
+
2779
+ # Sends a Telegram Passport authorization form, effectively sharing data with the service.
2780
+ #
2781
+ # @param autorization_form_id [Integer] Authorization form identifier.
2782
+ # @param types [Array<TD::Types::PassportElementType>] Types of Telegram Passport elements chosen by user to complete
2783
+ # the authorization form.
2784
+ # @return [TD::Types::Ok]
2785
+ def send_passport_authorization_form(autorization_form_id, types)
2786
+ broadcast('@type' => 'sendPassportAuthorizationForm',
2787
+ 'autorization_form_id' => autorization_form_id,
2788
+ 'types' => types)
2789
+ end
2790
+
2791
+ # Sends a filled-out payment form to the bot for final verification.
2792
+ #
2793
+ # @param chat_id [Integer] Chat identifier of the Invoice message.
2794
+ # @param message_id [Integer] Message identifier.
2795
+ # @param order_info_id [String] Identifier returned by {#validate_order_info}, or an empty string.
2796
+ # @param shipping_option_id [String, nil] Identifier of a chosen shipping option, if applicable.
2797
+ # @param credentials [TD::Types::InputCredentials] The credentials chosen by user for payment.
2798
+ # @return [TD::Types::PaymentResult]
2799
+ def send_payment_form(chat_id, message_id, credentials, order_info_id: "", shipping_option_id: nil)
2800
+ broadcast('@type' => 'sendPaymentForm',
2801
+ 'chat_id' => chat_id,
2802
+ 'message_id' => message_id,
2803
+ 'order_info_id' => order_info_id,
2804
+ 'shipping_option_id' => shipping_option_id,
2805
+ 'credentials' => credentials)
2806
+ end
2807
+
2808
+ # Sends phone number confirmation code.
2809
+ # Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or
2810
+ # "tg://confirmphone?phone=*******&hash=**********" link.
2811
+ #
2812
+ # @param hash [String] Value of the "hash" parameter from the link.
2813
+ # @param phone_number [String] Value of the "phone" parameter from the link.
2814
+ # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified
2815
+ # phone number.
2816
+ # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device.
2817
+ # Ignored if allow_flash_call is false.
2818
+ # @return [TD::Types::AuthenticationCodeInfo]
2819
+ def send_phone_number_confirmation_code(hash, phone_number, allow_flash_call: false, is_current_phone_number: false)
2820
+ broadcast('@type' => 'sendPhoneNumberConfirmationCode',
2821
+ 'hash' => hash,
2822
+ 'phone_number' => phone_number,
2823
+ 'allow_flash_call' => allow_flash_call,
2824
+ 'is_current_phone_number' => is_current_phone_number)
2825
+ end
2826
+
2827
+ # Sends a code to verify a phone number to be added to a user's Telegram Passport.
2828
+ #
2829
+ # @param phone_number [String] The phone number of the user, in international format.
2830
+ # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified
2831
+ # phone number.
2832
+ # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device.
2833
+ # Ignored if allow_flash_call is false.
2834
+ # @return [TD::Types::AuthenticationCodeInfo]
2835
+ def send_phone_number_verification_code(phone_number, allow_flash_call: false, is_current_phone_number: false)
2836
+ broadcast('@type' => 'sendPhoneNumberVerificationCode',
2837
+ 'phone_number' => phone_number,
2838
+ 'allow_flash_call' => allow_flash_call,
2839
+ 'is_current_phone_number' => is_current_phone_number)
2840
+ end
2841
+
2842
+ # Changes the period of inactivity after which the account of the current user will automatically be deleted.
2843
+ #
2844
+ # @param ttl [TD::Types::AccountTtl] New account TTL.
2845
+ # @return [TD::Types::Ok]
2846
+ def set_account_ttl(ttl)
2847
+ broadcast('@type' => 'setAccountTtl',
2848
+ 'ttl' => ttl)
2849
+ end
2850
+
2851
+ # Succeeds after a specified amount of time has passed.
2852
+ # Can be called before authorization.
2853
+ # Can be called before initialization.
2854
+ #
2855
+ # @param seconds [Float] Number of seconds before the function returns.
2856
+ # @return [TD::Types::Ok]
2857
+ def set_alarm(seconds)
2858
+ broadcast('@type' => 'setAlarm',
2859
+ 'seconds' => seconds)
2860
+ end
2861
+
2862
+ # Sets the phone number of the user and sends an authentication code to the user.
2863
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitPhoneNumber}.
2864
+ #
2865
+ # @param phone_number [String] The phone number of the user, in international format.
2866
+ # @param allow_flash_call [Boolean] Pass true if the authentication code may be sent via flash call to the specified
2867
+ # phone number.
2868
+ # @param is_current_phone_number [Boolean] Pass true if the phone number is used on the current device.
2869
+ # Ignored if allow_flash_call is false.
2870
+ # @return [TD::Types::Ok]
2871
+ def set_authentication_phone_number(phone_number, allow_flash_call: false, is_current_phone_number: false)
2872
+ broadcast('@type' => 'setAuthenticationPhoneNumber',
2873
+ 'phone_number' => phone_number,
2874
+ 'allow_flash_call' => allow_flash_call,
2875
+ 'is_current_phone_number' => is_current_phone_number)
2876
+ end
2877
+
2878
+ # Changes the bio of the current user.
2879
+ #
2880
+ # @param bio [String] The new value of the user bio; 0-70 characters without line feeds.
2881
+ # @return [TD::Types::Ok]
2882
+ def set_bio(bio)
2883
+ broadcast('@type' => 'setBio',
2884
+ 'bio' => bio)
2885
+ end
2886
+
2887
+ # Informs the server about the number of pending bot updates if they haven't been processed for a long time; for bots
2888
+ # only.
2889
+ #
2890
+ # @param pending_update_count [Integer] The number of pending updates.
2891
+ # @param error_message [String] The last error message.
2892
+ # @return [TD::Types::Ok]
2893
+ def set_bot_updates_status(pending_update_count, error_message)
2894
+ broadcast('@type' => 'setBotUpdatesStatus',
2895
+ 'pending_update_count' => pending_update_count,
2896
+ 'error_message' => error_message)
2897
+ end
2898
+
2899
+ # Changes client data associated with a chat.
2900
+ #
2901
+ # @param chat_id [Integer] Chat identifier.
2902
+ # @param client_data [String] New value of client_data.
2903
+ # @return [TD::Types::Ok]
2904
+ def set_chat_client_data(chat_id, client_data)
2905
+ broadcast('@type' => 'setChatClientData',
2906
+ 'chat_id' => chat_id,
2907
+ 'client_data' => client_data)
2908
+ end
2909
+
2910
+ # Changes the draft message in a chat.
2911
+ #
2912
+ # @param chat_id [Integer] Chat identifier.
2913
+ # @param draft_message [TD::Types::DraftMessage, nil] New draft message.
2914
+ # @return [TD::Types::Ok]
2915
+ def set_chat_draft_message(chat_id, draft_message = nil)
2916
+ broadcast('@type' => 'setChatDraftMessage',
2917
+ 'chat_id' => chat_id,
2918
+ 'draft_message' => draft_message)
2919
+ end
2920
+
2921
+ # Changes the status of a chat member, needs appropriate privileges.
2922
+ # This function is currently not suitable for adding new members to the chat; instead, use {#add_chat_member}.
2923
+ # The chat member status will not be changed until it has been synchronized with the server.
2924
+ #
2925
+ # @param chat_id [Integer] Chat identifier.
2926
+ # @param user_id [Integer] User identifier.
2927
+ # @param status [TD::Types::ChatMemberStatus] The new status of the member in the chat.
2928
+ # @return [TD::Types::Ok]
2929
+ def set_chat_member_status(chat_id, user_id, status)
2930
+ broadcast('@type' => 'setChatMemberStatus',
2931
+ 'chat_id' => chat_id,
2932
+ 'user_id' => user_id,
2933
+ 'status' => status)
2934
+ end
2935
+
2936
+ # Changes the notification settings of a chat.
2937
+ #
2938
+ # @param chat_id [Integer] Chat identifier.
2939
+ # @param notification_settings [TD::Types::ChatNotificationSettings] New notification settings for the chat.
2940
+ # @return [TD::Types::Ok]
2941
+ def set_chat_notification_settings(chat_id, notification_settings)
2942
+ broadcast('@type' => 'setChatNotificationSettings',
2943
+ 'chat_id' => chat_id,
2944
+ 'notification_settings' => notification_settings)
2945
+ end
2946
+
2947
+ # Changes the photo of a chat.
2948
+ # Supported only for basic groups, supergroups and channels.
2949
+ # Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels.
2950
+ # The photo will not be changed before request to the server has been completed.
2951
+ #
2952
+ # @param chat_id [Integer] Chat identifier.
2953
+ # @param photo [TD::Types::InputFile] New chat photo.
2954
+ # You can use a zero {TD::Types::InputFile::Id} to delete the chat photo.
2955
+ # Files that are accessible only by HTTP URL are not acceptable.
2956
+ # @return [TD::Types::Ok]
2957
+ def set_chat_photo(chat_id, photo = InputFile::Id.new(id: 0))
2958
+ broadcast('@type' => 'setChatPhoto',
2959
+ 'chat_id' => chat_id,
2960
+ 'photo' => photo)
2961
+ end
2962
+
2963
+ # Changes the chat title.
2964
+ # Supported only for basic groups, supergroups and channels.
2965
+ # Requires administrator rights in basic groups and the appropriate administrator rights in supergroups and channels.
2966
+ # The title will not be changed until the request to the server has been completed.
2967
+ #
2968
+ # @param chat_id [Integer] Chat identifier.
2969
+ # @param title [String] New title of the chat; 1-255 characters.
2970
+ # @return [TD::Types::Ok]
2971
+ def set_chat_title(chat_id, title)
2972
+ broadcast('@type' => 'setChatTitle',
2973
+ 'chat_id' => chat_id,
2974
+ 'title' => title)
2975
+ end
2976
+
2977
+ # Adds or changes a custom language pack to the current localization target.
2978
+ #
2979
+ # @param info [TD::Types::LanguagePackInfo] Information about the language pack.
2980
+ # Language pack ID must start with 'X', consist only of English letters, digits and hyphens, and must not exceed 64
2981
+ # characters.
2982
+ # @param strings [Array<TD::Types::LanguagePackString>] Strings of the new language pack.
2983
+ # @return [TD::Types::Ok]
2984
+ def set_custom_language_pack(info, strings)
2985
+ broadcast('@type' => 'setCustomLanguagePack',
2986
+ 'info' => info,
2987
+ 'strings' => strings)
2988
+ end
2989
+
2990
+ # Adds, edits or deletes a string in a custom language pack.
2991
+ #
2992
+ # @param language_pack_id [String] Identifier of a previously added custom language pack in the current localization
2993
+ # target.
2994
+ # @param new_string [TD::Types::LanguagePackString] New language pack string.
2995
+ # @return [TD::Types::Ok]
2996
+ def set_custom_language_pack_string(language_pack_id, new_string)
2997
+ broadcast('@type' => 'setCustomLanguagePackString',
2998
+ 'language_pack_id' => language_pack_id,
2999
+ 'new_string' => new_string)
3000
+ end
3001
+
3002
+ # Changes the database encryption key.
3003
+ # Usually the encryption key is never changed and is stored in some OS keychain.
3004
+ #
3005
+ # @param new_encryption_key [String] New encryption key.
3006
+ # @return [TD::Types::Ok]
3007
+ def set_database_encryption_key(new_encryption_key)
3008
+ broadcast('@type' => 'setDatabaseEncryptionKey',
3009
+ 'new_encryption_key' => new_encryption_key)
3010
+ end
3011
+
3012
+ # The next part of a file was generated.
3013
+ #
3014
+ # @param generation_id [Integer] The identifier of the generation process.
3015
+ # @param expected_size [Integer] Expected size of the generated file, in bytes; 0 if unknown.
3016
+ # @param local_prefix_size [Integer] The number of bytes already generated.
3017
+ # @return [TD::Types::Ok]
3018
+ def set_file_generation_progress(generation_id, local_prefix_size, expected_size: 0)
3019
+ broadcast('@type' => 'setFileGenerationProgress',
3020
+ 'generation_id' => generation_id,
3021
+ 'expected_size' => expected_size,
3022
+ 'local_prefix_size' => local_prefix_size)
3023
+ end
3024
+
3025
+ # Updates the game score of the specified user in the game; for bots only.
3026
+ #
3027
+ # @param chat_id [Integer] The chat to which the message with the game.
3028
+ # @param message_id [Integer] Identifier of the message.
3029
+ # @param edit_message [Boolean] True, if the message should be edited.
3030
+ # @param user_id [Integer] User identifier.
3031
+ # @param score [Integer] The new score.
3032
+ # @param force [Boolean] Pass true to update the score even if it decreases.
3033
+ # If the score is 0, the user will be deleted from the high score table.
3034
+ # @return [TD::Types::Message]
3035
+ def set_game_score(chat_id, message_id, user_id, score, edit_message: false, force: false)
3036
+ broadcast('@type' => 'setGameScore',
3037
+ 'chat_id' => chat_id,
3038
+ 'message_id' => message_id,
3039
+ 'edit_message' => edit_message,
3040
+ 'user_id' => user_id,
3041
+ 'score' => score,
3042
+ 'force' => force)
3043
+ end
3044
+
3045
+ # Updates the game score of the specified user in a game; for bots only.
3046
+ #
3047
+ # @param inline_message_id [String] Inline message identifier.
3048
+ # @param edit_message [Boolean] True, if the message should be edited.
3049
+ # @param user_id [Integer] User identifier.
3050
+ # @param score [Integer] The new score.
3051
+ # @param force [Boolean] Pass true to update the score even if it decreases.
3052
+ # If the score is 0, the user will be deleted from the high score table.
3053
+ # @return [TD::Types::Ok]
3054
+ def set_inline_game_score(inline_message_id, user_id, score, edit_message: false, force: false)
3055
+ broadcast('@type' => 'setInlineGameScore',
3056
+ 'inline_message_id' => inline_message_id,
3057
+ 'edit_message' => edit_message,
3058
+ 'user_id' => user_id,
3059
+ 'score' => score,
3060
+ 'force' => force)
3061
+ end
3062
+
3063
+ # Changes the first and last name of the current user.
3064
+ # If something changes, {TD::Types::Update::User} will be sent.
3065
+ #
3066
+ # @param first_name [String] The new value of the first name for the user; 1-255 characters.
3067
+ # @param last_name [String] The new value of the optional last name for the user; 0-255 characters.
3068
+ # @return [TD::Types::Ok]
3069
+ def set_name(first_name, last_name)
3070
+ broadcast('@type' => 'setName',
3071
+ 'first_name' => first_name,
3072
+ 'last_name' => last_name)
3073
+ end
3074
+
3075
+ # Sets the current network type.
3076
+ # Can be called before authorization.
3077
+ # Calling this method forces all network connections to reopen, mitigating the delay in switching between different
3078
+ # networks, so it should be called whenever the network is changed, even if the network type remains the same.
3079
+ # Network type is used to check whether the library can use the network at all and also for collecting detailed
3080
+ # network data usage statistics.
3081
+ #
3082
+ # @param type [TD::Types::NetworkType] The new network type.
3083
+ # By default, {TD::Types::NetworkType::Other}.
3084
+ # @return [TD::Types::Ok]
3085
+ def set_network_type(type = NetworkType::Other)
3086
+ broadcast('@type' => 'setNetworkType',
3087
+ 'type' => type)
3088
+ end
3089
+
3090
+ # Sets the value of an option.
3091
+ # Only writable options can be set.
3092
+ # Can be called before authorization.
3093
+ #
3094
+ # @param name [String] The name of the option.
3095
+ # @param value [TD::Types::OptionValue] The new value of the option.
3096
+ # @see https://core.telegram.org/tdlib/options List of available options
3097
+ # @return [TD::Types::Ok]
3098
+ def set_option(name, value)
3099
+ broadcast('@type' => 'setOption',
3100
+ 'name' => name,
3101
+ 'value' => value)
3102
+ end
3103
+
3104
+ # Adds an element to the user's Telegram Passport.
3105
+ # May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the chosen phone
3106
+ # number or the chosen email address must be verified first.
3107
+ #
3108
+ # @param element [TD::Types::InputPassportElement] Input Telegram Passport element.
3109
+ # @param password [String] Password of the current user.
3110
+ # @return [TD::Types::PassportElement]
3111
+ def set_passport_element(element, password)
3112
+ broadcast('@type' => 'setPassportElement',
3113
+ 'element' => element,
3114
+ 'password' => password)
3115
+ end
3116
+
3117
+ # Informs the user that some of the elements in their Telegram Passport contain errors; for bots only.
3118
+ # The user will not be able to resend the elements, until the errors are fixed.
3119
+ #
3120
+ # @param user_id [Integer] User identifier.
3121
+ # @param errors [Array<TD::Types::InputPassportElementError>] The errors.
3122
+ # @return [TD::Types::Ok]
3123
+ def set_passport_element_errors(user_id, errors)
3124
+ broadcast('@type' => 'setPassportElementErrors',
3125
+ 'user_id' => user_id,
3126
+ 'errors' => errors)
3127
+ end
3128
+
3129
+ # Changes the password for the user.
3130
+ # If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the password change
3131
+ # will not be applied until the new recovery email address has been confirmed.
3132
+ # The application should periodically call {#get_password_state} to check whether the new email address has been
3133
+ # confirmed.
3134
+ #
3135
+ # @param old_password [String] Previous password of the user.
3136
+ # @param new_password [String, nil] New password of the user; may be empty to remove the password.
3137
+ # @param new_hint [String, nil] New password hint.
3138
+ # @param set_recovery_email_address [Boolean] Pass true if the recovery email address should be changed.
3139
+ # @param new_recovery_email_address [String, nil] New recovery email address.
3140
+ # @return [TD::Types::PasswordState]
3141
+ def set_password(old_password, new_password: nil, new_hint: nil, set_recovery_email_address: false,
3142
+ new_recovery_email_address: nil)
3143
+ broadcast('@type' => 'setPassword',
3144
+ 'old_password' => old_password,
3145
+ 'new_password' => new_password,
3146
+ 'new_hint' => new_hint,
3147
+ 'set_recovery_email_address' => set_recovery_email_address,
3148
+ 'new_recovery_email_address' => new_recovery_email_address)
3149
+ end
3150
+
3151
+ # Changes the order of pinned chats.
3152
+ #
3153
+ # @param chat_ids [Array<Integer>] The new list of pinned chats.
3154
+ # @return [TD::Types::Ok]
3155
+ def set_pinned_chats(chat_ids)
3156
+ broadcast('@type' => 'setPinnedChats',
3157
+ 'chat_ids' => chat_ids)
3158
+ end
3159
+
3160
+ # Uploads a new profile photo for the current user.
3161
+ # If something changes, {TD::Types::Update::User} will be sent.
3162
+ #
3163
+ # @param photo [TD::Types::InputFile] Profile photo to set.
3164
+ # {TD::Types::InputFile::Id} and {TD::Types::InputFile::Remote} may still be unsupported.
3165
+ # @return [TD::Types::Ok]
3166
+ def set_profile_photo(photo)
3167
+ broadcast('@type' => 'setProfilePhoto',
3168
+ 'photo' => photo)
3169
+ end
3170
+
3171
+ # Changes the recovery email address of the user.
3172
+ # If a new recovery email address is specified, then the error EMAIL_UNCONFIRMED is returned and the email address
3173
+ # will not be changed until the new email has been confirmed.
3174
+ # The application should periodically call {#get_password_state} to check whether the email address has been
3175
+ # confirmed.
3176
+ # If new_recovery_email_address is the same as the email address that is currently set up, this call succeeds
3177
+ # immediately and aborts all other requests waiting for an email confirmation.
3178
+ #
3179
+ # @param password [String] Password of the current user.
3180
+ # @param new_recovery_email_address [String] New recovery email address.
3181
+ # @return [TD::Types::PasswordState]
3182
+ def set_recovery_email_address(new_recovery_email_address, password)
3183
+ broadcast('@type' => 'setRecoveryEmailAddress',
3184
+ 'password' => password,
3185
+ 'new_recovery_email_address' => new_recovery_email_address)
3186
+ end
3187
+
3188
+ # Changes notification settings for chats of a given type.
3189
+ #
3190
+ # @param scope [TD::Types::NotificationSettingsScope] Types of chats for which to change the notification settings.
3191
+ # @param notification_settings [TD::Types::ScopeNotificationSettings] The new notification settings for the given
3192
+ # scope.
3193
+ # @return [TD::Types::Ok]
3194
+ def set_scope_notification_settings(scope, notification_settings)
3195
+ broadcast('@type' => 'setScopeNotificationSettings',
3196
+ 'scope' => scope,
3197
+ 'notification_settings' => notification_settings)
3198
+ end
3199
+
3200
+ # Changes the position of a sticker in the set to which it belongs; for bots only.
3201
+ # The sticker set must have been created by the bot.
3202
+ #
3203
+ # @param sticker [TD::Types::InputFile] Sticker.
3204
+ # @param position [Integer] New position of the sticker in the set, zero-based.
3205
+ # @return [TD::Types::Ok]
3206
+ def set_sticker_position_in_set(sticker, position)
3207
+ broadcast('@type' => 'setStickerPositionInSet',
3208
+ 'sticker' => sticker,
3209
+ 'position' => position)
3210
+ end
3211
+
3212
+ # Changes information about a supergroup or channel; requires appropriate administrator rights.
3213
+ #
3214
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
3215
+ # @param description [String] New supergroup or channel description; 0-255 characters.
3216
+ # @return [TD::Types::Ok]
3217
+ def set_supergroup_description(supergroup_id, description)
3218
+ broadcast('@type' => 'setSupergroupDescription',
3219
+ 'supergroup_id' => supergroup_id,
3220
+ 'description' => description)
3221
+ end
3222
+
3223
+ # Changes the sticker set of a supergroup; requires appropriate rights in the supergroup.
3224
+ #
3225
+ # @param supergroup_id [Integer] Identifier of the supergroup.
3226
+ # @param sticker_set_id [Integer] New value of the supergroup sticker set identifier.
3227
+ # Use 0 to remove the supergroup sticker set.
3228
+ # @return [TD::Types::Ok]
3229
+ def set_supergroup_sticker_set(supergroup_id, sticker_set_id = 0)
3230
+ broadcast('@type' => 'setSupergroupStickerSet',
3231
+ 'supergroup_id' => supergroup_id,
3232
+ 'sticker_set_id' => sticker_set_id)
3233
+ end
3234
+
3235
+ # Changes the username of a supergroup or channel, requires creator privileges in the supergroup or channel.
3236
+ #
3237
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
3238
+ # @param username [String] New value of the username.
3239
+ # Use an empty string to remove the username.
3240
+ # @return [TD::Types::Ok]
3241
+ def set_supergroup_username(supergroup_id, username = "")
3242
+ broadcast('@type' => 'setSupergroupUsername',
3243
+ 'supergroup_id' => supergroup_id,
3244
+ 'username' => username)
3245
+ end
3246
+
3247
+ # Sets the parameters for TDLib initialization.
3248
+ # Works only when the current authorization state is {TD::Types::AuthorizationState::WaitTdlibParameters}.
3249
+ #
3250
+ # @param parameters [TD::Types::TdlibParameters] Parameters.
3251
+ # @return [TD::Types::Ok]
3252
+ def set_tdlib_parameters(parameters)
3253
+ broadcast('@type' => 'setTdlibParameters',
3254
+ 'parameters' => parameters)
3255
+ end
3256
+
3257
+ # Changes user privacy settings.
3258
+ #
3259
+ # @param setting [TD::Types::UserPrivacySetting] The privacy setting.
3260
+ # @param rules [TD::Types::UserPrivacySettingRules] The new privacy rules.
3261
+ # @return [TD::Types::Ok]
3262
+ def set_user_privacy_setting_rules(setting, rules)
3263
+ broadcast('@type' => 'setUserPrivacySettingRules',
3264
+ 'setting' => setting,
3265
+ 'rules' => rules)
3266
+ end
3267
+
3268
+ # Changes the username of the current user.
3269
+ # If something changes, {TD::Types::Update::User} will be sent.
3270
+ #
3271
+ # @param username [String] The new value of the username.
3272
+ # Use an empty string to remove the username.
3273
+ # @return [TD::Types::Ok]
3274
+ def set_username(username = "")
3275
+ broadcast('@type' => 'setUsername',
3276
+ 'username' => username)
3277
+ end
3278
+
3279
+ # Terminates all other sessions of the current user.
3280
+ #
3281
+ # @return [TD::Types::Ok]
3282
+ def terminate_all_other_sessions
3283
+ broadcast('@type' => 'terminateAllOtherSessions')
3284
+ end
3285
+
3286
+ # Terminates a session of the current user.
3287
+ #
3288
+ # @param session_id [Integer] Session identifier.
3289
+ # @return [TD::Types::Ok]
3290
+ def terminate_session(session_id)
3291
+ broadcast('@type' => 'terminateSession',
3292
+ 'session_id' => session_id)
3293
+ end
3294
+
3295
+ # Toggles the "All members are admins" setting in basic groups; requires creator privileges in the group.
3296
+ #
3297
+ # @param basic_group_id [Integer] Identifier of the basic group.
3298
+ # @param everyone_is_administrator [Boolean] New value of everyone_is_administrator.
3299
+ # @return [TD::Types::Ok]
3300
+ def toggle_basic_group_administrators(basic_group_id, everyone_is_administrator)
3301
+ broadcast('@type' => 'toggleBasicGroupAdministrators',
3302
+ 'basic_group_id' => basic_group_id,
3303
+ 'everyone_is_administrator' => everyone_is_administrator)
3304
+ end
3305
+
3306
+ # Changes the value of the default disable_notification parameter, used when a message is sent to a chat.
3307
+ #
3308
+ # @param chat_id [Integer] Chat identifier.
3309
+ # @param default_disable_notification [Boolean] New value of default_disable_notification.
3310
+ # @return [TD::Types::Ok]
3311
+ def toggle_chat_default_disable_notification(chat_id, default_disable_notification)
3312
+ broadcast('@type' => 'toggleChatDefaultDisableNotification',
3313
+ 'chat_id' => chat_id,
3314
+ 'default_disable_notification' => default_disable_notification)
3315
+ end
3316
+
3317
+ # Changes the marked as unread state of a chat.
3318
+ #
3319
+ # @param chat_id [Integer] Chat identifier.
3320
+ # @param is_marked_as_unread [Boolean] New value of is_marked_as_unread.
3321
+ # @return [TD::Types::Ok]
3322
+ def toggle_chat_is_marked_as_unread(chat_id, is_marked_as_unread)
3323
+ broadcast('@type' => 'toggleChatIsMarkedAsUnread',
3324
+ 'chat_id' => chat_id,
3325
+ 'is_marked_as_unread' => is_marked_as_unread)
3326
+ end
3327
+
3328
+ # Changes the pinned state of a chat.
3329
+ # You can pin up to GetOption("pinned_chat_count_max") non-secret chats and the same number of secret chats.
3330
+ #
3331
+ # @param chat_id [Integer] Chat identifier.
3332
+ # @param is_pinned [Boolean] New value of is_pinned.
3333
+ # @return [TD::Types::Ok]
3334
+ def toggle_chat_is_pinned(chat_id, is_pinned)
3335
+ broadcast('@type' => 'toggleChatIsPinned',
3336
+ 'chat_id' => chat_id,
3337
+ 'is_pinned' => is_pinned)
3338
+ end
3339
+
3340
+ # Toggles whether all members of a supergroup can add new members; requires appropriate administrator rights in the
3341
+ # supergroup.
3342
+ #
3343
+ # @param supergroup_id [Integer] Identifier of the supergroup.
3344
+ # @param anyone_can_invite [Boolean] New value of anyone_can_invite.
3345
+ # @return [TD::Types::Ok]
3346
+ def toggle_supergroup_invites(supergroup_id, anyone_can_invite)
3347
+ broadcast('@type' => 'toggleSupergroupInvites',
3348
+ 'supergroup_id' => supergroup_id,
3349
+ 'anyone_can_invite' => anyone_can_invite)
3350
+ end
3351
+
3352
+ # Toggles whether the message history of a supergroup is available to new members; requires appropriate administrator
3353
+ # rights in the supergroup.
3354
+ #
3355
+ # @param supergroup_id [Integer] The identifier of the supergroup.
3356
+ # @param is_all_history_available [Boolean] The new value of is_all_history_available.
3357
+ # @return [TD::Types::Ok]
3358
+ def toggle_supergroup_is_all_history_available(supergroup_id, is_all_history_available)
3359
+ broadcast('@type' => 'toggleSupergroupIsAllHistoryAvailable',
3360
+ 'supergroup_id' => supergroup_id,
3361
+ 'is_all_history_available' => is_all_history_available)
3362
+ end
3363
+
3364
+ # Toggles sender signatures messages sent in a channel; requires appropriate administrator rights in the channel.
3365
+ #
3366
+ # @param supergroup_id [Integer] Identifier of the channel.
3367
+ # @param sign_messages [Boolean] New value of sign_messages.
3368
+ # @return [TD::Types::Ok]
3369
+ def toggle_supergroup_sign_messages(supergroup_id, sign_messages)
3370
+ broadcast('@type' => 'toggleSupergroupSignMessages',
3371
+ 'supergroup_id' => supergroup_id,
3372
+ 'sign_messages' => sign_messages)
3373
+ end
3374
+
3375
+ # Removes a user from the blacklist.
3376
+ #
3377
+ # @param user_id [Integer] User identifier.
3378
+ # @return [TD::Types::Ok]
3379
+ def unblock_user(user_id)
3380
+ broadcast('@type' => 'unblockUser',
3381
+ 'user_id' => user_id)
3382
+ end
3383
+
3384
+ # Removes the pinned message from a supergroup or channel; requires appropriate administrator rights in the
3385
+ # supergroup or channel.
3386
+ #
3387
+ # @param supergroup_id [Integer] Identifier of the supergroup or channel.
3388
+ # @return [TD::Types::Ok]
3389
+ def unpin_supergroup_message(supergroup_id)
3390
+ broadcast('@type' => 'unpinSupergroupMessage',
3391
+ 'supergroup_id' => supergroup_id)
3392
+ end
3393
+
3394
+ # Creates a new supergroup from an existing basic group and sends a corresponding
3395
+ # {TD::Types::MessageContent::UpgradeTo} and {TD::Types::MessageContent::ChatUpgradeFrom}.
3396
+ # Deactivates the original basic group.
3397
+ #
3398
+ # @param chat_id [Integer] Identifier of the chat to upgrade.
3399
+ # @return [TD::Types::Chat]
3400
+ def upgrade_basic_group_chat_to_supergroup_chat(chat_id)
3401
+ broadcast('@type' => 'upgradeBasicGroupChatToSupergroupChat',
3402
+ 'chat_id' => chat_id)
3403
+ end
3404
+
3405
+ # Asynchronously uploads a file to the cloud without sending it in a message.
3406
+ # {TD::Types::Update::File} will be used to notify about upload progress and successful completion of the upload.
3407
+ # The file will not have a persistent remote identifier until it will be sent in a message.
3408
+ #
3409
+ # @param file [TD::Types::InputFile] File to upload.
3410
+ # @param file_type [TD::Types::FileType] File type.
3411
+ # @param priority [Integer] Priority of the upload (1-32).
3412
+ # The higher the priority, the earlier the file will be uploaded.
3413
+ # If the priorities of two files are equal, then the first one for which {#upload_file} was called will be uploaded
3414
+ # first.
3415
+ # @return [TD::Types::File]
3416
+ def upload_file(file, file_type, priority = 1)
3417
+ broadcast('@type' => 'uploadFile',
3418
+ 'file' => file,
3419
+ 'file_type' => file_type,
3420
+ 'priority' => priority)
3421
+ end
3422
+
3423
+ # Uploads a PNG image with a sticker; for bots only
3424
+ #
3425
+ # @param user_id [Integer] Sticker file owner.
3426
+ # @param png_sticker [TD::Types::InputFile] PNG image with the sticker; must be up to 512 kB in size and fit in
3427
+ # 512x512 square.
3428
+ # @return [TD::Types::File] the uploaded file.
3429
+ def upload_sticker_file(user_id, png_sticker)
3430
+ broadcast('@type' => 'uploadStickerFile',
3431
+ 'user_id' => user_id,
3432
+ 'png_sticker' => png_sticker)
3433
+ end
3434
+
3435
+ # Validates the order information provided by a user and returns the available shipping options for a flexible
3436
+ # invoice.
3437
+ #
3438
+ # @param chat_id [Integer] Chat identifier of the Invoice message.
3439
+ # @param message_id [Integer] Message identifier.
3440
+ # @param order_info [TD::Types::OrderInfo] The order information, provided by the user.
3441
+ # @param allow_save [Boolean] True, if the order information can be saved.
3442
+ # @return [TD::Types::ValidatedOrderInfo]
3443
+ def validate_order_info(chat_id, message_id, order_info, allow_save: false)
3444
+ broadcast('@type' => 'validateOrderInfo',
3445
+ 'chat_id' => chat_id,
3446
+ 'message_id' => message_id,
3447
+ 'order_info' => order_info,
3448
+ 'allow_save' => allow_save)
3449
+ end
3450
+
3451
+ # This method should be called if messages are being viewed by the user.
3452
+ # Many useful activities depend on whether the messages are currently being viewed or not (e.g., marking messages as
3453
+ # read, incrementing a view counter, updating a view counter, removing deleted messages in supergroups and channels).
3454
+ #
3455
+ # @param chat_id [Integer] Chat identifier.
3456
+ # @param message_ids [Array<Integer>] The identifiers of the messages being viewed.
3457
+ # @param force_read [Boolean] True, if messages in closed chats should be marked as read.
3458
+ # @return [TD::Types::Ok]
3459
+ def view_messages(chat_id, message_ids, force_read: false)
3460
+ broadcast('@type' => 'viewMessages',
3461
+ 'chat_id' => chat_id,
3462
+ 'message_ids' => message_ids,
3463
+ 'force_read' => force_read)
3464
+ end
3465
+
3466
+ # Informs the server that some trending sticker sets have been viewed by the user.
3467
+ #
3468
+ # @param sticker_set_ids [Array<Integer>] Identifiers of viewed trending sticker sets.
3469
+ # @return [TD::Types::Ok]
3470
+ def view_trending_sticker_sets(sticker_set_ids)
3471
+ broadcast('@type' => 'viewTrendingStickerSets',
3472
+ 'sticker_set_ids' => sticker_set_ids)
3473
+ end
3474
+ end