Skip to content

Commit

Permalink
bot api update
Browse files Browse the repository at this point in the history
  • Loading branch information
watzon committed Sep 15, 2024
1 parent 919fc4e commit 6ec039b
Show file tree
Hide file tree
Showing 2 changed files with 350 additions and 60 deletions.
164 changes: 118 additions & 46 deletions src/tourmaline/client/api.cr
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,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

Expand Down Expand Up @@ -430,6 +432,39 @@ module Tourmaline
})
end

# Use this method to send paid media. On success, the sent Message is returned.
def send_paid_media(
chat_id : Int32 | Int64 | String,
star_count : Int32 | Int64,
media : Array(Tourmaline::InputPaidMedia),
business_connection_id : String | ::Nil = nil,
payload : String | ::Nil = nil,
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::Message, "sendPaidMedia", {
chat_id: chat_id,
star_count: star_count,
media: media.to_json,
business_connection_id: business_connection_id,
payload: payload,
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

# Use this method to send a group of photos, videos, documents or audios as an album. Documents and audio files can be only grouped in an album with messages of the same type. On success, an array of Messages that were sent is returned.
def send_media_group(
chat_id : Int32 | Int64 | String,
Expand Down Expand Up @@ -1337,9 +1372,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,
Expand All @@ -1349,19 +1385,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,
Expand All @@ -1371,37 +1409,42 @@ 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

# Use this method to edit live location messages. A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the edited message is not an inline message, the edited Message is returned, otherwise True is returned.
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,
Expand All @@ -1414,6 +1457,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,
Expand All @@ -1427,44 +1471,50 @@ 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

# Use this method to stop a poll which was sent by the bot. On success, the stopped Poll is returned.
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

Expand Down Expand Up @@ -1868,6 +1918,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(
Expand Down
Loading

0 comments on commit 6ec039b

Please sign in to comment.