Skip to content

Commit

Permalink
7.8.0 (#323)
Browse files Browse the repository at this point in the history
* Supported Telegram API [8.2](https://core.telegram.org/bots/api-changelog#january-1-2025).
* Deprecated `sendAsync` methods in favor of `sendReturning` (they are the same).
  • Loading branch information
vendelieu authored Jan 2, 2025
1 parent 1584d40 commit 50601b2
Show file tree
Hide file tree
Showing 38 changed files with 588 additions and 101 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Telegram-bot (KtGram) Changelog

## 7.8.0

* Supported Telegram API [8.2](https://core.telegram.org/bots/api-changelog#january-1-2025).
* Deprecated `sendAsync` methods in favor of `sendReturning` (they are the same).

## 7.7.1

* Added max handling retries to spring starter configuration.
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ use [Github Flow](https://guides.github.com/introduction/flow/index.html)). We a
5. Specify `dev` as target branch.
6. Issue that pull request!

Helpful gradle tasks are:

* `./gradlew apiDump` - generates api dump
* `./gradlew prepareRelease` - formats code, does api validation, updates kdocs, runs api violations check.

### Environment

Environment parameters that are required for testing:
Expand Down
142 changes: 124 additions & 18 deletions buildSrc/src/main/resources/api.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "Bot API 8.1",
"release_date": "December 4, 2024",
"changelog": "https://core.telegram.org/bots/api#december-4-2024",
"version": "Bot API 8.2",
"release_date": "January 1, 2025",
"changelog": "https://core.telegram.org/bots/api#january-1-2025",
"methods": {
"getUpdates": {
"name": "getUpdates",
Expand Down Expand Up @@ -51,7 +51,7 @@
"name": "setWebhook",
"href": "https://core.telegram.org/bots/api#setwebhook",
"description": [
"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.",
"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.",
"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."
],
"returns": [
Expand Down Expand Up @@ -5691,15 +5691,15 @@
"String"
],
"required": false,
"description": "A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files: https://core.telegram.org/bots/api#sending-files. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail."
"description": "A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see https://core.telegram.org/stickers#animation-requirements for animated sticker technical requirements), or a .WEBM video with the thumbnail up to 32 kilobytes in size; see https://core.telegram.org/stickers#video-requirements for video sticker technical requirements. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More information on Sending Files: https://core.telegram.org/bots/api#sending-files. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail."
},
{
"name": "format",
"types": [
"String"
],
"required": true,
"description": "Format of the thumbnail, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, or \"video\" for a WEBM video"
"description": "Format of the thumbnail, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, or \"video\" for a .WEBM video"
}
]
},
Expand Down Expand Up @@ -5787,6 +5787,14 @@
"required": true,
"description": "Identifier of the gift"
},
{
"name": "pay_for_upgrade",
"types": [
"Boolean"
],
"required": false,
"description": "Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver"
},
{
"name": "text",
"types": [
Expand All @@ -5813,6 +5821,104 @@
}
]
},
"verifyUser": {
"name": "verifyUser",
"href": "https://core.telegram.org/bots/api#verifyuser",
"description": [
"Verifies a user on behalf of the organization which is represented by the bot. Returns True on success."
],
"returns": [
"Boolean"
],
"fields": [
{
"name": "user_id",
"types": [
"Integer"
],
"required": true,
"description": "Unique identifier of the target user"
},
{
"name": "custom_description",
"types": [
"String"
],
"required": false,
"description": "Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description."
}
]
},
"verifyChat": {
"name": "verifyChat",
"href": "https://core.telegram.org/bots/api#verifychat",
"description": [
"Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success."
],
"returns": [
"Boolean"
],
"fields": [
{
"name": "chat_id",
"types": [
"Integer",
"String"
],
"required": true,
"description": "Unique identifier for the target chat or username of the target channel (in the format @channelusername)"
},
{
"name": "custom_description",
"types": [
"String"
],
"required": false,
"description": "Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description."
}
]
},
"removeUserVerification": {
"name": "removeUserVerification",
"href": "https://core.telegram.org/bots/api#removeuserverification",
"description": [
"Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success."
],
"returns": [
"Boolean"
],
"fields": [
{
"name": "user_id",
"types": [
"Integer"
],
"required": true,
"description": "Unique identifier of the target user"
}
]
},
"removeChatVerification": {
"name": "removeChatVerification",
"href": "https://core.telegram.org/bots/api#removechatverification",
"description": [
"Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success."
],
"returns": [
"Boolean"
],
"fields": [
{
"name": "chat_id",
"types": [
"Integer",
"String"
],
"required": true,
"description": "Unique identifier for the target chat or username of the target channel (in the format @channelusername)"
}
]
},
"answerInlineQuery": {
"name": "answerInlineQuery",
"href": "https://core.telegram.org/bots/api#answerinlinequery",
Expand Down Expand Up @@ -10301,7 +10407,7 @@
"name": "BackgroundTypePattern",
"href": "https://core.telegram.org/bots/api#backgroundtypepattern",
"description": [
"The background is a PNG or TGV (gzipped subset of SVG with MIME type \"application/x-tgwallpattern\") pattern to be combined with the background fill chosen by the user."
"The background is a .PNG or .TGV (gzipped subset of SVG with MIME type \"application/x-tgwallpattern\") pattern to be combined with the background fill chosen by the user."
],
"fields": [
{
Expand Down Expand Up @@ -14694,7 +14800,7 @@
"String"
],
"required": true,
"description": "Format of the added sticker, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, \"video\" for a WEBM video"
"description": "Format of the added sticker, must be one of \"static\" for a .WEBP or .PNG image, \"animated\" for a .TGS animation, \"video\" for a .WEBM video"
},
{
"name": "emoji_list",
Expand Down Expand Up @@ -14753,6 +14859,14 @@
"required": true,
"description": "The number of Telegram Stars that must be paid to send the sticker"
},
{
"name": "upgrade_star_count",
"types": [
"Integer"
],
"required": false,
"description": "Optional. The number of Telegram Stars that must be paid to upgrade the gift to a unique one"
},
{
"name": "total_count",
"types": [
Expand Down Expand Up @@ -14983,14 +15097,6 @@
"required": false,
"description": "Optional. URL of the result"
},
{
"name": "hide_url",
"types": [
"Boolean"
],
"required": false,
"description": "Optional. Pass True if you don't want the URL to be shown in the message"
},
{
"name": "description",
"types": [
Expand Down Expand Up @@ -15181,7 +15287,7 @@
"String"
],
"required": true,
"description": "A valid URL for the GIF file. File size must not exceed 1MB"
"description": "A valid URL for the GIF file"
},
{
"name": "gif_width",
Expand Down Expand Up @@ -15313,7 +15419,7 @@
"String"
],
"required": true,
"description": "A valid URL for the MPEG4 file. File size must not exceed 1MB"
"description": "A valid URL for the MPEG4 file"
},
{
"name": "mpeg4_width",
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mockk = "1.13.14"
kover = "0.9.0"
krypto = "4.0.10"
urlencoder = "1.6.0"
sslcontext = "8.3.7"
sslcontext = "9.0.0"
spring = "3.4.1"

ksp = "2.1.0-1.0.29"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ import eu.vendeli.tgbot.api.stickerset.SetStickerPositionInSetAction
import eu.vendeli.tgbot.api.stickerset.SetStickerSetThumbnailAction
import eu.vendeli.tgbot.api.stickerset.SetStickerSetTitleAction
import eu.vendeli.tgbot.api.stickerset.UploadStickerFileAction
import eu.vendeli.tgbot.api.verification.RemoveChatVerificationAction
import eu.vendeli.tgbot.api.verification.RemoveUserVerificationAction
import eu.vendeli.tgbot.api.verification.VerifyChatAction
import eu.vendeli.tgbot.api.verification.VerifyUserAction
import eu.vendeli.tgbot.types.ParseMode
import eu.vendeli.tgbot.types.ReactionType
import eu.vendeli.tgbot.types.User
Expand Down Expand Up @@ -480,9 +484,10 @@ public inline fun TelegramBot.savePreparedInlineMessage(userId: Long, noinline r
public inline fun TelegramBot.sendGift(
userId: Long,
giftId: String,
payForUpgrade: Boolean? = null,
textParseMode: ParseMode? = null,
noinline text: (() -> String)? = null,
): SendGiftAction = eu.vendeli.tgbot.api.botactions.sendGift(userId, giftId, textParseMode, text)
noinline text: () -> String?,
): SendGiftAction = eu.vendeli.tgbot.api.botactions.sendGift(userId, giftId, payForUpgrade, textParseMode, text)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.setMyCommands(
Expand Down Expand Up @@ -1152,3 +1157,33 @@ public inline fun TelegramBot.uploadStickerFile(
sticker: InputFile,
stickerFormat: StickerFormat,
): UploadStickerFileAction = eu.vendeli.tgbot.api.stickerset.uploadStickerFile(userId, sticker, stickerFormat)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.removeChatVerification(chatId: Long): RemoveChatVerificationAction = eu.vendeli.tgbot.api.verification.removeChatVerification(chatId)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.removeChatVerification(chat: Chat): RemoveChatVerificationAction = eu.vendeli.tgbot.api.verification.removeChatVerification(chat)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.removeUserVerification(userId: Long): RemoveUserVerificationAction = eu.vendeli.tgbot.api.verification.removeUserVerification(userId)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.removeUserVerification(user: User): RemoveUserVerificationAction = eu.vendeli.tgbot.api.verification.removeUserVerification(user)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyChat(chatId: Long, customDescription: String? = null): VerifyChatAction = eu.vendeli.tgbot.api.verification.verifyChat(chatId, customDescription)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyChat(chatId: Long, noinline customDescription: () -> String?): VerifyChatAction = eu.vendeli.tgbot.api.verification.verifyChat(chatId, customDescription)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyChat(chat: Chat, noinline customDescription: () -> String?): VerifyChatAction = eu.vendeli.tgbot.api.verification.verifyChat(chat, customDescription)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyUser(userId: Long, customDescription: String? = null): VerifyUserAction = eu.vendeli.tgbot.api.verification.verifyUser(userId, customDescription)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyUser(userId: Long, noinline customDescription: () -> String?): VerifyUserAction = eu.vendeli.tgbot.api.verification.verifyUser(userId, customDescription)

@Suppress("NOTHING_TO_INLINE")
public inline fun TelegramBot.verifyUser(user: User, noinline customDescription: () -> String?): VerifyUserAction = eu.vendeli.tgbot.api.verification.verifyUser(user, customDescription)
Loading

0 comments on commit 50601b2

Please sign in to comment.