Skip to content

Commit d8fef2e

Browse files
committed
Telegram Bot API January 1, 2025 updates (v8.2)
1 parent fb6463c commit d8fef2e

16 files changed

+163
-34
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.1%20(December%204%2C%202024)-blue)](https://core.telegram.org/bots/api#recent-changes)
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)
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.801.0",
4+
"9.802.0",
55
git.gitCurrentBranch.value,
66
git.gitDescribedVersion.value,
77
git.gitUncommittedChanges.value

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ final case class BackgroundTypeWallpaper(
2020
isMoving: Option[Boolean] = Option.empty
2121
) extends BackgroundType
2222

23-
/** The background is a PNG or TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be
23+
/** The background is a .PNG or .TGV (gzipped subset of SVG with MIME type “application/x-tgwallpattern”) pattern to be
2424
* combined with the background fill chosen by the user.
2525
*
2626
* @param document

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package telegramium.bots
88
* The sticker that represents the gift
99
* @param starCount
1010
* The number of Telegram Stars that must be paid to send the sticker
11+
* @param upgradeStarCount
12+
* Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one
1113
* @param totalCount
1214
* Optional. The total number of the gifts of this type that can be sent; for limited gifts only
1315
* @param remainingCount
@@ -17,6 +19,7 @@ final case class Gift(
1719
id: String,
1820
sticker: Sticker,
1921
starCount: Int,
22+
upgradeStarCount: Option[Int] = Option.empty,
2023
totalCount: Option[Int] = Option.empty,
2124
remainingCount: Option[Int] = Option.empty
2225
)

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ sealed trait InlineQueryResult {}
99
* @param id
1010
* Unique identifier for this result, 1-64 bytes
1111
* @param gifUrl
12-
* A valid URL for the GIF file. File size must not exceed 1MB
12+
* A valid URL for the GIF file
1313
* @param thumbnailUrl
1414
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
1515
* @param gifWidth
@@ -277,8 +277,6 @@ final case class InlineQueryResultCachedVoice(
277277
* Optional. Inline keyboard attached to the message
278278
* @param url
279279
* Optional. URL of the result
280-
* @param hideUrl
281-
* Optional. Pass True if you don't want the URL to be shown in the message
282280
* @param description
283281
* Optional. Short description of the result
284282
* @param thumbnailUrl
@@ -294,7 +292,6 @@ final case class InlineQueryResultArticle(
294292
inputMessageContent: InputMessageContent,
295293
replyMarkup: Option[InlineKeyboardMarkup] = Option.empty,
296294
url: Option[String] = Option.empty,
297-
hideUrl: Option[Boolean] = Option.empty,
298295
description: Option[String] = Option.empty,
299296
thumbnailUrl: Option[String] = Option.empty,
300297
thumbnailWidth: Option[Int] = Option.empty,
@@ -345,7 +342,7 @@ final case class InlineQueryResultAudio(
345342
* @param id
346343
* Unique identifier for this result, 1-64 bytes
347344
* @param mpeg4Url
348-
* A valid URL for the MPEG4 file. File size must not exceed 1MB
345+
* A valid URL for the MPEG4 file
349346
* @param thumbnailUrl
350347
* URL of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result
351348
* @param mpeg4Width

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package telegramium.bots
99
* Animated and video stickers can't be uploaded via HTTP URL.
1010
* @param format
1111
* Format of the added sticker, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation,
12-
* “video” for a WEBM video
12+
* “video” for a .WEBM video
1313
* @param emojiList
1414
* List of 1-20 emoji associated with the sticker
1515
* @param maskPosition

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ package telegramium.bots.client
1616
* "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list of
1717
* available update types. Specify an empty list to receive all update types except chat_member, message_reaction,
1818
* and message_reaction_count (default). If not specified, the previous setting will be used. Please note that this
19-
* parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received
20-
* for a short period of time.
19+
* parameter doesn't affect updates created before the call to getUpdates, so unwanted updates may be received for a
20+
* short period of time.
2121
*/
2222
final case class GetUpdatesReq(
2323
offset: Option[Int] = Option.empty,

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

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,7 +1394,7 @@ trait Methods {
13941394
* "edited_channel_post", "callback_query"] to only receive updates of these types. See Update for a complete list
13951395
* of available update types. Specify an empty list to receive all update types except chat_member,
13961396
* message_reaction, and message_reaction_count (default). If not specified, the previous setting will be used.
1397-
* Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted
1397+
* Please note that this parameter doesn't affect updates created before the call to getUpdates, so unwanted
13981398
* updates may be received for a short period of time.
13991399
*/
14001400
def getUpdates(
@@ -1600,6 +1600,28 @@ trait Methods {
16001600
MethodReq[Boolean]("refundStarPayment", req.asJson)
16011601
}
16021602

1603+
/** Removes verification from a chat that is currently verified on behalf of the organization represented by the bot.
1604+
* Returns True on success.
1605+
*
1606+
* @param chatId
1607+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
1608+
*/
1609+
def removeChatVerification(chatId: ChatId): Method[Boolean] = {
1610+
val req = RemoveChatVerificationReq(chatId)
1611+
MethodReq[Boolean]("removeChatVerification", req.asJson)
1612+
}
1613+
1614+
/** Removes verification from a user who is currently verified on behalf of the organization represented by the bot.
1615+
* Returns True on success.
1616+
*
1617+
* @param userId
1618+
* Unique identifier of the target user
1619+
*/
1620+
def removeUserVerification(userId: Long): Method[Boolean] = {
1621+
val req = RemoveUserVerificationReq(userId)
1622+
MethodReq[Boolean]("removeUserVerification", req.asJson)
1623+
}
1624+
16031625
/** Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat
16041626
* for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic.
16051627
* Returns True on success.
@@ -2205,6 +2227,8 @@ trait Methods {
22052227
* Unique identifier of the target user that will receive the gift
22062228
* @param giftId
22072229
* Identifier of the gift
2230+
* @param payForUpgrade
2231+
* Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
22082232
* @param text
22092233
* Text that will be shown along with the gift; 0-255 characters
22102234
* @param textParseMode
@@ -2218,11 +2242,12 @@ trait Methods {
22182242
def sendGift(
22192243
userId: Long,
22202244
giftId: String,
2245+
payForUpgrade: Option[Boolean] = Option.empty,
22212246
text: Option[String] = Option.empty,
22222247
textParseMode: Option[ParseMode] = Option.empty,
22232248
textEntities: List[MessageEntity] = List.empty
22242249
): Method[Boolean] = {
2225-
val req = SendGiftReq(userId, giftId, text, textParseMode, textEntities)
2250+
val req = SendGiftReq(userId, giftId, payForUpgrade, text, textParseMode, textEntities)
22262251
MethodReq[Boolean]("sendGift", req.asJson)
22272252
}
22282253

@@ -3565,12 +3590,12 @@ trait Methods {
35653590
* User identifier of the sticker set owner
35663591
* @param format
35673592
* Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or
3568-
* “video” for a WEBM video
3593+
* “video” for a .WEBM video
35693594
* @param thumbnail
35703595
* A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of
35713596
* exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see
35723597
* https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a
3573-
* WEBM video with the thumbnail up to 32 kilobytes in size; see
3598+
* .WEBM video with the thumbnail up to 32 kilobytes in size; see
35743599
* https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id
35753600
* as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for
35763601
* Telegram to get a file from the Internet, or upload a new one using multipart/form-data. Animated and video
@@ -3624,10 +3649,10 @@ trait Methods {
36243649

36253650
/** Use this method to specify a URL and receive incoming updates via an outgoing webhook. Whenever there is an update
36263651
* for the bot, we will send an HTTPS POST request to the specified URL, containing a JSON-serialized Update. In case
3627-
* of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success. If
3628-
* you'd like to make sure that the webhook was set by you, you can specify secret data in the parameter
3629-
* secret_token. If specified, the request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret
3630-
* token as content.
3652+
* of an unsuccessful request (a request with response HTTP status code different from 2XY), we will repeat the
3653+
* request and give up after a reasonable amount of attempts. Returns True on success. If you'd like to make sure
3654+
* that the webhook was set by you, you can specify secret data in the parameter secret_token. If specified, the
3655+
* request will contain a header “X-Telegram-Bot-Api-Secret-Token” with the secret token as content.
36313656
*
36323657
* @param url
36333658
* HTTPS URL to send updates to. Use an empty string to remove webhook integration
@@ -3844,4 +3869,30 @@ trait Methods {
38443869
)
38453870
}
38463871

3872+
/** Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success.
3873+
*
3874+
* @param chatId
3875+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
3876+
* @param customDescription
3877+
* Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to
3878+
* provide a custom verification description.
3879+
*/
3880+
def verifyChat(chatId: ChatId, customDescription: Option[String] = Option.empty): Method[Boolean] = {
3881+
val req = VerifyChatReq(chatId, customDescription)
3882+
MethodReq[Boolean]("verifyChat", req.asJson)
3883+
}
3884+
3885+
/** Verifies a user on behalf of the organization which is represented by the bot. Returns True on success.
3886+
*
3887+
* @param userId
3888+
* Unique identifier of the target user
3889+
* @param customDescription
3890+
* Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to
3891+
* provide a custom verification description.
3892+
*/
3893+
def verifyUser(userId: Long, customDescription: Option[String] = Option.empty): Method[Boolean] = {
3894+
val req = VerifyUserReq(userId, customDescription)
3895+
MethodReq[Boolean]("verifyUser", req.asJson)
3896+
}
3897+
38473898
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package telegramium.bots.client
2+
3+
import telegramium.bots.ChatId
4+
5+
/** @param chatId
6+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
7+
*/
8+
final case class RemoveChatVerificationReq(chatId: ChatId)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package telegramium.bots.client
2+
3+
/** @param userId Unique identifier of the target user */
4+
final case class RemoveUserVerificationReq(userId: Long)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import telegramium.bots.MessageEntity
77
* Unique identifier of the target user that will receive the gift
88
* @param giftId
99
* Identifier of the gift
10+
* @param payForUpgrade
11+
* Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver
1012
* @param text
1113
* Text that will be shown along with the gift; 0-255 characters
1214
* @param textParseMode
@@ -20,6 +22,7 @@ import telegramium.bots.MessageEntity
2022
final case class SendGiftReq(
2123
userId: Long,
2224
giftId: String,
25+
payForUpgrade: Option[Boolean] = Option.empty,
2326
text: Option[String] = Option.empty,
2427
textParseMode: Option[ParseMode] = Option.empty,
2528
textEntities: List[MessageEntity] = List.empty

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import telegramium.bots.IFile
88
* User identifier of the sticker set owner
99
* @param format
1010
* Format of the thumbnail, must be one of “static” for a .WEBP or .PNG image, “animated” for a .TGS animation, or
11-
* “video” for a WEBM video
11+
* “video” for a .WEBM video
1212
* @param thumbnail
1313
* A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of
1414
* exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see
15-
* https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM
15+
* https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM
1616
* video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for
1717
* video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the
1818
* Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package telegramium.bots.client
2+
3+
import telegramium.bots.ChatId
4+
5+
/** @param chatId
6+
* Unique identifier for the target chat or username of the target channel (in the format @channelusername)
7+
* @param customDescription
8+
* Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to
9+
* provide a custom verification description.
10+
*/
11+
final case class VerifyChatReq(chatId: ChatId, customDescription: Option[String] = Option.empty)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package telegramium.bots.client
2+
3+
/** @param userId
4+
* Unique identifier of the target user
5+
* @param customDescription
6+
* Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to
7+
* provide a custom verification description.
8+
*/
9+
final case class VerifyUserReq(userId: Long, customDescription: Option[String] = Option.empty)

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,26 @@ object CirceImplicits {
887887
)
888888
}
889889

890+
implicit lazy val removechatverificationreqEncoder: Encoder[RemoveChatVerificationReq] =
891+
(x: RemoveChatVerificationReq) => {
892+
Json.fromFields(
893+
List(
894+
"chat_id" -> x.chatId.asJson,
895+
"method" -> "removeChatVerification".asJson
896+
).filter(!_._2.isNull)
897+
)
898+
}
899+
900+
implicit lazy val removeuserverificationreqEncoder: Encoder[RemoveUserVerificationReq] =
901+
(x: RemoveUserVerificationReq) => {
902+
Json.fromFields(
903+
List(
904+
"user_id" -> x.userId.asJson,
905+
"method" -> "removeUserVerification".asJson
906+
).filter(!_._2.isNull)
907+
)
908+
}
909+
890910
implicit lazy val reopenforumtopicreqEncoder: Encoder[ReopenForumTopicReq] =
891911
(x: ReopenForumTopicReq) => {
892912
Json.fromFields(
@@ -1118,6 +1138,7 @@ object CirceImplicits {
11181138
List(
11191139
"user_id" -> x.userId.asJson,
11201140
"gift_id" -> x.giftId.asJson,
1141+
"pay_for_upgrade" -> x.payForUpgrade.asJson,
11211142
"text" -> x.text.asJson,
11221143
"text_parse_mode" -> x.textParseMode.asJson,
11231144
"text_entities" -> x.textEntities.asJson,
@@ -1824,4 +1845,26 @@ object CirceImplicits {
18241845
)
18251846
}
18261847

1848+
implicit lazy val verifychatreqEncoder: Encoder[VerifyChatReq] =
1849+
(x: VerifyChatReq) => {
1850+
Json.fromFields(
1851+
List(
1852+
"chat_id" -> x.chatId.asJson,
1853+
"custom_description" -> x.customDescription.asJson,
1854+
"method" -> "verifyChat".asJson
1855+
).filter(!_._2.isNull)
1856+
)
1857+
}
1858+
1859+
implicit lazy val verifyuserreqEncoder: Encoder[VerifyUserReq] =
1860+
(x: VerifyUserReq) => {
1861+
Json.fromFields(
1862+
List(
1863+
"user_id" -> x.userId.asJson,
1864+
"custom_description" -> x.customDescription.asJson,
1865+
"method" -> "verifyUser".asJson
1866+
).filter(!_._2.isNull)
1867+
)
1868+
}
1869+
18271870
}

0 commit comments

Comments
 (0)