Skip to content

Commit 366b7f4

Browse files
committed
Telegram Bot API November 17, 2024 updates (v8.0)
1 parent 29dcf8b commit 366b7f4

17 files changed

+428
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# F[Tg] - Telegramium
22

3-
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-7.11%20(October%2031%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
3+
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-8.0%20(October%2031%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
44
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_3/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.apimorphism/telegramium-core_3)
55

66

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
enablePlugins(GitPlugin)
22

33
ThisBuild / version := Version.mkVersion(
4-
"9.711.0",
4+
"9.800.0",
55
git.gitCurrentBranch.value,
66
git.gitDescribedVersion.value,
77
git.gitUncommittedChanges.value
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package telegramium.bots
2+
3+
/** This object represents a gift that can be sent by the bot.
4+
*
5+
* @param id
6+
* Unique identifier of the gift
7+
* @param sticker
8+
* The sticker that represents the gift
9+
* @param starCount
10+
* The number of Telegram Stars that must be paid to send the sticker
11+
* @param totalCount
12+
* Optional. The total number of the gifts of this type that can be sent; for limited gifts only
13+
* @param remainingCount
14+
* Optional. The number of remaining gifts of this type that can be sent; for limited gifts only
15+
*/
16+
final case class Gift(
17+
id: String,
18+
sticker: Sticker,
19+
starCount: Int,
20+
totalCount: Option[Int] = Option.empty,
21+
remainingCount: Option[Int] = Option.empty
22+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package telegramium.bots
2+
3+
/** This object represent a list of gifts.
4+
*
5+
* @param gifts
6+
* The list of gifts
7+
*/
8+
final case class Gifts(gifts: List[Gift] = List.empty)

telegramium-core/src/main/scala/telegramium/bots/InputPollOption.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ package telegramium.bots
1313
*/
1414
final case class InputPollOption(
1515
text: String,
16-
textParseMode: Option[String] = Option.empty,
16+
textParseMode: Option[ParseMode] = Option.empty,
1717
textEntities: List[iozhik.OpenEnum[MessageEntity]] = List.empty
1818
)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package telegramium.bots
2+
3+
/** Describes an inline message to be sent by a user of a Mini App.
4+
*
5+
* @param id
6+
* Unique identifier of the prepared message
7+
* @param expirationDate
8+
* Expiration date of the prepared message, in Unix time. Expired prepared messages can no longer be used
9+
*/
10+
final case class PreparedInlineMessage(id: String, expirationDate: Int)

telegramium-core/src/main/scala/telegramium/bots/SuccessfulPayment.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ package telegramium.bots
1414
* Telegram payment identifier
1515
* @param providerPaymentChargeId
1616
* Provider payment identifier
17+
* @param subscriptionExpirationDate
18+
* Optional. Expiration date of the subscription, in Unix time; for recurring payments only
19+
* @param isRecurring
20+
* Optional. True, if the payment is a recurring payment for a subscription
21+
* @param isFirstRecurring
22+
* Optional. True, if the payment is the first payment for a subscription
1723
* @param shippingOptionId
1824
* Optional. Identifier of the shipping option chosen by the user
1925
* @param orderInfo
@@ -25,6 +31,9 @@ final case class SuccessfulPayment(
2531
invoicePayload: String,
2632
telegramPaymentChargeId: String,
2733
providerPaymentChargeId: String,
34+
subscriptionExpirationDate: Option[Int] = Option.empty,
35+
isRecurring: Option[Boolean] = Option.empty,
36+
isFirstRecurring: Option[Boolean] = Option.empty,
2837
shippingOptionId: Option[String] = Option.empty,
2938
orderInfo: Option[OrderInfo] = Option.empty
3039
)

telegramium-core/src/main/scala/telegramium/bots/TransactionPartner.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,22 @@ case object TransactionPartnerTelegramAds extends TransactionPartner
1414
* Information about the user
1515
* @param invoicePayload
1616
* Optional. Bot-specified invoice payload
17+
* @param subscriptionPeriod
18+
* Optional. The duration of the paid subscription
1719
* @param paidMedia
1820
* Optional. Information about the paid media bought by the user
1921
* @param paidMediaPayload
2022
* Optional. Bot-specified paid media payload
23+
* @param gift
24+
* Optional. The gift sent to the user by the bot
2125
*/
2226
final case class TransactionPartnerUser(
2327
user: User,
2428
invoicePayload: Option[String] = Option.empty,
29+
subscriptionPeriod: Option[Int] = Option.empty,
2530
paidMedia: List[iozhik.OpenEnum[PaidMedia]] = List.empty,
26-
paidMediaPayload: Option[String] = Option.empty
31+
paidMediaPayload: Option[String] = Option.empty,
32+
gift: Option[Gift] = Option.empty
2733
) extends TransactionPartner
2834

2935
/** Describes a transaction with payment for paid broadcasting.

telegramium-core/src/main/scala/telegramium/bots/client/CreateInvoiceLinkReq.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ import telegramium.bots.LabeledPrice
1111
* processes.
1212
* @param currency
1313
* Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
14+
* @param businessConnectionId
15+
* Unique identifier of the business connection on behalf of which the link will be created. For payments in Telegram
16+
* Stars only.
1417
* @param providerToken
1518
* Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
1619
* @param prices
1720
* Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost, delivery
1821
* tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
22+
* @param subscriptionPeriod
23+
* The number of seconds the subscription will be active for before the next payment. The currency must be set to
24+
* “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified. Any
25+
* number of subscriptions can be active for a given bot at the same time, including multiple concurrent
26+
* subscriptions from the same user.
1927
* @param maxTipAmount
2028
* The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For
2129
* example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it
@@ -57,8 +65,10 @@ final case class CreateInvoiceLinkReq(
5765
description: String,
5866
payload: String,
5967
currency: String,
68+
businessConnectionId: Option[String] = Option.empty,
6069
providerToken: Option[String] = Option.empty,
6170
prices: List[LabeledPrice] = List.empty,
71+
subscriptionPeriod: Option[Int] = Option.empty,
6272
maxTipAmount: Option[Int] = Option.empty,
6373
suggestedTipAmounts: List[Int] = List.empty,
6474
providerData: Option[String] = Option.empty,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package telegramium.bots.client
2+
3+
/** @param userId
4+
* Identifier of the user whose subscription will be edited
5+
* @param telegramPaymentChargeId
6+
* Telegram payment identifier for the subscription
7+
* @param isCanceled
8+
* Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the
9+
* current subscription period. Pass False to allow the user to re-enable a subscription that was previously canceled
10+
* by the bot.
11+
*/
12+
final case class EditUserStarSubscriptionReq(userId: Long, telegramPaymentChargeId: String, isCanceled: Boolean)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package telegramium.bots.client
2+
3+
case object GetAvailableGiftsReq

telegramium-core/src/main/scala/telegramium/bots/client/Methods.scala

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import telegramium.bots.MessageId
99
import telegramium.bots.ChatInviteLink
1010
import telegramium.bots.ForumTopic
1111
import telegramium.bots.Message
12+
import telegramium.bots.Gifts
1213
import telegramium.bots.BusinessConnection
1314
import telegramium.bots.ChatFullInfo
1415
import telegramium.bots.ChatMember
@@ -28,6 +29,7 @@ import telegramium.bots.Update
2829
import telegramium.bots.UserChatBoosts
2930
import telegramium.bots.UserProfilePhotos
3031
import telegramium.bots.WebhookInfo
32+
import telegramium.bots.PreparedInlineMessage
3133
import telegramium.bots.Poll
3234

3335
trait Methods {
@@ -479,11 +481,19 @@ trait Methods {
479481
* processes.
480482
* @param currency
481483
* Three-letter ISO 4217 currency code, see more on currencies. Pass “XTR” for payments in Telegram Stars.
484+
* @param businessConnectionId
485+
* Unique identifier of the business connection on behalf of which the link will be created. For payments in
486+
* Telegram Stars only.
482487
* @param providerToken
483488
* Payment provider token, obtained via @BotFather. Pass an empty string for payments in Telegram Stars.
484489
* @param prices
485490
* Price breakdown, a JSON-serialized list of components (e.g. product price, tax, discount, delivery cost,
486491
* delivery tax, bonus, etc.). Must contain exactly one item for payments in Telegram Stars.
492+
* @param subscriptionPeriod
493+
* The number of seconds the subscription will be active for before the next payment. The currency must be set to
494+
* “XTR” (Telegram Stars) if the parameter is used. Currently, it must always be 2592000 (30 days) if specified.
495+
* Any number of subscriptions can be active for a given bot at the same time, including multiple concurrent
496+
* subscriptions from the same user.
487497
* @param maxTipAmount
488498
* The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double). For
489499
* example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145. See the exp parameter in currencies.json, it
@@ -525,8 +535,10 @@ trait Methods {
525535
description: String,
526536
payload: String,
527537
currency: String,
538+
businessConnectionId: Option[String] = Option.empty,
528539
providerToken: Option[String] = Option.empty,
529540
prices: List[LabeledPrice] = List.empty,
541+
subscriptionPeriod: Option[Int] = Option.empty,
530542
maxTipAmount: Option[Int] = Option.empty,
531543
suggestedTipAmounts: List[Int] = List.empty,
532544
providerData: Option[String] = Option.empty,
@@ -547,8 +559,10 @@ trait Methods {
547559
description,
548560
payload,
549561
currency,
562+
businessConnectionId,
550563
providerToken,
551564
prices,
565+
subscriptionPeriod,
552566
maxTipAmount,
553567
suggestedTipAmounts,
554568
providerData,
@@ -1049,6 +1063,22 @@ trait Methods {
10491063
MethodReq[Either[Boolean, Message]]("editMessageText", req.asJson)
10501064
}
10511065

1066+
/** Allows the bot to cancel or re-enable extension of a subscription paid in Telegram Stars. Returns True on success.
1067+
*
1068+
* @param userId
1069+
* Identifier of the user whose subscription will be edited
1070+
* @param telegramPaymentChargeId
1071+
* Telegram payment identifier for the subscription
1072+
* @param isCanceled
1073+
* Pass True to cancel extension of the user subscription; the subscription must be active up to the end of the
1074+
* current subscription period. Pass False to allow the user to re-enable a subscription that was previously
1075+
* canceled by the bot.
1076+
*/
1077+
def editUserStarSubscription(userId: Long, telegramPaymentChargeId: String, isCanceled: Boolean): Method[Boolean] = {
1078+
val req = EditUserStarSubscriptionReq(userId, telegramPaymentChargeId, isCanceled)
1079+
MethodReq[Boolean]("editUserStarSubscription", req.asJson)
1080+
}
1081+
10521082
/** Use this method to generate a new primary invite link for a chat; any previously generated primary link is
10531083
* revoked. The bot must be an administrator in the chat for this to work and must have the appropriate administrator
10541084
* rights. Returns the new invite link as String on success.
@@ -1121,6 +1151,13 @@ trait Methods {
11211151
MethodReq[List[MessageId]]("forwardMessages", req.asJson)
11221152
}
11231153

1154+
/** Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
1155+
*/
1156+
def getAvailableGifts(): Method[Gifts] = {
1157+
val req = GetAvailableGiftsReq
1158+
MethodReq[Gifts]("getAvailableGifts", req.asJson)
1159+
}
1160+
11241161
/** Use this method to get information about the connection of the bot with a business account. Returns a
11251162
* BusinessConnection object on success.
11261163
*
@@ -1654,6 +1691,34 @@ trait Methods {
16541691
MethodReq[ChatInviteLink]("revokeChatInviteLink", req.asJson)
16551692
}
16561693

1694+
/** Stores a message that can be sent by a user of a Mini App. Returns a PreparedInlineMessage object.
1695+
*
1696+
* @param userId
1697+
* Unique identifier of the target user that can use the prepared message
1698+
* @param result
1699+
* A JSON-serialized object describing the message to be sent
1700+
* @param allowUserChats
1701+
* Pass True if the message can be sent to private chats with users
1702+
* @param allowBotChats
1703+
* Pass True if the message can be sent to private chats with bots
1704+
* @param allowGroupChats
1705+
* Pass True if the message can be sent to group and supergroup chats
1706+
* @param allowChannelChats
1707+
* Pass True if the message can be sent to channel chats
1708+
*/
1709+
def savePreparedInlineMessage(
1710+
userId: Long,
1711+
result: InlineQueryResult,
1712+
allowUserChats: Option[Boolean] = Option.empty,
1713+
allowBotChats: Option[Boolean] = Option.empty,
1714+
allowGroupChats: Option[Boolean] = Option.empty,
1715+
allowChannelChats: Option[Boolean] = Option.empty
1716+
): Method[PreparedInlineMessage] = {
1717+
val req =
1718+
SavePreparedInlineMessageReq(userId, result, allowUserChats, allowBotChats, allowGroupChats, allowChannelChats)
1719+
MethodReq[PreparedInlineMessage]("savePreparedInlineMessage", req.asJson)
1720+
}
1721+
16571722
/** Use this method to send animation files (GIF or H.264/MPEG-4 AVC video without sound). On success, the sent
16581723
* Message is returned. Bots can currently send animation files of up to 50 MB in size, this limit may be changed in
16591724
* the future.
@@ -2133,6 +2198,34 @@ trait Methods {
21332198
MethodReq[Message]("sendGame", req.asJson)
21342199
}
21352200

2201+
/** Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on
2202+
* success.
2203+
*
2204+
* @param userId
2205+
* Unique identifier of the target user that will receive the gift
2206+
* @param giftId
2207+
* Identifier of the gift
2208+
* @param text
2209+
* Text that will be shown along with the gift; 0-255 characters
2210+
* @param textParseMode
2211+
* Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”,
2212+
* “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
2213+
* @param textEntities
2214+
* A JSON-serialized list of special entities that appear in the gift text. It can be specified instead of
2215+
* text_parse_mode. Entities other than “bold”, “italic”, “underline”, “strikethrough”, “spoiler”, and
2216+
* “custom_emoji” are ignored.
2217+
*/
2218+
def sendGift(
2219+
userId: Long,
2220+
giftId: String,
2221+
text: Option[String] = Option.empty,
2222+
textParseMode: Option[ParseMode] = Option.empty,
2223+
textEntities: List[MessageEntity] = List.empty
2224+
): Method[Boolean] = {
2225+
val req = SendGiftReq(userId, giftId, text, textParseMode, textEntities)
2226+
MethodReq[Boolean]("sendGift", req.asJson)
2227+
}
2228+
21362229
/** Use this method to send invoices. On success, the sent Message is returned.
21372230
*
21382231
* @param chatId
@@ -3510,6 +3603,25 @@ trait Methods {
35103603
MethodReq[Boolean]("setStickerSetTitle", req.asJson)
35113604
}
35123605

3606+
/** Changes the emoji status for a given user that previously allowed the bot to manage their emoji status via the
3607+
* Mini App method requestEmojiStatusAccess. Returns True on success.
3608+
*
3609+
* @param userId
3610+
* Unique identifier of the target user
3611+
* @param emojiStatusCustomEmojiId
3612+
* Custom emoji identifier of the emoji status to set. Pass an empty string to remove the status.
3613+
* @param emojiStatusExpirationDate
3614+
* Expiration date of the emoji status, if any
3615+
*/
3616+
def setUserEmojiStatus(
3617+
userId: Long,
3618+
emojiStatusCustomEmojiId: Option[String] = Option.empty,
3619+
emojiStatusExpirationDate: Option[Int] = Option.empty
3620+
): Method[Boolean] = {
3621+
val req = SetUserEmojiStatusReq(userId, emojiStatusCustomEmojiId, emojiStatusExpirationDate)
3622+
MethodReq[Boolean]("setUserEmojiStatus", req.asJson)
3623+
}
3624+
35133625
/** Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update
35143626
* for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case
35153627
* of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. If
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package telegramium.bots.client
2+
3+
import telegramium.bots.InlineQueryResult
4+
5+
/** @param userId
6+
* Unique identifier of the target user that can use the prepared message
7+
* @param result
8+
* A JSON-serialized object describing the message to be sent
9+
* @param allowUserChats
10+
* Pass True if the message can be sent to private chats with users
11+
* @param allowBotChats
12+
* Pass True if the message can be sent to private chats with bots
13+
* @param allowGroupChats
14+
* Pass True if the message can be sent to group and supergroup chats
15+
* @param allowChannelChats
16+
* Pass True if the message can be sent to channel chats
17+
*/
18+
final case class SavePreparedInlineMessageReq(
19+
userId: Long,
20+
result: InlineQueryResult,
21+
allowUserChats: Option[Boolean] = Option.empty,
22+
allowBotChats: Option[Boolean] = Option.empty,
23+
allowGroupChats: Option[Boolean] = Option.empty,
24+
allowChannelChats: Option[Boolean] = Option.empty
25+
)

0 commit comments

Comments
 (0)