Skip to content

Commit 642f424

Browse files
authored
bot api update
1 parent 730e4af commit 642f424

File tree

2 files changed

+1277
-114
lines changed

2 files changed

+1277
-114
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,
@@ -151,6 +151,7 @@ module Tourmaline
151151
caption : String | ::Nil = nil,
152152
parse_mode : ParseMode = default_parse_mode,
153153
caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil,
154+
show_caption_above_media : Bool | ::Nil = nil,
154155
disable_notification : Bool | ::Nil = nil,
155156
protect_content : Bool | ::Nil = nil,
156157
allow_paid_broadcast : Bool | ::Nil = nil,
@@ -319,6 +320,8 @@ module Tourmaline
319320
width : Int32 | Int64 | ::Nil = nil,
320321
height : Int32 | Int64 | ::Nil = nil,
321322
thumbnail : ::File | String | ::Nil = nil,
323+
cover : ::File | String | ::Nil = nil,
324+
start_timestamp : Int32 | Int64 | ::Nil = nil,
322325
caption : String | ::Nil = nil,
323326
parse_mode : ParseMode = default_parse_mode,
324327
caption_entities : Array(Tourmaline::MessageEntity) | ::Nil = nil,
@@ -655,6 +658,29 @@ module Tourmaline
655658
})
656659
end
657660

661+
# Use this method to send a checklist on behalf of a connected business account. On success, the sent Message is returned.
662+
def send_checklist(
663+
business_connection_id : String,
664+
chat_id : Int32 | Int64,
665+
checklist : Tourmaline::InputChecklist,
666+
disable_notification : Bool | ::Nil = nil,
667+
protect_content : Bool | ::Nil = nil,
668+
message_effect_id : String | ::Nil = nil,
669+
reply_parameters : Tourmaline::ReplyParameters | ::Nil = nil,
670+
reply_markup : Tourmaline::InlineKeyboardMarkup | ::Nil = nil
671+
)
672+
request(Tourmaline::Message, "sendChecklist", {
673+
business_connection_id: business_connection_id,
674+
chat_id: chat_id,
675+
checklist: checklist.to_json,
676+
disable_notification: disable_notification,
677+
protect_content: protect_content,
678+
message_effect_id: message_effect_id,
679+
reply_parameters: reply_parameters.try(&.to_json),
680+
reply_markup: reply_markup.try(&.to_json),
681+
})
682+
end
683+
658684
# Use this method to send an animated emoji that will display a random value. On success, the sent Message is returned.
659685
def send_dice(
660686
chat_id : Int32 | Int64 | String,
@@ -698,7 +724,7 @@ module Tourmaline
698724
})
699725
end
700726

701-
# 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.
727+
# 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.
702728
def set_message_reaction(
703729
chat_id : Int32 | Int64 | String,
704730
message_id : Int32 | Int64,
@@ -726,6 +752,19 @@ module Tourmaline
726752
})
727753
end
728754

755+
# 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.
756+
def set_user_emoji_status(
757+
user_id : Int32 | Int64,
758+
emoji_status_custom_emoji_id : String | ::Nil = nil,
759+
emoji_status_expiration_date : Int32 | Int64 | ::Nil = nil
760+
)
761+
request(Bool, "setUserEmojiStatus", {
762+
user_id: user_id,
763+
emoji_status_custom_emoji_id: emoji_status_custom_emoji_id,
764+
emoji_status_expiration_date: emoji_status_expiration_date,
765+
})
766+
end
767+
729768
# 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.
730769
# 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.
731770
def get_file(
@@ -1829,6 +1868,25 @@ module Tourmaline
18291868
})
18301869
end
18311870

1871+
# Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
1872+
def save_prepared_inline_message(
1873+
user_id : Int32 | Int64,
1874+
result : Tourmaline::InlineQueryResult,
1875+
allow_user_chats : Bool | ::Nil = nil,
1876+
allow_bot_chats : Bool | ::Nil = nil,
1877+
allow_group_chats : Bool | ::Nil = nil,
1878+
allow_channel_chats : Bool | ::Nil = nil
1879+
)
1880+
request(Tourmaline::PreparedInlineMessage, "savePreparedInlineMessage", {
1881+
user_id: user_id,
1882+
result: result.to_json,
1883+
allow_user_chats: allow_user_chats,
1884+
allow_bot_chats: allow_bot_chats,
1885+
allow_group_chats: allow_group_chats,
1886+
allow_channel_chats: allow_channel_chats,
1887+
})
1888+
end
1889+
18321890
# Use this method to send invoices. On success, the sent Message is returned.
18331891
def send_invoice(
18341892
chat_id : Int32 | Int64 | String,
@@ -1901,6 +1959,9 @@ module Tourmaline
19011959
payload : String,
19021960
currency : String,
19031961
prices : Array(Tourmaline::LabeledPrice),
1962+
business_connection_id : String | ::Nil = nil,
1963+
provider_token : String | ::Nil = nil,
1964+
subscription_period : Int32 | Int64 | ::Nil = nil,
19041965
max_tip_amount : Int32 | Int64 | ::Nil = nil,
19051966
suggested_tip_amounts : Array(Int32 | Int64) | ::Nil = nil,
19061967
provider_data : String | ::Nil = nil,
@@ -1922,6 +1983,9 @@ module Tourmaline
19221983
payload: payload,
19231984
currency: currency,
19241985
prices: prices.to_json,
1986+
business_connection_id: business_connection_id,
1987+
provider_token: provider_token,
1988+
subscription_period: subscription_period,
19251989
max_tip_amount: max_tip_amount,
19261990
suggested_tip_amounts: suggested_tip_amounts.try(&.to_json),
19271991
provider_data: provider_data.try(&.to_json),
@@ -1967,6 +2031,46 @@ module Tourmaline
19672031
})
19682032
end
19692033

2034+
# A method to get the current Telegram Stars balance of the bot. Requires no parameters. On success, returns a StarAmount object.
2035+
def get_my_star_balance
2036+
request(Tourmaline::StarAmount, "getMyStarBalance")
2037+
end
2038+
2039+
# Returns the bot's Telegram Star transactions in chronological order. On success, returns a StarTransactions object.
2040+
def get_star_transactions(
2041+
offset : Int32 | Int64 | ::Nil = nil,
2042+
limit : Int32 | Int64 | ::Nil = nil
2043+
)
2044+
request(Tourmaline::StarTransactions, "getStarTransactions", {
2045+
offset: offset,
2046+
limit: limit,
2047+
})
2048+
end
2049+
2050+
# Refunds a successful payment in Telegram Stars. Returns True on success.
2051+
def refund_star_payment(
2052+
user_id : Int32 | Int64,
2053+
telegram_payment_charge_id : String
2054+
)
2055+
request(Bool, "refundStarPayment", {
2056+
user_id: user_id,
2057+
telegram_payment_charge_id: telegram_payment_charge_id,
2058+
})
2059+
end
2060+
2061+
# Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
2062+
def edit_user_star_subscription(
2063+
user_id : Int32 | Int64,
2064+
telegram_payment_charge_id : String,
2065+
is_canceled : Bool
2066+
)
2067+
request(Bool, "editUserStarSubscription", {
2068+
user_id: user_id,
2069+
telegram_payment_charge_id: telegram_payment_charge_id,
2070+
is_canceled: is_canceled,
2071+
})
2072+
end
2073+
19702074
# 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.
19712075
# 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.
19722076
def set_passport_data_errors(

0 commit comments

Comments
 (0)