Skip to content

Commit

Permalink
issue-157: Review/Implement Bot API 7.4 Changes
Browse files Browse the repository at this point in the history
- Updated fns for the telegram bot api 7.4 release.
- Bumped project version.
- Generated pom.
  • Loading branch information
wdhowe committed Jun 2, 2024
1 parent aaf0518 commit e84b590
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 34 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>telegrambot-lib</groupId>
<artifactId>telegrambot-lib</artifactId>
<packaging>jar</packaging>
<version>2.14.0</version>
<version>2.15.0</version>
<name>telegrambot-lib</name>
<description>A library for interacting with the Telegram Bot API.</description>
<url>https://github.com/wdhowe/telegrambot-lib</url>
Expand All @@ -18,7 +18,7 @@
<url>https://github.com/wdhowe/telegrambot-lib</url>
<connection>scm:git:git://github.com/wdhowe/telegrambot-lib.git</connection>
<developerConnection>scm:git:ssh://[email protected]/wdhowe/telegrambot-lib.git</developerConnection>
<tag>e47f5e254d0449d65863bb3e21ad00d80728674a</tag>
<tag>aaf0518d942f99c768b94bf6e582506b7c3dd6da</tag>
</scm>
<build>
<sourceDirectory>src</sourceDirectory>
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject telegrambot-lib "2.14.0"
(defproject telegrambot-lib "2.15.0"

;;; Project Metadata
:description "A library for interacting with the Telegram Bot API."
Expand Down
3 changes: 2 additions & 1 deletion src/telegrambot_lib/api/edit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
Optional
- parse_mode ; entity parsing in message
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- show_caption_above_media ; True, to show caption above the message media.
- reply_markup ; inline keyboard markup"
{:changed "0.2.0"}
{:changed "2.15.0"}

([this content]
(http/request this "editMessageCaption" content))
Expand Down
3 changes: 2 additions & 1 deletion src/telegrambot_lib/api/games.clj
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@
- message_thread_id ; id of the target thread of the forum.
- disable_notification ; send message silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; inline keyboard markup"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendGame" content))
Expand Down
48 changes: 33 additions & 15 deletions src/telegrambot_lib/api/methods.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@
- link_preview_options ; link preview generation options.
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendMessage" content))
Expand Down Expand Up @@ -183,11 +184,12 @@
- caption ; new caption for media
- parse_mode ; entity parsing
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- show_caption_above_media ; True, to show caption above the message media.
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.12.0"}
{:changed "2.15.0"}

([this content]
(http/request this "copyMessage" content))
Expand Down Expand Up @@ -258,12 +260,14 @@
- caption ; photo caption
- parse_mode ; entity parsing in photo caption
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- show_caption_above_media ; True, to show caption above the message media.
- has_spoiler ; true if photo needs to be covered with spoiler animation.
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendPhoto" content))
Expand Down Expand Up @@ -302,9 +306,10 @@
- thumbnail ; thumbnail of the file sent
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendAudio" content))
Expand Down Expand Up @@ -339,9 +344,10 @@
- disable_content_type_detection ; disable auto content type detection for files uploaded
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendDocument" content))
Expand Down Expand Up @@ -376,14 +382,16 @@
- caption ; video caption
- parse_mode ; entity parsing in video caption
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- show_caption_above_media ; True, to show caption above the message media.
- has_spoiler ; true if video needs to be covered with spoiler animation.
- thumbnail ; thumbnail of file sent
- supports_streaming ; true if uploaded video is ok for streaming
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendVideo" content))
Expand Down Expand Up @@ -418,13 +426,15 @@
- caption ; animation caption
- parse_mode ; entity parsing in animation caption
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- show_caption_above_media ; True, to show caption above the message media.
- has_spoiler ; true if animation needs to be covered with spoiler animation.
- thumbnail ; thumbnail of file sent
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendAnimation" content))
Expand Down Expand Up @@ -461,9 +471,10 @@
- caption_entities ; list of MessageEntity - can use instead of parse_mode
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendVoice" content))
Expand Down Expand Up @@ -496,9 +507,10 @@
- thumbnail ; thumbnail of the file sent
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendVideoNote" content))
Expand Down Expand Up @@ -528,8 +540,9 @@
- message_thread_id ; id of the target thread of the forum.
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendMediaGroup" content))
Expand Down Expand Up @@ -564,9 +577,10 @@
- proximity_alert_radius ; 1-100000 meters max distance for proximity alerts
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendLocation" content))
Expand Down Expand Up @@ -736,9 +750,10 @@
- google_place_type ; Google Places type of venue
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendVenue" content))
Expand Down Expand Up @@ -777,9 +792,10 @@
- vcard ; 'vCard' formatted additional data
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendContact" content))
Expand Down Expand Up @@ -832,9 +848,10 @@
- is_closed ; true if poll needs to be immediately closed
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.14.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendPoll" content))
Expand Down Expand Up @@ -866,9 +883,10 @@
- emoji ; image for dice animation (default: dice)
- disable_notification ; send silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}
content-map?)

(defmethod send-dice true
Expand Down
39 changes: 27 additions & 12 deletions src/telegrambot_lib/api/payments.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
- title ; product name
- description ; product description
- payload ; internal bot defined invoice payload
- provider_token ; payments provider token
- currency ; three letter ISO 4217 currency code
- prices ; 'LabeledPrice' array breakdown (price, tax, discount, delivery, etc)
Optional
- provider_token ; payments provider token, omit for Telegram Stars payments.
- message_thread_id ; id of the target thread of the forum.
- max_tip_amount ; integer of max tip accepted. US $1.45 = 145.
- suggested_tip_amounts ; json serialized array of integer tip amounts, 4 max suggested tips,
Expand All @@ -44,32 +44,31 @@
- is_flexible ; true if final price depends on shipping method
- disable_notification ; send message silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; inline keyboard markup"
{:changed "2.12.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendInvoice" content))

([this chat_id title description payload provider_token
([this chat_id title description payload
currency prices]
(let [content {:chat_id chat_id
:title title
:description description
:payload payload
:provider_token provider_token
:currency currency
:prices prices}]
(send-invoice this content)))

([this chat_id title description payload provider_token
([this chat_id title description payload
currency prices & optional]
(let [content (merge (first optional)
{:chat_id chat_id
:title title
:description description
:payload payload
:provider_token provider_token
:currency currency
:prices prices})]
(send-invoice this content))))
Expand All @@ -82,11 +81,11 @@
- title ; product name
- description ; product description
- payload ; internal bot defined invoice payload
- provider_token ; payments provider token
- currency ; three letter ISO 4217 currency code
- prices ; 'LabeledPrice' array breakdown (price, tax, discount, delivery, etc)
Optional
- provider_token ; payments provider token, omit for Telegram Stars payments.
- max_tip_amount ; integer of max tip accepted. US $1.45 = 145.
- suggested_tip_amounts ; json serialized array of integer tip amounts, 4 max suggested tips,
positive numbers, increasing order, and must not exceed max_tip_amount.
Expand All @@ -102,26 +101,24 @@
- send_phone_number_to_provider ; true to send phone number to provider
- send_email_to_provider ; true to send email to provider
- is_flexible ; true if final price depends on shipping method"
{:added "2.1.0"}
{:changed "2.15.0"}

([this content]
(http/request this "createInvoiceLink" content))

([this title description payload provider_token currency prices]
([this title description payload currency prices]
(let [content {:title title
:description description
:payload payload
:provider_token provider_token
:currency currency
:prices prices}]
(create-invoice-link this content)))

([this title description payload provider_token currency prices & optional]
([this title description payload currency prices & optional]
(let [content (merge (first optional)
{:title title
:description description
:payload payload
:provider_token provider_token
:currency currency
:prices prices})]
(create-invoice-link this content))))
Expand Down Expand Up @@ -224,3 +221,21 @@
:ok false
:error_message error_message}]
(answer-precheckout-query-error this content))))

(defn refund-star-payment
"Refunds a successful payment in Telegram Stars.
Returns True on success.
Required
- this ; a bot instance
- user_id ; ID of the user whose payment will be refunded.
- telegram_payment_charge_id ; Telegram payment identifier."
{:added "2.15.0"}

([this content]
(http/request this "refundStarPayment" content))

([this user_id telegram_payment_charge_id]
(let [content {:user_id user_id
:telegram_payment_charge_id telegram_payment_charge_id}]
(refund-star-payment this content))))
3 changes: 2 additions & 1 deletion src/telegrambot_lib/api/stickers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
- emoji ; Emoji associated with the recently uploaded sticker.
- disable_notification ; true to send message silently
- protect_content ; protect content from forwarding/saving
- message_effect_id ; ID of the message effect to be added to the message.
- reply_parameters ; Description of the message to reply to
- reply_markup ; additional interface options"
{:changed "2.13.0"}
{:changed "2.15.0"}

([this content]
(http/request this "sendSticker" content))
Expand Down
3 changes: 2 additions & 1 deletion src/telegrambot_lib/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@
answer-shipping-query-ok
answer-shipping-query-error
answer-precheckout-query-ok
answer-precheckout-query-error]
answer-precheckout-query-error
refund-star-payment]
[stickers
send-sticker
get-sticker-set
Expand Down

0 comments on commit e84b590

Please sign in to comment.