From e30662f1ea5d75638a4bf1327596496aeb87e456 Mon Sep 17 00:00:00 2001 From: Chris Watson Date: Sat, 24 Aug 2024 01:14:11 +0000 Subject: [PATCH] bot api update --- src/tourmaline/client/api.cr | 131 +++++++++++++++++++++++------------ src/tourmaline/types/api.cr | 13 ++-- 2 files changed, 90 insertions(+), 54 deletions(-) diff --git a/src/tourmaline/client/api.cr b/src/tourmaline/client/api.cr index 19bf0c4d6..c0a9a8ad0 100644 --- a/src/tourmaline/client/api.cr +++ b/src/tourmaline/client/api.cr @@ -149,23 +149,25 @@ module Tourmaline caption : String | ::Nil = nil, parse_mode : ParseMode = default_parse_mode, caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil, + show_caption_above_media : Bool | ::Nil = nil, disable_notification : Bool | ::Nil = nil, protect_content : Bool | ::Nil = nil, reply_parameters : Tourmaline::ReplyParameters | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | Tourmaline::ReplyKeyboardMarkup | Tourmaline::ReplyKeyboardRemove | Tourmaline::ForceReply | ::Nil = nil ) request(Tourmaline::MessageId, "copyMessage", { - chat_id: chat_id, - from_chat_id: from_chat_id, - message_id: message_id, - message_thread_id: message_thread_id, - caption: caption, - parse_mode: parse_mode, - caption_entities: caption_entities.try(&.to_json), - disable_notification: disable_notification, - protect_content: protect_content, - reply_parameters: reply_parameters, - reply_markup: reply_markup.try(&.to_json), + chat_id: chat_id, + from_chat_id: from_chat_id, + message_id: message_id, + message_thread_id: message_thread_id, + caption: caption, + parse_mode: parse_mode, + caption_entities: caption_entities.try(&.to_json), + show_caption_above_media: show_caption_above_media, + disable_notification: disable_notification, + protect_content: protect_content, + reply_parameters: reply_parameters, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1434,9 +1436,10 @@ module Tourmaline }) end - # Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit text and game messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_text( text : String, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1446,19 +1449,21 @@ module Tourmaline reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageText", { - text: text, - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - parse_mode: parse_mode, - entities: entities.try(&.to_json), - link_preview_options: link_preview_options, - reply_markup: reply_markup.try(&.to_json), + text: text, + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + parse_mode: parse_mode, + entities: entities.try(&.to_json), + link_preview_options: link_preview_options, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit captions of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_caption( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1469,30 +1474,34 @@ module Tourmaline reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageCaption", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - caption: caption, - parse_mode: parse_mode, - caption_entities: caption_entities.try(&.to_json), - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + caption: caption, + parse_mode: parse_mode, + caption_entities: caption_entities.try(&.to_json), + show_caption_above_media: show_caption_above_media, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit animation, audio, document, photo, or video messages. If a message is part of a message album, then it can be edited only to an audio for audio albums, only to a document for document albums and to a photo or a video otherwise. When an inline message is edited, a new file can't be uploaded; use a previously uploaded file via its file_id or specify a URL. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_media( media : Tourmaline::InputMedia, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageMedia", { - media: media.to_json, - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + media: media.to_json, + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1500,6 +1509,7 @@ module Tourmaline def edit_message_live_location( latitude : Float64, longitude : Float64, + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, @@ -1512,6 +1522,7 @@ module Tourmaline request(Tourmaline::Message | Bool, "editMessageLiveLocation", { latitude: latitude, longitude: longitude, + business_connection_id: business_connection_id, chat_id: chat_id, message_id: message_id, inline_message_id: inline_message_id, @@ -1525,31 +1536,35 @@ module Tourmaline # Use this method to stop updating a live location message before live_period expires. On success, if the message is not an inline message, the edited Message is returned, otherwise True is returned. def stop_message_live_location( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "stopMessageLiveLocation", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end - # Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. + # Use this method to edit only the reply markup of messages. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned. Note that business messages that were not sent by the bot and do not contain an inline keyboard can only be edited within 48 hours from the time they were sent. def edit_message_reply_markup( + business_connection_id : String | ::Nil = nil, chat_id : Int32 | Int64 | String | ::Nil = nil, message_id : Int32 | Int64 | ::Nil = nil, inline_message_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Message | Bool, "editMessageReplyMarkup", { - chat_id: chat_id, - message_id: message_id, - inline_message_id: inline_message_id, - reply_markup: reply_markup.try(&.to_json), + business_connection_id: business_connection_id, + chat_id: chat_id, + message_id: message_id, + inline_message_id: inline_message_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1557,12 +1572,14 @@ module Tourmaline def stop_poll( chat_id : Int32 | Int64 | String, message_id : Int32 | Int64, + business_connection_id : String | ::Nil = nil, reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil ) request(Tourmaline::Poll, "stopPoll", { - chat_id: chat_id, - message_id: message_id, - reply_markup: reply_markup.try(&.to_json), + chat_id: chat_id, + message_id: message_id, + business_connection_id: business_connection_id, + reply_markup: reply_markup.try(&.to_json), }) end @@ -1970,6 +1987,28 @@ module Tourmaline }) end + # Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object. + def get_star_transactions( + offset : Int32 | Int64 | ::Nil = nil, + limit : Int32 | Int64 | ::Nil = nil + ) + request(Tourmaline::StarTransactions, "getStarTransactions", { + offset: offset, + limit: limit, + }) + end + + # Refunds a successful payment in Telegram Stars. Returns True on success. + def refund_star_payment( + user_id : Int32 | Int64, + telegram_payment_charge_id : String + ) + request(Bool, "refundStarPayment", { + user_id: user_id, + telegram_payment_charge_id: telegram_payment_charge_id, + }) + end + # Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. # Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. def set_passport_data_errors( diff --git a/src/tourmaline/types/api.cr b/src/tourmaline/types/api.cr index 7758a8980..f683d4b85 100644 --- a/src/tourmaline/types/api.cr +++ b/src/tourmaline/types/api.cr @@ -26,7 +26,7 @@ module Tourmaline # Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot property business_connection : Tourmaline::BusinessConnection | ::Nil - # Optional. New non-service message from a connected business account + # Optional. New message from a connected business account property business_message : Tourmaline::Message | ::Nil # Optional. New version of a message from a connected business account @@ -333,7 +333,7 @@ module Tourmaline # Optional. True, if users need to join the supergroup before they can send messages property? join_to_send_messages : Bool | ::Nil - # Optional. True, if all users directly joining the supergroup need to be approved by supergroup administrators + # Optional. True, if all users directly joining the supergroup without using an invite link need to be approved by supergroup administrators property? join_by_request : Bool | ::Nil # Optional. Description, for groups, supergroups and channel chats @@ -1686,9 +1686,6 @@ module Tourmaline # Longitude as defined by the sender property longitude : Float64 - # Latitude as defined by sender - property latitude : Float64 - # Optional. The radius of uncertainty for the location, measured in meters; 0-1500 property horizontal_accuracy : Float64 | ::Nil @@ -1702,8 +1699,8 @@ module Tourmaline property proximity_alert_radius : Int32 | Int64 | ::Nil def initialize( - @longitude, @latitude, + @longitude, @horizontal_accuracy : Float64 | ::Nil = nil, @live_period : Int32 | Int64 | ::Nil = nil, @heading : Int32 | Int64 | ::Nil = nil, @@ -2618,7 +2615,7 @@ module Tourmaline # Optional. HTTP or tg:// URL to be opened when the button is pressed. Links tg://user?id= can be used to mention a user by their identifier without using a username, if this is allowed by their privacy settings. property url : String | ::Nil - # Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. Not supported for messages sent on behalf of a Telegram Business account. + # Optional. Data to be sent in a callback query to the bot when the button is pressed, 1-64 bytes property callback_data : String | ::Nil # Optional. Description of the Web App that will be launched when the user presses the button. The Web App will be able to send an arbitrary message on behalf of the user using the method answerWebAppQuery. Available only in private chats between a user and the bot. Not supported for messages sent on behalf of a Telegram Business account. @@ -2933,7 +2930,7 @@ module Tourmaline # Optional. Chat invite link, which was used by the user to join the chat; for joining by invite link events only. property invite_link : Tourmaline::ChatInviteLink | ::Nil - # Optional. True, if the user joined the chat after sending a direct join request and being approved by an administrator + # Optional. True, if the user joined the chat after sending a direct join request without using an invite link and being approved by an administrator property? via_join_request : Bool | ::Nil # Optional. True, if the user joined the chat via a chat folder invite link