1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 07:09:23 +00:00

add support for sending of gifts to chats

This commit is contained in:
2025-02-13 12:17:05 +06:00
parent 3504776344
commit b3b9070cd6
7 changed files with 339 additions and 102 deletions

View File

@@ -1088,23 +1088,33 @@ public final class dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGiftsKt {
public static final fun getAvailableGifts (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun getAvailableGifts (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
} }
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt { public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftGeneratedVariationKt {
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGift (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static synthetic fun sendGift$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGift-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-0SDnvgk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static final fun sendGift-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt {
public static final fun sendGift-1FWvrZc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGift-1FWvrZc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-1FWvrZc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static synthetic fun sendGift-1FWvrZc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-CrS58cM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGift-CrS58cM (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-CrS58cM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static synthetic fun sendGift-CrS58cM$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGiftToChat-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-GROm3fU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static synthetic fun sendGiftToChat-0SDnvgk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; public static final fun sendGiftToChat-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun sendGift-VjR9mJc$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; public static synthetic fun sendGiftToChat-GROm3fU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun sendGift-ySMgKnk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object; }
public static synthetic fun sendGift-ySMgKnk$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift;Ljava/util/List;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftToChatGeneratedVariationKt {
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGiftToChat (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ldev/inmo/tgbotapi/types/gifts/Gift;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGiftToChat-0SDnvgk (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun sendGiftToChat-GROm3fU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
} }
public final class dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessageKt { public final class dev/inmo/tgbotapi/extensions/api/inline/SavePreparedInlineMessageKt {

View File

@@ -2,6 +2,7 @@ plugins {
id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.kotlin.plugin.serialization" id "org.jetbrains.kotlin.plugin.serialization"
id "org.jetbrains.dokka" id "org.jetbrains.dokka"
id "com.google.devtools.ksp"
} }
project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor" project.description = "API extensions with \"Telegram Bot API\"-like extensions for TelegramBot and RequestsExecutor"
@@ -14,6 +15,7 @@ kotlin {
commonMain { commonMain {
dependencies { dependencies {
api project(":tgbotapi.core") api project(":tgbotapi.core")
api libs.microutils.ksp.variations
} }
} }
configureEach { configureEach {
@@ -22,3 +24,8 @@ kotlin {
} }
explicitApi() explicitApi()
} }
dependencies {
add("kspCommonMainMetadata", libs.microutils.ksp.variations.generator)
}

View File

@@ -1,22 +1,37 @@
package dev.inmo.tgbotapi.extensions.api.gifts package dev.inmo.tgbotapi.extensions.api.gifts
import dev.inmo.micro_utils.ksp.variations.GenerateVariations
import dev.inmo.micro_utils.ksp.variations.GenerationVariant
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.gifts.SendGift import dev.inmo.tgbotapi.requests.gifts.SendGift
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.GiftId import dev.inmo.tgbotapi.types.GiftId
import dev.inmo.tgbotapi.types.UserId import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.gifts.Gift import dev.inmo.tgbotapi.types.gifts.Gift
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@GenerateVariations
public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift(
@GenerationVariant(
User::class,
"id",
"user"
)
userId: UserId, userId: UserId,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId, giftId: GiftId,
text: String, text: String,
parseMode: ParseMode?, parseMode: ParseMode?,
upgradableToUnique: Boolean = false upgradableToUnique: Boolean = false
): Boolean = execute( ): Boolean = execute(
SendGift( SendGift.toUser(
userId = userId, userId = userId,
giftId = giftId, giftId = giftId,
text = text, text = text,
@@ -25,13 +40,51 @@ public suspend fun TelegramBot.sendGift(
) )
) )
@GenerateVariations
public suspend fun TelegramBot.sendGiftToChat(
@GenerationVariant(
PublicChat::class,
"id",
"chat"
)
chatId: ChatIdentifier,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = execute(
SendGift.toChat(
chatId = chatId,
giftId = giftId,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
)
@GenerateVariations
public suspend fun TelegramBot.sendGift( public suspend fun TelegramBot.sendGift(
@GenerationVariant(
User::class,
"id",
"user"
)
userId: UserId, userId: UserId,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId, giftId: GiftId,
textSources: TextSourcesList, textSources: TextSourcesList,
upgradableToUnique: Boolean = false, upgradableToUnique: Boolean = false,
): Boolean = execute( ): Boolean = execute(
SendGift( SendGift.toUser(
userId = userId, userId = userId,
giftId = giftId, giftId = giftId,
textSources = textSources, textSources = textSources,
@@ -39,81 +92,27 @@ public suspend fun TelegramBot.sendGift(
) )
) )
public suspend fun TelegramBot.sendGift( @GenerateVariations
user: User, public suspend fun TelegramBot.sendGiftToChat(
giftId: GiftId, @GenerationVariant(
text: String, PublicChat::class,
parseMode: ParseMode?, "id",
upgradableToUnique: Boolean = false "chat"
): Boolean = sendGift( )
userId = user.id, chatId: ChatIdentifier,
giftId = giftId, @GenerationVariant(
text = text, Gift::class,
parseMode = parseMode, "id",
upgradableToUnique = upgradableToUnique "gift"
) )
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId, giftId: GiftId,
textSources: TextSourcesList, textSources: TextSourcesList,
upgradableToUnique: Boolean = false, upgradableToUnique: Boolean = false,
): Boolean = sendGift( ): Boolean = execute(
userId = user.id, SendGift.toChat(
chatId = chatId,
giftId = giftId, giftId = giftId,
textSources = textSources, textSources = textSources,
upgradableToUnique = upgradableToUnique upgradableToUnique = upgradableToUnique
) )
public suspend fun TelegramBot.sendGift(
user: UserId,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user,
giftId = gift.id,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: UserId,
gift: Gift,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user,
giftId = gift.id,
textSources = textSources,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user.id,
giftId = gift.id,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user.id,
giftId = gift.id,
textSources = textSources,
upgradableToUnique = upgradableToUnique
) )

View File

@@ -0,0 +1,73 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SendGift.kt
package dev.inmo.tgbotapi.extensions.api.gifts
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.types.GiftId
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.gifts.Gift
import dev.inmo.tgbotapi.types.message.ParseMode
import kotlin.Boolean
import kotlin.String
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
): Boolean = sendGift(
userId = with(user) {id}, giftId = giftId, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGift(
userId = with(user) {id}, giftId = giftId, text = text, parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
userId: UserId,
gift: Gift,
text: String,
parseMode: ParseMode?,
): Boolean = sendGift(
userId = userId, giftId = with(gift) {id}, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGift(
userId: UserId,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGift(
userId = userId, giftId = with(gift) {id}, text = text, parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
text: String,
parseMode: ParseMode?,
): Boolean = sendGift(
user = user, giftId = with(gift) {id}, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGift(
user = user, giftId = with(gift) {id}, text = text, parseMode = parseMode, upgradableToUnique =
upgradableToUnique
)

View File

@@ -0,0 +1,73 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SendGift.kt
package dev.inmo.tgbotapi.extensions.api.gifts
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.GiftId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.gifts.Gift
import dev.inmo.tgbotapi.types.message.ParseMode
import kotlin.Boolean
import kotlin.String
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
): Boolean = sendGiftToChat(
chatId = with(chat) {id}, giftId = giftId, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGiftToChat(
chatId = with(chat) {id}, giftId = giftId, text = text, parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGiftToChat(
chatId: ChatIdentifier,
gift: Gift,
text: String,
parseMode: ParseMode?,
): Boolean = sendGiftToChat(
chatId = chatId, giftId = with(gift) {id}, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGiftToChat(
chatId: ChatIdentifier,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGiftToChat(
chatId = chatId, giftId = with(gift) {id}, text = text, parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
gift: Gift,
text: String,
parseMode: ParseMode?,
): Boolean = sendGiftToChat(
chat = chat, giftId = with(gift) {id}, text = text, parseMode = parseMode
)
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
gift: Gift,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
): Boolean = sendGiftToChat(
chat = chat, giftId = with(gift) {id}, text = text, parseMode = parseMode, upgradableToUnique =
upgradableToUnique
)

View File

@@ -4570,19 +4570,21 @@ public final class dev/inmo/tgbotapi/requests/gifts/GetAvailableGifts : dev/inmo
public final class dev/inmo/tgbotapi/requests/gifts/SendGift : dev/inmo/tgbotapi/abstracts/TextedOutput, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { public final class dev/inmo/tgbotapi/requests/gifts/SendGift : dev/inmo/tgbotapi/abstracts/TextedOutput, dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {
public static final field Companion Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion; public static final field Companion Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion;
public synthetic fun <init> (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JLjava/lang/String;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (JLjava/lang/String;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (JLjava/lang/String;Ljava/util/List;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V public synthetic fun <init> (JLjava/lang/String;Ljava/util/List;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component1-tHkBKVM ()J public synthetic fun <init> (Ldev/inmo/tgbotapi/types/ChatId;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V
public final fun component2-OyCYJok ()Ljava/lang/String; public final fun component1-_eYXl24 ()Ldev/inmo/tgbotapi/types/ChatId;
public final fun component3 ()Ljava/lang/String; public final fun component2 ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public final fun component4 ()Ldev/inmo/tgbotapi/types/message/ParseMode; public final fun component3-OyCYJok ()Ljava/lang/String;
public final fun component6 ()Z public final fun component4 ()Ljava/lang/String;
public final fun copy-ekxNoiw (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift; public final fun component5 ()Ldev/inmo/tgbotapi/types/message/ParseMode;
public static synthetic fun copy-ekxNoiw$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift; public final fun component7 ()Z
public final fun copy-xmxulwY (Ldev/inmo/tgbotapi/types/ChatId;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public static synthetic fun copy-xmxulwY$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift;Ldev/inmo/tgbotapi/types/ChatId;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Ljava/util/List;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public fun equals (Ljava/lang/Object;)Z public fun equals (Ljava/lang/Object;)Z
public final fun getChatId ()Ldev/inmo/tgbotapi/types/ChatIdentifier;
public fun getEntities ()Ljava/util/List; public fun getEntities ()Ljava/util/List;
public final fun getGiftId-OyCYJok ()Ljava/lang/String; public final fun getGiftId-OyCYJok ()Ljava/lang/String;
public fun getParseMode ()Ldev/inmo/tgbotapi/types/message/ParseMode; public fun getParseMode ()Ldev/inmo/tgbotapi/types/message/ParseMode;
@@ -4591,7 +4593,7 @@ public final class dev/inmo/tgbotapi/requests/gifts/SendGift : dev/inmo/tgbotapi
public fun getText ()Ljava/lang/String; public fun getText ()Ljava/lang/String;
public fun getTextSources ()Ljava/util/List; public fun getTextSources ()Ljava/util/List;
public final fun getUpgradableToUnique ()Z public final fun getUpgradableToUnique ()Z
public final fun getUserId-tHkBKVM ()J public final fun getUserId-_eYXl24 ()Ldev/inmo/tgbotapi/types/ChatId;
public fun hashCode ()I public fun hashCode ()I
public fun method ()Ljava/lang/String; public fun method ()Ljava/lang/String;
public fun toString ()Ljava/lang/String; public fun toString ()Ljava/lang/String;
@@ -4609,6 +4611,14 @@ public synthetic class dev/inmo/tgbotapi/requests/gifts/SendGift$$serializer : k
public final class dev/inmo/tgbotapi/requests/gifts/SendGift$Companion { public final class dev/inmo/tgbotapi/requests/gifts/SendGift$Companion {
public final fun serializer ()Lkotlinx/serialization/KSerializer; public final fun serializer ()Lkotlinx/serialization/KSerializer;
public final fun toChat-A6CMM0Q (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/util/List;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public static synthetic fun toChat-A6CMM0Q$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/util/List;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public final fun toChat-MXj3T_8 (Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public static synthetic fun toChat-MXj3T_8$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public final fun toUser-IEl38uo (JLjava/lang/String;Ljava/util/List;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public static synthetic fun toUser-IEl38uo$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion;JLjava/lang/String;Ljava/util/List;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public final fun toUser-LbrZz8c (JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;Z)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
public static synthetic fun toUser-LbrZz8c$default (Ldev/inmo/tgbotapi/requests/gifts/SendGift$Companion;JLjava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/ParseMode;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/requests/gifts/SendGift;
} }
public final class dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest { public final class dev/inmo/tgbotapi/requests/inline/SavePreparedInlineMessage : dev/inmo/tgbotapi/requests/abstracts/SimpleRequest {

View File

@@ -19,11 +19,13 @@ import kotlinx.serialization.builtins.serializer
@Serializable @Serializable
data class SendGift internal constructor( data class SendGift internal constructor(
@SerialName(userIdField) @SerialName(userIdField)
val userId: UserId, val userId: UserId? = null,
@SerialName(chatIdField)
val chatId: ChatIdentifier? = null,
@SerialName(giftIdField) @SerialName(giftIdField)
val giftId: GiftId, val giftId: GiftId,
@SerialName(textField) @SerialName(textField)
override val text: String, override val text: String? = null,
@SerialName(textParseModeField) @SerialName(textParseModeField)
override val parseMode: ParseMode?, override val parseMode: ParseMode?,
@SerialName(textEntitiesField) @SerialName(textEntitiesField)
@@ -32,7 +34,11 @@ data class SendGift internal constructor(
val upgradableToUnique: Boolean = false val upgradableToUnique: Boolean = false
) : SimpleRequest<Boolean>, TextedOutput { ) : SimpleRequest<Boolean>, TextedOutput {
override val textSources: TextSourcesList? by lazy { override val textSources: TextSourcesList? by lazy {
rawEntities ?.asTextSources(text) rawEntities ?.let {
text ?.let { _ ->
it.asTextSources(text)
}
}
} }
override fun method(): String = "sendGift" override fun method(): String = "sendGift"
@@ -44,6 +50,7 @@ data class SendGift internal constructor(
override val resultDeserializer: DeserializationStrategy<Boolean> override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer() get() = Boolean.serializer()
@Deprecated("Use factory function `toUser` instead", ReplaceWith("toUser(userId, giftId, text, parseMode, upgradableToUnique)"))
constructor( constructor(
userId: UserId, userId: UserId,
giftId: GiftId, giftId: GiftId,
@@ -59,17 +66,75 @@ data class SendGift internal constructor(
upgradableToUnique = upgradableToUnique upgradableToUnique = upgradableToUnique
) )
@Deprecated("Use factory function `toUser` instead", ReplaceWith("toUser(userId, giftId, textSources, upgradableToUnique)"))
constructor( constructor(
userId: UserId, userId: UserId,
giftId: GiftId, giftId: GiftId,
textSources: TextSourcesList, textSources: TextSourcesList? = null,
upgradableToUnique: Boolean = false, upgradableToUnique: Boolean = false,
) : this( ) : this(
userId = userId, userId = userId,
giftId = giftId, giftId = giftId,
text = textSources.makeSourceString(), text = textSources ?.makeSourceString(),
parseMode = null, parseMode = null,
rawEntities = textSources.toRawMessageEntities(), rawEntities = textSources ?.toRawMessageEntities(),
upgradableToUnique = upgradableToUnique upgradableToUnique = upgradableToUnique
) )
companion object {
fun toUser(
userId: UserId,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
) = SendGift(
userId = userId,
giftId = giftId,
text = text,
parseMode = parseMode,
rawEntities = null,
upgradableToUnique = upgradableToUnique
)
fun toUser(
userId: UserId,
giftId: GiftId,
textSources: TextSourcesList? = null,
upgradableToUnique: Boolean = false,
) = SendGift(
userId = userId,
giftId = giftId,
text = textSources ?.makeSourceString(),
parseMode = null,
rawEntities = textSources ?.toRawMessageEntities(),
upgradableToUnique = upgradableToUnique
)
fun toChat(
chatId: ChatIdentifier,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
) = SendGift(
chatId = chatId,
giftId = giftId,
text = text,
parseMode = parseMode,
rawEntities = null,
upgradableToUnique = upgradableToUnique
)
fun toChat(
chatId: ChatIdentifier,
giftId: GiftId,
textSources: TextSourcesList? = null,
upgradableToUnique: Boolean = false,
) = SendGift(
chatId = chatId,
giftId = giftId,
text = textSources ?.makeSourceString(),
parseMode = null,
rawEntities = textSources ?.toRawMessageEntities(),
upgradableToUnique = upgradableToUnique
)
}
} }