1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-09-03 15:19:30 +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 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/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 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 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 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 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 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 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 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 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 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 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 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 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 {

View File

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

View File

@@ -1,22 +1,37 @@
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.requests.gifts.SendGift
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.GiftId
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.gifts.Gift
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@GenerateVariations
public suspend fun TelegramBot.sendGift(
@GenerationVariant(
User::class,
"id",
"user"
)
userId: UserId,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = execute(
SendGift(
SendGift.toUser(
userId = userId,
giftId = giftId,
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(
@GenerationVariant(
User::class,
"id",
"user"
)
userId: UserId,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = execute(
SendGift(
SendGift.toUser(
userId = userId,
giftId = giftId,
textSources = textSources,
@@ -39,81 +92,27 @@ public suspend fun TelegramBot.sendGift(
)
)
public suspend fun TelegramBot.sendGift(
user: User,
giftId: GiftId,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean = false
): Boolean = sendGift(
userId = user.id,
giftId = giftId,
text = text,
parseMode = parseMode,
upgradableToUnique = upgradableToUnique
)
public suspend fun TelegramBot.sendGift(
user: User,
@GenerateVariations
public suspend fun TelegramBot.sendGiftToChat(
@GenerationVariant(
PublicChat::class,
"id",
"chat"
)
chatId: ChatIdentifier,
@GenerationVariant(
Gift::class,
"id",
"gift"
)
giftId: GiftId,
textSources: TextSourcesList,
upgradableToUnique: Boolean = false,
): Boolean = sendGift(
userId = user.id,
giftId = giftId,
textSources = textSources,
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
): Boolean = execute(
SendGift.toChat(
chatId = chatId,
giftId = giftId,
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
)