Skip to content

Commit 983966d

Browse files
committed
bot api update
1 parent d3b4984 commit 983966d

File tree

2 files changed

+1140
-51
lines changed

2 files changed

+1140
-51
lines changed

src/tourmaline/client/api.cr

Lines changed: 106 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ module Tourmaline
2020
})
2121
end
2222

23-
# Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.
23+
# Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the request and give up after a reasonable amount of attempts. Returns True on success.
2424
# If you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the request will contain a header "X-Telegram-Bot-Api-Secret-Token" with the secret token as content.
2525
def set_webhook(
2626
url : String,
@@ -165,6 +165,7 @@ module Tourmaline
165165
caption : String | ::Nil = nil,
166166
parse_mode : ParseMode = default_parse_mode,
167167
caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil,
168+
show_caption_above_media : Bool | ::Nil = nil,
168169
disable_notification : Bool | ::Nil = nil,
169170
protect_content : Bool | ::Nil = nil,
170171
allow_paid_broadcast : Bool | ::Nil = nil,
@@ -354,6 +355,8 @@ module Tourmaline
354355
width : Int32 | Int64 | ::Nil = nil,
355356
height : Int32 | Int64 | ::Nil = nil,
356357
thumbnail : ::File | String | ::Nil = nil,
358+
cover : ::File | String | ::Nil = nil,
359+
start_timestamp : Int32 | Int64 | ::Nil = nil,
357360
caption : String | ::Nil = nil,
358361
parse_mode : ParseMode = default_parse_mode,
359362
caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil,
@@ -765,6 +768,29 @@ module Tourmaline
765768
})
766769
end
767770

771+
# Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.
772+
def send_checklist(
773+
business_connection_id : String,
774+
chat_id : Int32 | Int64,
775+
checklist : Tourmaline::InputChecklist,
776+
disable_notification : Bool | ::Nil = nil,
777+
protect_content : Bool | ::Nil = nil,
778+
message_effect_id : String | ::Nil = nil,
779+
reply_parameters : Tourmaline::ReplyParameters | ::Nil = nil,
780+
reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil
781+
)
782+
request(Tourmaline::Message, "sendChecklist", {
783+
business_connection_id: business_connection_id,
784+
chat_id: chat_id,
785+
checklist: checklist.to_json,
786+
disable_notification: disable_notification,
787+
protect_content: protect_content,
788+
message_effect_id: message_effect_id,
789+
reply_parameters: reply_parameters.try(&.to_json),
790+
reply_markup: reply_markup.try(&.to_json),
791+
})
792+
end
793+
768794
# Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
769795
def send_dice(
770796
chat_id : Int32 | Int64 | String,
@@ -812,7 +838,7 @@ module Tourmaline
812838
})
813839
end
814840

815-
# Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Returns True on success.
841+
# Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. Bots can't use paid reactions. Returns True on success.
816842
def set_message_reaction(
817843
chat_id : Int32 | Int64 | String,
818844
message_id : Int32 | Int64,
@@ -840,6 +866,19 @@ module Tourmaline
840866
})
841867
end
842868

869+
# Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the Mini App method requestEmojiStatusAccess. Returns True on success.
870+
def set_user_emoji_status(
871+
user_id : Int32 | Int64,
872+
emoji_status_custom_emoji_id : String | ::Nil = nil,
873+
emoji_status_expiration_date : Int32 | Int64 | ::Nil = nil
874+
)
875+
request(Bool, "setUserEmojiStatus", {
876+
user_id: user_id,
877+
emoji_status_custom_emoji_id: emoji_status_custom_emoji_id,
878+
emoji_status_expiration_date: emoji_status_expiration_date,
879+
})
880+
end
881+
843882
# Use this method to get basic information about a file and prepare it for downloading. For the moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile again.
844883
# Note: This function may not preserve the original file name and MIME type. You should save the file's MIME type and name (if available) when the File object is received.
845884
def get_file(
@@ -2332,6 +2371,25 @@ module Tourmaline
23322371
})
23332372
end
23342373

2374+
# Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
2375+
def save_prepared_inline_message(
2376+
user_id : Int32 | Int64,
2377+
result : Tourmaline::InlineQueryResult,
2378+
allow_user_chats : Bool | ::Nil = nil,
2379+
allow_bot_chats : Bool | ::Nil = nil,
2380+
allow_group_chats : Bool | ::Nil = nil,
2381+
allow_channel_chats : Bool | ::Nil = nil
2382+
)
2383+
request(Tourmaline::PreparedInlineMessage, "savePreparedInlineMessage", {
2384+
user_id: user_id,
2385+
result: result.to_json,
2386+
allow_user_chats: allow_user_chats,
2387+
allow_bot_chats: allow_bot_chats,
2388+
allow_group_chats: allow_group_chats,
2389+
allow_channel_chats: allow_channel_chats,
2390+
})
2391+
end
2392+
23352393
# Use this method to send invoices. On success, the sent Message is returned.
23362394
def send_invoice(
23372395
chat_id : Int32 | Int64 | String,
@@ -2408,6 +2466,9 @@ module Tourmaline
24082466
payload : String,
24092467
currency : String,
24102468
prices : Array(Tourmaline::LabeledPrice),
2469+
business_connection_id : String | ::Nil = nil,
2470+
provider_token : String | ::Nil = nil,
2471+
subscription_period : Int32 | Int64 | ::Nil = nil,
24112472
max_tip_amount : Int32 | Int64 | ::Nil = nil,
24122473
suggested_tip_amounts : Array(Int32 | Int64) | ::Nil = nil,
24132474
provider_data : String | ::Nil = nil,
@@ -2429,6 +2490,9 @@ module Tourmaline
24292490
payload: payload,
24302491
currency: currency,
24312492
prices: prices.to_json,
2493+
business_connection_id: business_connection_id,
2494+
provider_token: provider_token,
2495+
subscription_period: subscription_period,
24322496
max_tip_amount: max_tip_amount,
24332497
suggested_tip_amounts: suggested_tip_amounts.try(&.to_json),
24342498
provider_data: provider_data.try(&.to_json),
@@ -2474,6 +2538,46 @@ module Tourmaline
24742538
})
24752539
end
24762540

2541+
# A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
2542+
def get_my_star_balance
2543+
request(Tourmaline::StarAmount, "getMyStarBalance")
2544+
end
2545+
2546+
# Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
2547+
def get_star_transactions(
2548+
offset : Int32 | Int64 | ::Nil = nil,
2549+
limit : Int32 | Int64 | ::Nil = nil
2550+
)
2551+
request(Tourmaline::StarTransactions, "getStarTransactions", {
2552+
offset: offset,
2553+
limit: limit,
2554+
})
2555+
end
2556+
2557+
# Refunds a successful payment in Telegram Stars. Returns True on success.
2558+
def refund_star_payment(
2559+
user_id : Int32 | Int64,
2560+
telegram_payment_charge_id : String
2561+
)
2562+
request(Bool, "refundStarPayment", {
2563+
user_id: user_id,
2564+
telegram_payment_charge_id: telegram_payment_charge_id,
2565+
})
2566+
end
2567+
2568+
# Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
2569+
def edit_user_star_subscription(
2570+
user_id : Int32 | Int64,
2571+
telegram_payment_charge_id : String,
2572+
is_canceled : Bool
2573+
)
2574+
request(Bool, "editUserStarSubscription", {
2575+
user_id: user_id,
2576+
telegram_payment_charge_id: telegram_payment_charge_id,
2577+
is_canceled: is_canceled,
2578+
})
2579+
end
2580+
24772581
# 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.
24782582
# 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.
24792583
def set_passport_data_errors(

0 commit comments

Comments
 (0)