Skip to content

Commit 791ae80

Browse files
committed
Telegram Bot API February 12, 2025 updates (v8.3)
1 parent 50e6da4 commit 791ae80

17 files changed

+198
-63
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-8.2%20(January%201%2C%202025)-blue)](https://core.telegram.org/bots/api#recent-changes)
3+
[![Telegram](https://img.shields.io/badge/Telegram%20Bot%20API-8.3%20(February%2012%2C%202025)-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.802.0",
4+
"9.803.0",
55
git.gitCurrentBranch.value,
66
git.gitDescribedVersion.value,
77
git.gitUncommittedChanges.value

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ package telegramium.bots
7272
* Optional. The most recent pinned message (by sending date)
7373
* @param permissions
7474
* Optional. Default chat member permissions, for groups and supergroups
75+
* @param canSendGift
76+
* Optional. True, if gifts can be sent to the chat
7577
* @param canSendPaidMedia
7678
* Optional. True, if paid media messages can be sent or forwarded to the channel chat. The field is available only
7779
* for channel chats.
@@ -139,6 +141,7 @@ final case class ChatFullInfo(
139141
inviteLink: Option[String] = Option.empty,
140142
pinnedMessage: Option[Message] = Option.empty,
141143
permissions: Option[ChatPermissions] = Option.empty,
144+
canSendGift: Option[Boolean] = Option.empty,
142145
canSendPaidMedia: Option[Boolean] = Option.empty,
143146
slowModeDelay: Option[Int] = Option.empty,
144147
unrestrictBoostCount: Option[Int] = Option.empty,

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ sealed trait InputMedia {}
3232
* Optional. Pass True if the animation needs to be covered with a spoiler animation
3333
*/
3434
final case class InputMediaAnimation(
35-
media: String,
35+
media: IFile,
3636
thumbnail: Option[IFile] = Option.empty,
3737
caption: Option[String] = Option.empty,
3838
parseMode: Option[ParseMode] = Option.empty,
@@ -62,7 +62,7 @@ final case class InputMediaAnimation(
6262
* Optional. Pass True if the photo needs to be covered with a spoiler animation
6363
*/
6464
final case class InputMediaPhoto(
65-
media: String,
65+
media: IFile,
6666
caption: Option[String] = Option.empty,
6767
parseMode: Option[ParseMode] = Option.empty,
6868
captionEntities: List[iozhik.OpenEnum[MessageEntity]] = List.empty,
@@ -82,6 +82,12 @@ final case class InputMediaPhoto(
8282
* should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused
8383
* and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was
8484
* uploaded using multipart/form-data under <file_attach_name>.
85+
* @param cover
86+
* Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers
87+
* (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass
88+
* “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
89+
* @param startTimestamp
90+
* Optional. Start timestamp for the video in the message
8591
* @param caption
8692
* Optional. Caption of the video to be sent, 0-1024 characters after entities parsing
8793
* @param parseMode
@@ -102,8 +108,10 @@ final case class InputMediaPhoto(
102108
* Optional. Pass True if the video needs to be covered with a spoiler animation
103109
*/
104110
final case class InputMediaVideo(
105-
media: String,
111+
media: IFile,
106112
thumbnail: Option[IFile] = Option.empty,
113+
cover: Option[IFile] = Option.empty,
114+
startTimestamp: Option[Int] = Option.empty,
107115
caption: Option[String] = Option.empty,
108116
parseMode: Option[ParseMode] = Option.empty,
109117
captionEntities: List[iozhik.OpenEnum[MessageEntity]] = List.empty,
@@ -138,7 +146,7 @@ final case class InputMediaVideo(
138146
* Always True, if the document is sent as part of an album.
139147
*/
140148
final case class InputMediaDocument(
141-
media: String,
149+
media: IFile,
142150
thumbnail: Option[IFile] = Option.empty,
143151
caption: Option[String] = Option.empty,
144152
parseMode: Option[ParseMode] = Option.empty,
@@ -172,7 +180,7 @@ final case class InputMediaDocument(
172180
* Optional. Title of the audio
173181
*/
174182
final case class InputMediaAudio(
175-
media: String,
183+
media: IFile,
176184
thumbnail: Option[IFile] = Option.empty,
177185
caption: Option[String] = Option.empty,
178186
parseMode: Option[ParseMode] = Option.empty,

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sealed trait InputPaidMedia {}
99
* for Telegram to get a file from the Internet, or pass “attach://<file_attach_name>” to upload a new one using
1010
* multipart/form-data under <file_attach_name> name.
1111
*/
12-
final case class InputPaidMediaPhoto(media: String) extends InputPaidMedia
12+
final case class InputPaidMediaPhoto(media: IFile) extends InputPaidMedia
1313

1414
/** The paid media to send is a video.
1515
*
@@ -23,6 +23,12 @@ final case class InputPaidMediaPhoto(media: String) extends InputPaidMedia
2323
* should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused
2424
* and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was
2525
* uploaded using multipart/form-data under <file_attach_name>.
26+
* @param cover
27+
* Optional. Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers
28+
* (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass
29+
* “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
30+
* @param startTimestamp
31+
* Optional. Start timestamp for the video in the message
2632
* @param width
2733
* Optional. Video width
2834
* @param height
@@ -33,8 +39,10 @@ final case class InputPaidMediaPhoto(media: String) extends InputPaidMedia
3339
* Optional. Pass True if the uploaded video is suitable for streaming
3440
*/
3541
final case class InputPaidMediaVideo(
36-
media: String,
42+
media: IFile,
3743
thumbnail: Option[IFile] = Option.empty,
44+
cover: Option[IFile] = Option.empty,
45+
startTimestamp: Option[Int] = Option.empty,
3846
width: Option[Int] = Option.empty,
3947
height: Option[Int] = Option.empty,
4048
duration: Option[Int] = Option.empty,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package telegramium.bots
22

3-
/** Describes a Telegram Star transaction.
3+
/** Describes a Telegram Star transaction. Note that if the buyer initiates a chargeback with the payment provider from
4+
* whom they acquired Stars (e.g., Apple, Google) following this transaction, the refunded Stars will be deducted from
5+
* the bot's balance. This is outside of Telegram's control.
46
*
57
* @param id
68
* Unique identifier of the transaction. Coincides with the identifier of the original transaction for refund

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package telegramium.bots
22

3-
/** This object contains basic information about a successful payment.
3+
/** This object contains basic information about a successful payment. Note that if the buyer initiates a chargeback
4+
* with the relevant payment provider following this transaction, the funds may be debited from your balance. This is
5+
* outside of Telegram's control.
46
*
57
* @param currency
68
* Three-letter ISO 4217 currency code, or “XTR” for payments in Telegram Stars

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@ package telegramium.bots
22

33
sealed trait TransactionPartner {}
44

5+
/** Describes a transaction with a chat.
6+
*
7+
* @param chat
8+
* Information about the chat
9+
* @param gift
10+
* Optional. The gift sent to the chat by the bot
11+
*/
12+
final case class TransactionPartnerChat(chat: Chat, gift: Option[Gift] = Option.empty) extends TransactionPartner
13+
514
/** Describes the affiliate program that issued the affiliate commission received via this transaction.
615
*
716
* @param commissionPerMille

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ package telegramium.bots
1515
* Duration of the video in seconds as defined by the sender
1616
* @param thumbnail
1717
* Optional. Video thumbnail
18+
* @param cover
19+
* Optional. Available sizes of the cover of the video in the message
20+
* @param startTimestamp
21+
* Optional. Timestamp in seconds from which the video will play in the message
1822
* @param fileName
1923
* Optional. Original filename as defined by the sender
2024
* @param mimeType
@@ -31,6 +35,8 @@ final case class Video(
3135
height: Int,
3236
duration: Int,
3337
thumbnail: Option[PhotoSize] = Option.empty,
38+
cover: List[PhotoSize] = List.empty,
39+
startTimestamp: Option[Int] = Option.empty,
3440
fileName: Option[String] = Option.empty,
3541
mimeType: Option[String] = Option.empty,
3642
fileSize: Option[Long] = Option.empty

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import telegramium.bots.ShippingOption
1111
* Required if ok is True. A JSON-serialized array of available shipping options.
1212
* @param errorMessage
1313
* Required if ok is False. Error message in human readable form that explains why it is impossible to complete the
14-
* order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the
14+
* order (e.g. Sorry, delivery to your desired address is unavailable). Telegram will display this message to the
1515
* user.
1616
*/
1717
final case class AnswerShippingQueryReq(

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import telegramium.bots.KeyboardMarkup
1515
* Message identifier in the chat specified in from_chat_id
1616
* @param messageThreadId
1717
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
18+
* @param videoStartTimestamp
19+
* New start timestamp for the copied video in the message
1820
* @param caption
1921
* New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
2022
* @param parseMode
@@ -42,6 +44,7 @@ final case class CopyMessageReq(
4244
fromChatId: ChatId,
4345
messageId: Int,
4446
messageThreadId: Option[Int] = Option.empty,
47+
videoStartTimestamp: Option[Int] = Option.empty,
4548
caption: Option[String] = Option.empty,
4649
parseMode: Option[ParseMode] = Option.empty,
4750
captionEntities: List[MessageEntity] = List.empty,

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import telegramium.bots.ChatId
1111
* Message identifier in the chat specified in from_chat_id
1212
* @param messageThreadId
1313
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
14+
* @param videoStartTimestamp
15+
* New start timestamp for the forwarded video in the message
1416
* @param disableNotification
1517
* Sends the message silently. Users will receive a notification with no sound.
1618
* @param protectContent
@@ -21,6 +23,7 @@ final case class ForwardMessageReq(
2123
fromChatId: ChatId,
2224
messageId: Int,
2325
messageThreadId: Option[Int] = Option.empty,
26+
videoStartTimestamp: Option[Int] = Option.empty,
2427
disableNotification: Option[Boolean] = Option.empty,
2528
protectContent: Option[Boolean] = Option.empty
2629
)

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

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ trait Methods {
157157
* Required if ok is True. A JSON-serialized array of available shipping options.
158158
* @param errorMessage
159159
* Required if ok is False. Error message in human readable form that explains why it is impossible to complete the
160-
* order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the
160+
* order (e.g. Sorry, delivery to your desired address is unavailable). Telegram will display this message to the
161161
* user.
162162
*/
163163
def answerShippingQuery(
@@ -290,6 +290,8 @@ trait Methods {
290290
* Message identifier in the chat specified in from_chat_id
291291
* @param messageThreadId
292292
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
293+
* @param videoStartTimestamp
294+
* New start timestamp for the copied video in the message
293295
* @param caption
294296
* New caption for media, 0-1024 characters after entities parsing. If not specified, the original caption is kept
295297
* @param parseMode
@@ -317,6 +319,7 @@ trait Methods {
317319
fromChatId: ChatId,
318320
messageId: Int,
319321
messageThreadId: Option[Int] = Option.empty,
322+
videoStartTimestamp: Option[Int] = Option.empty,
320323
caption: Option[String] = Option.empty,
321324
parseMode: Option[ParseMode] = Option.empty,
322325
captionEntities: List[MessageEntity] = List.empty,
@@ -332,6 +335,7 @@ trait Methods {
332335
fromChatId,
333336
messageId,
334337
messageThreadId,
338+
videoStartTimestamp,
335339
caption,
336340
parseMode,
337341
captionEntities,
@@ -1103,6 +1107,8 @@ trait Methods {
11031107
* Message identifier in the chat specified in from_chat_id
11041108
* @param messageThreadId
11051109
* Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
1110+
* @param videoStartTimestamp
1111+
* New start timestamp for the forwarded video in the message
11061112
* @param disableNotification
11071113
* Sends the message silently. Users will receive a notification with no sound.
11081114
* @param protectContent
@@ -1113,10 +1119,19 @@ trait Methods {
11131119
fromChatId: ChatId,
11141120
messageId: Int,
11151121
messageThreadId: Option[Int] = Option.empty,
1122+
videoStartTimestamp: Option[Int] = Option.empty,
11161123
disableNotification: Option[Boolean] = Option.empty,
11171124
protectContent: Option[Boolean] = Option.empty
11181125
): Method[Message] = {
1119-
val req = ForwardMessageReq(chatId, fromChatId, messageId, messageThreadId, disableNotification, protectContent)
1126+
val req = ForwardMessageReq(
1127+
chatId,
1128+
fromChatId,
1129+
messageId,
1130+
messageThreadId,
1131+
videoStartTimestamp,
1132+
disableNotification,
1133+
protectContent
1134+
)
11201135
MethodReq[Message]("forwardMessage", req.asJson)
11211136
}
11221137

@@ -1151,7 +1166,8 @@ trait Methods {
11511166
MethodReq[List[MessageId]]("forwardMessages", req.asJson)
11521167
}
11531168

1154-
/** Returns the list of gifts that can be sent by the bot to users. Requires no parameters. Returns a Gifts object.
1169+
/** Returns the list of gifts that can be sent by the bot to users and channel chats. Requires no parameters. Returns
1170+
* a Gifts object.
11551171
*/
11561172
def getAvailableGifts(): Method[Gifts] = {
11571173
val req = GetAvailableGiftsReq
@@ -2220,17 +2236,20 @@ trait Methods {
22202236
MethodReq[Message]("sendGame", req.asJson)
22212237
}
22222238

2223-
/** Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on
2224-
* success.
2239+
/** Sends a gift to the given user or channel chat. The gift can't be converted to Telegram Stars by the receiver.
2240+
* Returns True on success.
22252241
*
2226-
* @param userId
2227-
* Unique identifier of the target user that will receive the gift
22282242
* @param giftId
22292243
* Identifier of the gift
2244+
* @param userId
2245+
* Required if chat_id is not specified. Unique identifier of the target user who will receive the gift.
2246+
* @param chatId
2247+
* Required if user_id is not specified. Unique identifier for the chat or username of the channel (in the format
2248+
* &#064;channelusername) that will receive the gift.
22302249
* @param payForUpgrade
22312250
* Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
22322251
* @param text
2233-
* Text that will be shown along with the gift; 0-255 characters
2252+
* Text that will be shown along with the gift; 0-128 characters
22342253
* @param textParseMode
22352254
* Mode for parsing entities in the text. See formatting options for more details. Entities other than “bold”,
22362255
* “italic”, “underline”, “strikethrough”, “spoiler”, and “custom_emoji” are ignored.
@@ -2240,14 +2259,15 @@ trait Methods {
22402259
* “custom_emoji” are ignored.
22412260
*/
22422261
def sendGift(
2243-
userId: Long,
22442262
giftId: String,
2263+
userId: Option[Long] = Option.empty,
2264+
chatId: Option[ChatId] = Option.empty,
22452265
payForUpgrade: Option[Boolean] = Option.empty,
22462266
text: Option[String] = Option.empty,
22472267
textParseMode: Option[ParseMode] = Option.empty,
22482268
textEntities: List[MessageEntity] = List.empty
22492269
): Method[Boolean] = {
2250-
val req = SendGiftReq(userId, giftId, payForUpgrade, text, textParseMode, textEntities)
2270+
val req = SendGiftReq(giftId, userId, chatId, payForUpgrade, text, textParseMode, textEntities)
22512271
MethodReq[Boolean]("sendGift", req.asJson)
22522272
}
22532273

@@ -3007,6 +3027,12 @@ trait Methods {
30073027
* exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can't be reused and can be
30083028
* only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using
30093029
* multipart/form-data under <file_attach_name>.
3030+
* @param cover
3031+
* Cover for the video in the message. Pass a file_id to send a file that exists on the Telegram servers
3032+
* (recommended), pass an HTTP URL for Telegram to get a file from the Internet, or pass
3033+
* “attach://<file_attach_name>” to upload a new one using multipart/form-data under <file_attach_name> name.
3034+
* @param startTimestamp
3035+
* Start timestamp for the video in the message
30103036
* @param caption
30113037
* Video caption (may also be used when resending videos by file_id), 0-1024 characters after entities parsing
30123038
* @param parseMode
@@ -3044,6 +3070,8 @@ trait Methods {
30443070
width: Option[Int] = Option.empty,
30453071
height: Option[Int] = Option.empty,
30463072
thumbnail: Option[IFile] = Option.empty,
3073+
cover: Option[IFile] = Option.empty,
3074+
startTimestamp: Option[Int] = Option.empty,
30473075
caption: Option[String] = Option.empty,
30483076
parseMode: Option[ParseMode] = Option.empty,
30493077
captionEntities: List[MessageEntity] = List.empty,
@@ -3066,6 +3094,8 @@ trait Methods {
30663094
width,
30673095
height,
30683096
thumbnail,
3097+
cover,
3098+
startTimestamp,
30693099
caption,
30703100
parseMode,
30713101
captionEntities,
@@ -3082,7 +3112,7 @@ trait Methods {
30823112
MethodReq[Message](
30833113
"sendVideo",
30843114
req.asJson,
3085-
Map("video" -> Option(video), "thumbnail" -> thumbnail).collect { case (k, Some(v)) => k -> v }
3115+
Map("video" -> Option(video), "thumbnail" -> thumbnail, "cover" -> cover).collect { case (k, Some(v)) => k -> v }
30863116
)
30873117
}
30883118

@@ -3396,9 +3426,9 @@ trait Methods {
33963426
MethodReq[Either[Boolean, Message]]("setGameScore", req.asJson)
33973427
}
33983428

3399-
/** Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically
3400-
* forwarded messages from a channel to its discussion group have the same available reactions as messages in the
3401-
* channel. Bots can't use paid reactions. Returns True on success.
3429+
/** Use this method to change the chosen reactions on a message. Service messages of some types can't be reacted to.
3430+
* Automatically forwarded messages from a channel to its discussion group have the same available reactions as
3431+
* messages in the channel. Bots can't use paid reactions. Returns True on success.
34023432
*
34033433
* @param chatId
34043434
* Unique identifier for the target chat or username of the target channel (in the format &#064;channelusername)

0 commit comments

Comments
 (0)