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

Merge branch '25.0.0' into api-v9.0-premium

This commit is contained in:
Bodya
2025-04-22 22:48:26 +03:00
committed by GitHub
73 changed files with 3863 additions and 571 deletions

View File

@@ -1,5 +1,7 @@
# TelegramBotAPI changelog
## 25.0.0
## 24.0.2
* `Version`:

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=24.0.2
library_version=25.0.0

View File

@@ -57,6 +57,7 @@ microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
microutils-ksp-generator = { module = "dev.inmo:micro_utils.ksp.generator", version.ref = "microutils" }
microutils-ksp-sealed = { module = "dev.inmo:micro_utils.ksp.sealed", version.ref = "microutils" }
microutils-ksp-sealed-generator = { module = "dev.inmo:micro_utils.ksp.sealed.generator", version.ref = "microutils" }
microutils-ksp-variations = { module = "dev.inmo:micro_utils.ksp.variations", version.ref = "microutils" }

View File

@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip

View File

@@ -330,6 +330,57 @@ public final class dev/inmo/tgbotapi/extensions/api/bot/SetMyShortDescriptionKt
public static synthetic fun setMyShortDescription$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/micro_utils/language_codes/IetfLang;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/DeleteBusinessMessagesGeneratedVariationKt {
public static final fun deleteBusinessMessages-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/DeleteBusinessMessagesKt {
public static final fun deleteBusinessMessages-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/GetBusinessAccountStarBalanceKt {
public static final fun getBusinessAccountStarBalance-spp27rg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/ReadBusinessMessageGeneratedVariationKt {
public static final fun readBusinessMessage-1MWLODE (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/chat/Chat;JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/ReadBusinessMessageKt {
public static final fun readBusinessMessage-kYJnN-U (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;JJLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun readBusinessMessage-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/RemoveBusinessAccountProfilePhotoKt {
public static final fun removeBusinessAccountProfilePhoto-spp27rg (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountBioKt {
public static final fun setBusinessAccountBio-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountNameKt {
public static final fun setBusinessAccountName-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setBusinessAccountName-XzFA9qU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountProfilePhotoKt {
public static final fun setBusinessAccountProfilePhoto-XzFA9qU (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/requests/business_connection/InputProfilePhoto;ZLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun setBusinessAccountProfilePhoto-XzFA9qU$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ldev/inmo/tgbotapi/requests/business_connection/InputProfilePhoto;ZLkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountUsernameGeneratedVariationKt {
public static final fun setBusinessAccountUsername-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/SetBusinessAccountUsernameKt {
public static final fun setBusinessAccountUsername-_dB6Ko0 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/business/TransferBusinessAccountStarBalanceKt {
public static final fun transferBusinessAccountStarBalance-wC12z2M (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ljava/lang/String;ILkotlin/coroutines/Continuation;)Ljava/lang/Object;
}
public final class dev/inmo/tgbotapi/extensions/api/chat/ExportChatInviteLinkKt {
public static final fun exportChatInviteLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static final fun exportChatInviteLink (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/chat/PublicChat;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -1089,12 +1140,12 @@ public final class dev/inmo/tgbotapi/extensions/api/gifts/GetAvailableGiftsKt {
}
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$Regular;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$Regular;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 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 static final fun sendGift-VjR9mJc (Ldev/inmo/tgbotapi/bot/RequestsExecutor;JLdev/inmo/tgbotapi/types/gifts/Gift$Regular;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$Regular;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 {
@@ -1109,10 +1160,10 @@ public final class dev/inmo/tgbotapi/extensions/api/gifts/SendGiftKt {
}
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 (Ldev/inmo/tgbotapi/bot/RequestsExecutor;Ldev/inmo/tgbotapi/types/ChatIdentifier;Ldev/inmo/tgbotapi/types/gifts/Gift$Regular;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$Regular;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$Regular;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$Regular;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;
}

View File

@@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.extensions.api.business
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.business_connection.DeleteBusinessMessages
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
@GenerateVariations
public suspend fun TelegramBot.deleteBusinessMessages(
businessConnectionId: BusinessConnectionId,
@GenerationVariant(List::class, "messages.map { it.messageId }", "messages", AccessibleMessage::class)
messageIds: List<MessageId>
): Boolean = execute(
DeleteBusinessMessages(businessConnectionId, messageIds)
)

View File

@@ -0,0 +1,16 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: DeleteBusinessMessages.kt
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import kotlin.Boolean
import kotlin.collections.List
public suspend fun TelegramBot.deleteBusinessMessages(businessConnectionId: BusinessConnectionId,
messages: List<AccessibleMessage>): Boolean = deleteBusinessMessages(
businessConnectionId = businessConnectionId, messageIds = with(messages) {messages.map {
it.messageId }}
)

View File

@@ -0,0 +1,12 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.GetBusinessAccountStarBalance
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
public suspend fun TelegramBot.getBusinessAccountStarBalance(
businessConnectionId: BusinessConnectionId
): StarAmount = execute(
GetBusinessAccountStarBalance(businessConnectionId)
)

View File

@@ -0,0 +1,27 @@
package dev.inmo.tgbotapi.extensions.api.business
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.business_connection.ReadBusinessMessage
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.toChatId
@GenerateVariations
public suspend fun TelegramBot.readBusinessMessage(
businessConnectionId: BusinessConnectionId,
@GenerationVariant(Chat::class, "chat.id.toChatId()", "chat")
chatId: ChatId,
messageId: MessageId
): Boolean = execute(
ReadBusinessMessage(businessConnectionId, chatId, messageId)
)
public suspend fun TelegramBot.readBusinessMessage(
businessConnectionId: BusinessConnectionId,
message: AccessibleMessage
): Boolean = readBusinessMessage(businessConnectionId, message.chat.id.toChatId(), message.messageId)

View File

@@ -0,0 +1,20 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: ReadBusinessMessage.kt
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.toChatId
import kotlin.Boolean
public suspend fun TelegramBot.readBusinessMessage(
businessConnectionId: BusinessConnectionId,
chat: Chat,
messageId: MessageId,
): Boolean = readBusinessMessage(
businessConnectionId = businessConnectionId, chatId = with(chat) {chat.id.toChatId()}, messageId
= messageId
)

View File

@@ -0,0 +1,11 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.RemoveBusinessAccountProfilePhoto
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.removeBusinessAccountProfilePhoto(
businessConnectionId: BusinessConnectionId
): Boolean = execute(
RemoveBusinessAccountProfilePhoto(businessConnectionId)
)

View File

@@ -0,0 +1,12 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountBio
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.setBusinessAccountBio(
businessConnectionId: BusinessConnectionId,
bio: String
): Boolean = execute(
SetBusinessAccountBio(businessConnectionId, bio)
)

View File

@@ -0,0 +1,13 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountName
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.setBusinessAccountName(
businessConnectionId: BusinessConnectionId,
firstName: String,
lastName: String? = null
): Boolean = execute(
SetBusinessAccountName(businessConnectionId, firstName, lastName)
)

View File

@@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.InputProfilePhoto
import dev.inmo.tgbotapi.requests.business_connection.SetBusinessAccountProfilePhoto
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
public suspend fun TelegramBot.setBusinessAccountProfilePhoto(
businessConnectionId: BusinessConnectionId,
photo: InputProfilePhoto,
isPublic: Boolean = false
): Boolean = execute(
SetBusinessAccountProfilePhoto(businessConnectionId, photo, isPublic)
)

View File

@@ -0,0 +1,17 @@
package dev.inmo.tgbotapi.extensions.api.business
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.business_connection.SetBusinessAccountUsername
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.Username
@GenerateVariations
public suspend fun TelegramBot.setBusinessAccountUsername(
businessConnectionId: BusinessConnectionId,
@GenerationVariant(String::class, "Username(username)", "username")
username: Username
): Boolean = execute(
SetBusinessAccountUsername(businessConnectionId, username)
)

View File

@@ -0,0 +1,16 @@
// THIS CODE HAVE BEEN GENERATED AUTOMATICALLY
// TO REGENERATE IT JUST DELETE FILE
// ORIGINAL FILE: SetBusinessAccountUsername.kt
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import kotlin.Boolean
import kotlin.String
public suspend
fun TelegramBot.setBusinessAccountUsername(businessConnectionId: BusinessConnectionId,
username: String): Boolean = setBusinessAccountUsername(
businessConnectionId = businessConnectionId, username = with(username) { Username(username) }
)

View File

@@ -0,0 +1,13 @@
package dev.inmo.tgbotapi.extensions.api.business
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.business_connection.TransferBusinessAccountStarBalance
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
public suspend fun TelegramBot.transferBusinessAccountStarBalance(
businessConnectionId: BusinessConnectionId,
amount: Int
): Boolean = execute(
TransferBusinessAccountStarBalance(businessConnectionId, amount)
)

View File

@@ -22,7 +22,7 @@ public suspend fun TelegramBot.sendGift(
)
userId: UserId,
@GenerationVariant(
Gift::class,
Gift.Regular::class,
"id",
"gift"
)
@@ -49,7 +49,7 @@ public suspend fun TelegramBot.sendGiftToChat(
)
chatId: ChatIdentifier,
@GenerationVariant(
Gift::class,
Gift.Regular::class,
"id",
"gift"
)
@@ -76,7 +76,7 @@ public suspend fun TelegramBot.sendGift(
)
userId: UserId,
@GenerationVariant(
Gift::class,
Gift.Regular::class,
"id",
"gift"
)
@@ -101,7 +101,7 @@ public suspend fun TelegramBot.sendGiftToChat(
)
chatId: ChatIdentifier,
@GenerationVariant(
Gift::class,
Gift.Regular::class,
"id",
"gift"
)

View File

@@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGift(
public suspend fun TelegramBot.sendGift(
userId: UserId,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
): Boolean = sendGift(
@@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGift(
public suspend fun TelegramBot.sendGift(
userId: UserId,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
@@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGift(
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
): Boolean = sendGift(
@@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGift(
public suspend fun TelegramBot.sendGift(
user: User,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,

View File

@@ -34,7 +34,7 @@ public suspend fun TelegramBot.sendGiftToChat(
public suspend fun TelegramBot.sendGiftToChat(
chatId: ChatIdentifier,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
): Boolean = sendGiftToChat(
@@ -43,7 +43,7 @@ public suspend fun TelegramBot.sendGiftToChat(
public suspend fun TelegramBot.sendGiftToChat(
chatId: ChatIdentifier,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,
@@ -54,7 +54,7 @@ public suspend fun TelegramBot.sendGiftToChat(
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
): Boolean = sendGiftToChat(
@@ -63,7 +63,7 @@ public suspend fun TelegramBot.sendGiftToChat(
public suspend fun TelegramBot.sendGiftToChat(
chat: PublicChat,
gift: Gift,
gift: Gift.Regular,
text: String,
parseMode: ParseMode?,
upgradableToUnique: Boolean,

View File

@@ -654,6 +654,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
public static synthetic fun waitNewChatPhotoEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitNewChatTitleEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitNewChatTitleEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPaidMessagePriceChanged (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPinnedMessageEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitPinnedMessageEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPrivateEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -664,12 +666,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
public static synthetic fun waitPublicChatEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitRefundedPaymentEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitRefundedPaymentEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitRegularGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitRegularGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSuccessfulPaymentEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSuccessfulPaymentEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSupergroupChatCreatedEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSupergroupChatCreatedEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSupergroupEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSupergroupEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUniqueGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitUniqueGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUserLoggedInEvents (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitUserLoggedInEvents$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUserShared (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -743,6 +749,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
public static synthetic fun waitNewChatPhotoEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitNewChatTitleEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitNewChatTitleEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPaidMessagePriceChangedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitPaidMessagePriceChangedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPinnedMessageEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitPinnedMessageEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitPrivateEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -753,12 +761,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/expectations/W
public static synthetic fun waitPublicChatEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitRefundedPaymentEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitRefundedPaymentEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitRegularGiftSentOrReceivedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitRegularGiftSentOrReceivedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSuccessfulPaymentEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSuccessfulPaymentEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSupergroupChatCreatedEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSupergroupChatCreatedEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitSupergroupEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitSupergroupEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUniqueGiftSentOrReceivedMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitUniqueGiftSentOrReceivedMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUserLoggedInEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun waitUserLoggedInEventsMessages$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun waitUserSharedEventsMessages (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -1348,6 +1360,8 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl
public static synthetic fun onNewChatPhoto$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onNewChatTitle (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onNewChatTitle$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onPaidMessagePriceChanged (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onPaidMessagePriceChanged$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onPinnedMessage (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onPinnedMessage$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onPrivateEvent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
@@ -1358,12 +1372,16 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/triggers_handl
public static synthetic fun onPublicChatEvent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onRefundedPayment (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onRefundedPayment$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onRegularGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onRegularGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onSuccessfulPayment (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onSuccessfulPayment$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onSupergroupChatCreated (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onSupergroupChatCreated$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onSupergroupEvent (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onSupergroupEvent$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onUniqueGiftSentOrReceived (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onUniqueGiftSentOrReceived$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onUserLoggedIn (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public static synthetic fun onUserLoggedIn$default (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
public static final fun onUserShared (Ldev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Lkotlin/jvm/functions/Function4;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/marker_factories/MarkerFactory;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function3;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;

View File

@@ -5,10 +5,11 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
import dev.inmo.tgbotapi.types.chat.ChatBackground
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
@@ -248,3 +249,18 @@ suspend fun BehaviourContext.waitGiveawayCompletedWithPrivateWinners(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitGiveawayCompleted(initRequest, errorFactory)
suspend fun BehaviourContext.waitPaidMessagePriceChanged(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<PaidMessagePriceChanged>(initRequest, errorFactory)
suspend fun BehaviourContext.waitRegularGiftSentOrReceived(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<GiftSentOrReceived.Regular>(initRequest, errorFactory)
suspend fun BehaviourContext.waitUniqueGiftSentOrReceived(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<GiftSentOrReceived.Unique>(initRequest, errorFactory)

View File

@@ -5,7 +5,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
import dev.inmo.tgbotapi.types.chat.ChatBackground
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
@@ -224,3 +226,18 @@ suspend fun BehaviourContext.waitChatBackgroundSetEventsMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<ChatBackground>(initRequest, errorFactory)
suspend fun BehaviourContext.waitPaidMessagePriceChangedMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<PaidMessagePriceChanged>(initRequest, errorFactory)
suspend fun BehaviourContext.waitRegularGiftSentOrReceivedMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<GiftSentOrReceived.Regular>(initRequest, errorFactory)
suspend fun BehaviourContext.waitUniqueGiftSentOrReceivedMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<GiftSentOrReceived.Unique>(initRequest, errorFactory)

View File

@@ -10,10 +10,11 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.Mar
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
import dev.inmo.tgbotapi.types.chat.ChatBackground
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
import dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
@@ -1045,3 +1046,69 @@ suspend fun <BC : BehaviourContext> BC.onGiveawayCompletedWithPrivateWinners(
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiveawayPrivateResults>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiveawayPrivateResults>>
) = onGiveawayCompleted(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
* "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onPaidMessagePriceChanged(
initialFilter: SimpleFilter<ChatEventMessage<PaidMessagePriceChanged>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<PaidMessagePriceChanged>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<PaidMessagePriceChanged>, Any>? = ByChatMessageMarkerFactory,
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<PaidMessagePriceChanged>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<PaidMessagePriceChanged>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
* "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onRegularGiftSentOrReceived(
initialFilter: SimpleFilter<ChatEventMessage<GiftSentOrReceived.Regular>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<GiftSentOrReceived.Regular>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<GiftSentOrReceived.Regular>, Any>? = ByChatMessageMarkerFactory,
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiftSentOrReceived.Regular>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiftSentOrReceived.Regular>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] **Pass null to handle requests fully parallel**. Will be used to identify different "stream".
* [scenarioReceiver] will be called synchronously in one "stream". Output of [markerFactory] will be used as a key for
* "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onUniqueGiftSentOrReceived(
initialFilter: SimpleFilter<ChatEventMessage<GiftSentOrReceived.Unique>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<GiftSentOrReceived.Unique>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<GiftSentOrReceived.Unique>, Any>? = ByChatMessageMarkerFactory,
additionalSubcontextInitialAction: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, Update, ChatEventMessage<GiftSentOrReceived.Unique>>? = null,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<GiftSentOrReceived.Unique>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, additionalSubcontextInitialAction, scenarioReceiver)

File diff suppressed because it is too large Load Diff

View File

@@ -78,6 +78,6 @@ dependencies {
ksp {
arg("cctargetPackage", "dev.inmo.tgbotapi.extensions.utils")
arg("ccoutputFileName", "ClassCastsNew")
arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin").absolutePath)
arg("ccoutputFileName", "ClassCastsNew.kt")
arg("ccoutputFolder", project(":tgbotapi.utils").file("src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/utils").absolutePath)
}

View File

@@ -0,0 +1,13 @@
package dev.inmo.tgbotapi.requests.abstracts
import dev.inmo.tgbotapi.abstracts.types.WithBusinessConnectionId
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import kotlinx.serialization.json.JsonObject
interface BusinessRequest<T: Any> : Request<T>, WithBusinessConnectionId {
interface Simple<T : Any> : BusinessRequest<T>, SimpleRequest<T>
interface Multipart<T : Any> : BusinessRequest<T>, MultipartRequest.Common<T>, SimpleRequest<T> {
override val data: SimpleRequest<T>
get() = this
}
}

View File

@@ -0,0 +1,27 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.messageIdsField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class DeleteBusinessMessages(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(messageIdsField)
val messagesIds: List<MessageId>
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "deleteBusinessMessages"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,36 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.bioField
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class GetBusinessAccountStarBalance(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
) : BusinessRequest.Simple<StarAmount> {
override fun method(): String = "getBusinessAccountStarBalance"
override val resultDeserializer: DeserializationStrategy<StarAmount>
get() = StarAmount.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,62 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.types.DoubleSeconds
import dev.inmo.tgbotapi.types.Seconds
import dev.inmo.tgbotapi.types.StickerFormat
import dev.inmo.tgbotapi.types.animationField
import dev.inmo.tgbotapi.types.mainFrameTimestampField
import dev.inmo.tgbotapi.types.photoField
import dev.inmo.tgbotapi.utils.deserializeWithRaw
import kotlinx.serialization.EncodeDefault
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonObject
@Serializable
sealed interface InputProfilePhoto {
val type: String
val mediaPair: Pair<String, MultipartFile>
@Serializable
data class Static(
@SerialName(photoField)
val photo: MultipartFile
) : InputProfilePhoto {
override val mediaPair: Pair<String, MultipartFile>
get() = photoField to photo
@EncodeDefault
override val type: String = "static"
}
@Serializable
data class Animated(
@SerialName(animationField)
val animation: MultipartFile,
@SerialName(mainFrameTimestampField)
val mainFrameTimestamp: DoubleSeconds? = null
) : InputProfilePhoto {
override val mediaPair: Pair<String, MultipartFile>
get() = animationField to animation
@EncodeDefault
override val type: String = "animated"
}
companion object : KSerializer<InputProfilePhoto> {
override val descriptor: SerialDescriptor
get() = JsonObject.serializer().descriptor
override fun deserialize(decoder: Decoder): InputProfilePhoto {
error("Deserialization is not supported yet")
}
override fun serialize(encoder: Encoder, value: InputProfilePhoto) {
when (value) {
is Animated -> Animated.serializer().serialize(encoder, value)
is Static -> Static.serializer().serialize(encoder, value)
}
}
}
}

View File

@@ -0,0 +1,33 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class ReadBusinessMessage(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(chatIdField)
val chatId: ChatId,
@SerialName(messageIdField)
val messageId: MessageId
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "readBusinessMessage"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,39 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.isPublicField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.photoField
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class RemoveBusinessAccountProfilePhoto(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(isPublicField)
val isPublic: Boolean = false
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "removeBusinessAccountProfilePhoto"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,37 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.bioField
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class SetBusinessAccountBio(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(bioField)
val bio: String
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "setBusinessAccountBio"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,36 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class SetBusinessAccountName(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(firstNameField)
val firstName: String,
@SerialName(lastNameField)
val lastName: String? = null
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "setBusinessAccountName"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,45 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.isPublicField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.photoField
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class SetBusinessAccountProfilePhoto(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(photoField)
val photo: InputProfilePhoto,
@SerialName(isPublicField)
val isPublic: Boolean = false
) : BusinessRequest.Multipart<Boolean> {
override fun method(): String = "setBusinessAccountProfilePhoto"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val mediaMap: Map<String, MultipartFile> = mapOf(
photo.mediaPair
)
}

View File

@@ -0,0 +1,36 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class SetBusinessAccountUsername(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(usernameField)
val username: Username
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "setBusinessAccountUsername"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -0,0 +1,39 @@
package dev.inmo.tgbotapi.requests.business_connection
import dev.inmo.tgbotapi.requests.abstracts.BusinessRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.bioField
import dev.inmo.tgbotapi.types.businessConnectionIdField
import dev.inmo.tgbotapi.types.business_connection.BusinessConnectionId
import dev.inmo.tgbotapi.types.chatIdField
import dev.inmo.tgbotapi.types.firstNameField
import dev.inmo.tgbotapi.types.lastNameField
import dev.inmo.tgbotapi.types.message.RawMessage
import dev.inmo.tgbotapi.types.messageIdField
import dev.inmo.tgbotapi.types.messageIdsField
import dev.inmo.tgbotapi.types.payments.stars.StarAmount
import dev.inmo.tgbotapi.types.starCountField
import dev.inmo.tgbotapi.types.usernameField
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationStrategy
import kotlinx.serialization.builtins.serializer
@Serializable
data class TransferBusinessAccountStarBalance(
@SerialName(businessConnectionIdField)
override val businessConnectionId: BusinessConnectionId,
@SerialName(starCountField)
val starCount: Int
) : BusinessRequest.Simple<Boolean> {
override fun method(): String = "transferBusinessAccountStars"
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.utils.BuiltinMimeTypes
import kotlinx.serialization.Serializable
import kotlin.jvm.JvmInline
typealias ForwardSignature = String
typealias ForwardSenderName = String
typealias AuthorSignature = ForwardSignature
@@ -19,6 +20,7 @@ typealias GooglePlaceType = String
typealias MembersLimit = Int
typealias Seconds = Int
typealias DoubleSeconds = Double
typealias MilliSeconds = Long
typealias LongSeconds = Long
typealias UnixTimeStamp = LongSeconds
@@ -186,6 +188,19 @@ const val hasMainWebAppField = "has_main_web_app"
const val canJoinGroupsField = "can_join_groups"
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
const val canReplyField = "can_reply"
const val canReadMessagesField = "can_read_messages"
const val canDeleteOutgoingMessagesField = "can_delete_outgoing_messages"
const val canDeleteAllMessagesField = "can_delete_all_messages"
const val canEditNameField = "can_edit_name"
const val canEditBioField = "can_edit_bio"
const val canEditProfilePhotoField = "can_edit_profile_photo"
const val canEditUsernameField = "can_edit_username"
const val canChangeGiftSettingsField = "can_change_gift_settings"
const val canViewGiftsAndStarsField = "can_view_gifts_and_stars"
const val canConvertGiftsToStarsField = "can_convert_gifts_to_stars"
const val canTransferAndUpgradeGiftsField = "can_transfer_and_upgrade_gifts"
const val canTransferStarsField = "can_transfer_stars"
const val canManageStoriesField = "can_manage_stories"
const val supportInlineQueriesField = "supports_inline_queries"
const val canConnectToBusinessField = "can_connect_to_business"
const val textEntitiesField = "text_entities"
@@ -494,8 +509,19 @@ const val creatorField = "creator"
const val subscriptionPeriodField = "subscription_period"
const val subscriptionPriceField = "subscription_price"
const val copyTextField = "copy_text"
const val isPublicField = "is_public"
const val giftField = "gift"
const val giftsField = "gifts"
const val rarityPerMilleField = "rarity_per_mille"
const val acceptedGiftTypesField = "accepted_gift_types"
const val ownedGiftIdField = "owned_gift_id"
const val convertStarCountField = "convert_star_count"
const val prepaidUpgradeStarCountField = "prepaid_upgrade_star_count"
const val canBeUpgradedField = "can_be_upgraded"
const val isPrivateField = "is_private"
const val transferStarCountField = "transfer_star_count"
const val pointField = "point"
const val xShiftField = "x_shift"
@@ -589,6 +615,11 @@ const val voiceField = "voice"
const val videoNoteField = "video_note"
const val mediaField = "media"
const val mainFrameTimestampField = "main_frame_timestamp"
const val paidMessageStarCountField = "paid_message_star_count"
const val paidStarCountField = "paid_star_count"
const val disableEditMessageField = "disable_edit_message"
const val scoreField = "score"
const val forceField = "force"
@@ -667,6 +698,22 @@ const val upgradeStarCountField = "upgrade_star_count"
const val payToUpgradeField = "pay_for_upgrade"
const val paidMediaField = "paid_media"
const val centerColorField = "center_color"
const val edgeColorField = "edge_color"
const val symbolColorField = "symbol_color"
const val textColorField = "text_color"
const val baseNameField = "base_name"
const val numberField = "number"
const val modelField = "model"
const val symbolField = "symbol"
const val backdropField = "backdrop"
const val unlimitedGiftsField = "unlimited_gifts"
const val limitedGiftsField = "limited_gifts"
const val uniqueGiftsField = "unique_gifts"
const val premiumSubscriptionField = "premium_subscription"
const val businessConnectionIdField = "business_connection_id"
const val businessIntroField = "business_intro"
const val businessLocationField = "business_location"

View File

@@ -0,0 +1,11 @@
package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class PaidMessagePriceChanged(
@SerialName(paidMessageStarCountField)
val cost: Int
) : CommonEvent

View File

@@ -0,0 +1,50 @@
package dev.inmo.tgbotapi.types.business_connection
import dev.inmo.tgbotapi.types.canChangeGiftSettingsField
import dev.inmo.tgbotapi.types.canConvertGiftsToStarsField
import dev.inmo.tgbotapi.types.canDeleteAllMessagesField
import dev.inmo.tgbotapi.types.canDeleteOutgoingMessagesField
import dev.inmo.tgbotapi.types.canEditBioField
import dev.inmo.tgbotapi.types.canEditNameField
import dev.inmo.tgbotapi.types.canEditProfilePhotoField
import dev.inmo.tgbotapi.types.canEditUsernameField
import dev.inmo.tgbotapi.types.canManageStoriesField
import dev.inmo.tgbotapi.types.canReadMessagesField
import dev.inmo.tgbotapi.types.canReplyField
import dev.inmo.tgbotapi.types.canTransferAndUpgradeGiftsField
import dev.inmo.tgbotapi.types.canTransferStarsField
import dev.inmo.tgbotapi.types.canViewGiftsAndStarsField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class BusinessBotRights(
@SerialName(canReplyField)
val canReply: Boolean = false,
@SerialName(canReadMessagesField)
val canMarkMessagesAsRead: Boolean = false,
@SerialName(canDeleteOutgoingMessagesField)
val canDeleteOutgoingMessages: Boolean = false,
@SerialName(canDeleteAllMessagesField)
val canDeleteAllMessages: Boolean = false,
@SerialName(canEditNameField)
val canEditName: Boolean = false,
@SerialName(canEditBioField)
val canEditBio: Boolean = false,
@SerialName(canEditProfilePhotoField)
val canEditProfilePhoto: Boolean = false,
@SerialName(canEditUsernameField)
val canEditUsername: Boolean = false,
@SerialName(canChangeGiftSettingsField)
val canChangeGiftSettings: Boolean = false,
@SerialName(canViewGiftsAndStarsField)
val canViewGiftsAndStars: Boolean = false,
@SerialName(canConvertGiftsToStarsField)
val canConvertGiftsToStars: Boolean = false,
@SerialName(canTransferAndUpgradeGiftsField)
val canTransferAndUpgradeGifts: Boolean = false,
@SerialName(canTransferStarsField)
val canTransferStars: Boolean = false,
@SerialName(canManageStoriesField)
val canManageStories: Boolean = false,
)

View File

@@ -16,7 +16,9 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
val user: PreviewUser
val userChatId: ChatId
val date: TelegramDate
val rights: BusinessBotRights
val canReply: Boolean
get() = rights.canReply
val isEnabled: Boolean
override val businessConnectionId: BusinessConnectionId
@@ -32,8 +34,8 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
override val userChatId: ChatId,
@SerialName(dateField)
override val date: TelegramDate,
@SerialName(canReplyField)
override val canReply: Boolean,
@SerialName(rightsField)
override val rights: BusinessBotRights = BusinessBotRights(),
) : BusinessConnection {
@EncodeDefault
override val isEnabled: Boolean = true
@@ -49,8 +51,8 @@ sealed interface BusinessConnection : WithBusinessConnectionId {
override val userChatId: ChatId,
@SerialName(dateField)
override val date: TelegramDate,
@SerialName(canReplyField)
override val canReply: Boolean,
@SerialName(rightsField)
override val rights: BusinessBotRights = BusinessBotRights(),
) : BusinessConnection {
@EncodeDefault
override val isEnabled: Boolean = false

View File

@@ -15,8 +15,8 @@ internal data class RawBusinessConnection(
val userChatId: ChatId,
@SerialName(dateField)
val date: TelegramDate,
@SerialName(canReplyField)
val canReply: Boolean,
@SerialName(rightsField)
val rights: BusinessBotRights = BusinessBotRights(),
@SerialName(isEnabledField)
val isEnabled: Boolean
) {
@@ -27,14 +27,14 @@ internal data class RawBusinessConnection(
user = user,
userChatId = userChatId,
date = date,
canReply = canReply
rights = rights
)
false -> BusinessConnection.Disabled(
id = id,
user = user,
userChatId = userChatId,
date = date,
canReply = canReply
rights = rights
)
}
@@ -43,7 +43,7 @@ internal data class RawBusinessConnection(
user = businessConnection.user,
userChatId = businessConnection.userChatId,
date = businessConnection.date,
canReply = businessConnection.canReply,
rights = businessConnection.rights,
isEnabled = businessConnection.isEnabled,
)
}

View File

@@ -5,11 +5,11 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
import dev.inmo.tgbotapi.types.colors.ColorId
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
import dev.inmo.tgbotapi.types.reactions.Reaction
import dev.inmo.tgbotapi.utils.RiskFeature
import korlibs.time.DateTime
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject
@@ -21,6 +21,8 @@ data class ExtendedChannelChatImpl(
override val id: ChatId,
@SerialName(titleField)
override val title: String,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes,
@SerialName(usernameField)
override val username: Username? = null,
@SerialName(activeUsernamesField)
@@ -57,9 +59,7 @@ data class ExtendedChannelChatImpl(
@SerialName(hasVisibleHistoryField)
override val newMembersSeeHistory: Boolean = false,
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
override val maxReactionsCount: Int = 3
) : ExtendedChannelChat
@Serializable
@@ -100,8 +100,8 @@ data class ExtendedGroupChatImpl(
override val newMembersSeeHistory: Boolean = false,
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
) : ExtendedGroupChat
@Serializable
@@ -150,8 +150,8 @@ data class ExtendedPrivateChatImpl(
override val personalChat: PreviewChannelChat? = null,
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
) : ExtendedPrivateChat
typealias ExtendedUser = ExtendedPrivateChatImpl
@@ -218,8 +218,8 @@ data class ExtendedSupergroupChatImpl(
override val customEmojiStickerSetName: StickerSetName? = null,
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
) : ExtendedSupergroupChat
@Serializable
@@ -284,8 +284,8 @@ data class ExtendedForumChatImpl(
override val customEmojiStickerSetName: StickerSetName? = null,
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
) : ExtendedForumChat
@Serializable
@@ -320,8 +320,8 @@ data class ExtendedBot(
override val maxReactionsCount: Int = 3,
@SerialName(hasMainWebAppField)
val hasMainWebApp: Boolean = false,
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false,
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes(),
) : Bot(), ExtendedChat {
@SerialName(isBotField)
private val isBot = true
@@ -351,6 +351,6 @@ data class UnknownExtendedChat(
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null
@SerialName(maxReactionCountField)
override val maxReactionsCount: Int = 3
@SerialName(canSendGiftsField)
override val canReceiveGifts: Boolean = false
@SerialName(acceptedGiftTypesField)
override val acceptedGiftTypes: AcceptedGiftTypes = AcceptedGiftTypes()
}

View File

@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.business_connection.BusinessIntro
import dev.inmo.tgbotapi.types.business_connection.BusinessLocation
import dev.inmo.tgbotapi.types.business_connection.BusinessOpeningHours
import dev.inmo.tgbotapi.types.colors.ColorId
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.gifts.AcceptedGiftTypes
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
import dev.inmo.tgbotapi.types.reactions.Reaction
@@ -20,10 +20,18 @@ sealed interface ExtendedChat : Chat {
val profileBackgroundCustomEmojiId: CustomEmojiId?
val maxReactionsCount: Int
/**
* Represent `can_send_gifts` field
*/
val acceptedGiftTypes: AcceptedGiftTypes
@Deprecated(
message = "Telegram Bot API v9.0 introduced the new field, `acceptedGiftTypes`, to allow granular" +
" control over which types of gifts user, bot, or chat can accept.",
replaceWith = ReplaceWith("acceptedGiftTypes.uniqueGifts || acceptedGiftTypes.unlimitedGifts || acceptedGiftTypes.limitedGifts || acceptedGiftTypes.premiumSubscription")
)
val canReceiveGifts: Boolean
get() = acceptedGiftTypes.uniqueGifts ||
acceptedGiftTypes.unlimitedGifts ||
acceptedGiftTypes.limitedGifts ||
acceptedGiftTypes.premiumSubscription
}
@Serializable(ExtendedChatSerializer.Companion::class)
@@ -63,6 +71,7 @@ sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, Ex
sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotChat {
val description: String
val inviteLink: String?
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
val pinnedMessage: Message?
val membersHidden: Boolean

View File

@@ -0,0 +1,21 @@
package dev.inmo.tgbotapi.types.gifts
import dev.inmo.tgbotapi.types.limitedGiftsField
import dev.inmo.tgbotapi.types.premiumSubscriptionField
import dev.inmo.tgbotapi.types.uniqueGiftsField
import dev.inmo.tgbotapi.types.unlimitedGiftsField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class AcceptedGiftTypes(
@SerialName(unlimitedGiftsField)
val unlimitedGifts: Boolean = false,
@SerialName(limitedGiftsField)
val limitedGifts: Boolean = false,
@SerialName(uniqueGiftsField)
val uniqueGifts: Boolean = false,
@SerialName(premiumSubscriptionField)
val premiumSubscription: Boolean = false
)

View File

@@ -2,6 +2,9 @@ package dev.inmo.tgbotapi.types.gifts
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftBackdrop
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftModel
import dev.inmo.tgbotapi.types.gifts.unique.UniqueGiftSymbol
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@@ -11,6 +14,8 @@ import kotlinx.serialization.encoding.Encoder
@Serializable(Gift.Companion::class)
sealed interface Gift {
@Serializable(Regular.Companion::class)
sealed interface Regular : Gift {
val id: GiftId
val sticker: Sticker
val starCount: Int
@@ -28,7 +33,7 @@ sealed interface Gift {
override val starCount: Int,
@SerialName(upgradeStarCountField)
override val upgradeStarCount: Int? = null
) : Gift {
) : Regular {
override val totalCount: Int?
get() = null
override val remainingCount: Int?
@@ -49,11 +54,12 @@ sealed interface Gift {
override val remainingCount: Int,
@SerialName(upgradeStarCountField)
override val upgradeStarCount: Int? = null,
) : Gift
) : Regular
companion object : KSerializer<Gift> {
companion object : KSerializer<Regular> {
@Serializable
private data class GiftSurrogate(
@Suppress("propertyName")
private data class RegularGiftSurrogate(
val id: GiftId,
val sticker: Sticker,
val star_count: Int,
@@ -63,10 +69,10 @@ sealed interface Gift {
)
override val descriptor: SerialDescriptor
get() = GiftSurrogate.serializer().descriptor
get() = RegularGiftSurrogate.serializer().descriptor
override fun deserialize(decoder: Decoder): Gift {
val surrogate = GiftSurrogate.serializer().deserialize(decoder)
override fun deserialize(decoder: Decoder): Regular {
val surrogate = RegularGiftSurrogate.serializer().deserialize(decoder)
return if (surrogate.total_count != null && surrogate.remaining_count != null) {
Limited(
@@ -87,8 +93,8 @@ sealed interface Gift {
}
}
override fun serialize(encoder: Encoder, value: Gift) {
val surrogate = GiftSurrogate(
override fun serialize(encoder: Encoder, value: Regular) {
val surrogate = RegularGiftSurrogate(
id = value.id,
sticker = value.sticker,
star_count = value.starCount,
@@ -96,6 +102,85 @@ sealed interface Gift {
remaining_count = value.remainingCount,
upgrade_star_count = value.upgradeStarCount
)
RegularGiftSurrogate.serializer().serialize(encoder, surrogate)
}
}
}
@Serializable
data class Unique(
@SerialName(baseNameField)
val baseName: String,
@SerialName(nameField)
val name: String,
@SerialName(numberField)
val number: Int,
@SerialName(modelField)
val model: UniqueGiftModel,
@SerialName(symbolField)
val symbol: UniqueGiftSymbol,
@SerialName(backdropField)
val backdrop: UniqueGiftBackdrop
) : Gift
companion object : KSerializer<Gift> {
@Serializable
@Suppress("unused", "propertyName")
private class GiftSurrogate(
// regular gift fields
val id: GiftId?,
val sticker: Sticker?,
val star_count: Int?,
val total_count: Int? = null,
val remaining_count: Int? = null,
val upgrade_star_count: Int? = null,
// unique gift fields
val base_name: String? = null,
val name: String? = null,
val number: Int? = null,
val model: UniqueGiftModel? = null,
val symbol: UniqueGiftSymbol? = null,
val backdrop: UniqueGiftBackdrop? = null,
)
override val descriptor: SerialDescriptor
get() = GiftSurrogate.serializer().descriptor
override fun deserialize(decoder: Decoder): Gift {
val surrogate = GiftSurrogate.serializer().deserialize(decoder)
return if (surrogate.base_name != null && surrogate.name != null && surrogate.number != null && surrogate.model != null && surrogate.symbol != null && surrogate.backdrop != null) {
Unique(
baseName = surrogate.base_name,
name = surrogate.name,
number = surrogate.number,
model = surrogate.model,
symbol = surrogate.symbol,
backdrop = surrogate.backdrop,
)
} else {
decoder.decodeSerializableValue(Regular.serializer())
}
}
override fun serialize(
encoder: Encoder,
value: Gift
) {
val surrogate = GiftSurrogate(
id = (value as? Regular)?.id,
sticker = (value as? Regular)?.sticker,
star_count = (value as? Regular)?.starCount,
total_count = (value as? Regular.Limited)?.totalCount,
remaining_count = (value as? Regular.Limited)?.remainingCount,
upgrade_star_count = (value as? Regular)?.upgradeStarCount,
base_name = (value as? Unique)?.baseName,
name = (value as? Unique)?.name,
number = (value as? Unique)?.number,
model = (value as? Unique)?.model,
symbol = (value as? Unique)?.symbol,
backdrop = (value as? Unique)?.backdrop,
)
GiftSurrogate.serializer().serialize(encoder, surrogate)
}
}

View File

@@ -0,0 +1,286 @@
package dev.inmo.tgbotapi.types.gifts
import dev.inmo.tgbotapi.abstracts.TextedInput
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.RawMessageEntities
import dev.inmo.tgbotapi.types.message.asTextSources
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlin.jvm.JvmName
/**
* Represent Telegram Bots API abstraction [GiftInfo](https://core.telegram.org/bots/api#giftinfo) and
* [UniqueGiftInfo](https://core.telegram.org/bots/api#uniquegiftinfo)
*
* @see ReceivedInBusinessAccount
* @see Regular.Common
* @see Regular.ReceivedInBusinessAccount
* @see Unique.Common
* @see Unique.ReceivedInBusinessAccount
*/
@Serializable
sealed interface GiftSentOrReceived : CommonEvent {
val ownedGiftId: GiftId?
val gift: Gift
@Serializable
sealed interface ReceivedInBusinessAccount : GiftSentOrReceived {
override val ownedGiftId: GiftId
}
@Serializable(Regular.Companion::class)
sealed interface Regular : GiftSentOrReceived, TextedInput {
override val gift: Gift.Regular
val convertStarCount: Int?
val prepaidUpgradeStarCount: Int?
val canBeUpgraded: Boolean
val isPrivate: Boolean
@Serializable
data class Common(
@SerialName(giftField)
override val gift: Gift.Regular,
@SerialName(convertStarCountField)
override val convertStarCount: Int? = null,
@SerialName(prepaidUpgradeStarCountField)
override val prepaidUpgradeStarCount: Int? = null,
@SerialName(canBeUpgradedField)
override val canBeUpgraded: Boolean = false,
@SerialName(textField)
override val text: String? = null,
@SerialName(entitiesField)
private val entities: RawMessageEntities? = null,
@SerialName(isPrivateField)
override val isPrivate: Boolean = false
) : Regular {
override val textSources: List<TextSource> by lazy {
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
}
override val ownedGiftId: GiftId?
get() = null
}
@Serializable
data class ReceivedInBusinessAccount(
@SerialName(giftField)
override val gift: Gift.Regular,
@SerialName(ownedGiftIdField)
override val ownedGiftId: GiftId,
@SerialName(convertStarCountField)
override val convertStarCount: Int? = null,
@SerialName(prepaidUpgradeStarCountField)
override val prepaidUpgradeStarCount: Int? = null,
@SerialName(canBeUpgradedField)
override val canBeUpgraded: Boolean = false,
@SerialName(textField)
override val text: String? = null,
@SerialName(entitiesField)
private val entities: RawMessageEntities? = null,
@SerialName(isPrivateField)
override val isPrivate: Boolean = false
) : Regular, GiftSentOrReceived.ReceivedInBusinessAccount {
override val textSources: List<TextSource> by lazy {
entities ?.asTextSources(text ?: return@lazy emptyList()) ?: emptyList()
}
}
companion object : KSerializer<GiftSentOrReceived.Regular> {
@Serializable
private data class Surrogate(
@SerialName(giftField)
val gift: Gift.Regular,
@SerialName(ownedGiftIdField)
val ownedGiftId: GiftId? = null,
@SerialName(convertStarCountField)
val convertStarCount: Int? = null,
@SerialName(prepaidUpgradeStarCountField)
val prepaidUpgradeStarCount: Int? = null,
@SerialName(canBeUpgradedField)
val canBeUpgraded: Boolean = false,
@SerialName(textField)
val text: String? = null,
@SerialName(entitiesField)
val entities: RawMessageEntities? = null,
@SerialName(isPrivateField)
val isPrivate: Boolean = false
)
override val descriptor: SerialDescriptor
get() = Surrogate.serializer().descriptor
override fun serialize(encoder: Encoder, value: Regular) {
when (value) {
is Common -> Common.serializer().serialize(encoder, value)
is ReceivedInBusinessAccount -> ReceivedInBusinessAccount.serializer().serialize(encoder, value)
}
}
override fun deserialize(decoder: Decoder): Regular {
val surrogate = Surrogate.serializer().deserialize(decoder)
return when {
surrogate.ownedGiftId == null -> {
Common(
gift = surrogate.gift,
convertStarCount = surrogate.convertStarCount,
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
canBeUpgraded = surrogate.canBeUpgraded,
text = surrogate.text,
entities = surrogate.entities,
isPrivate = surrogate.isPrivate
)
}
else -> {
ReceivedInBusinessAccount(
gift = surrogate.gift,
ownedGiftId = surrogate.ownedGiftId,
convertStarCount = surrogate.convertStarCount,
prepaidUpgradeStarCount = surrogate.prepaidUpgradeStarCount,
canBeUpgraded = surrogate.canBeUpgraded,
text = surrogate.text,
entities = surrogate.entities,
isPrivate = surrogate.isPrivate
)
}
}
}
@JvmName("PublicConstructor")
operator fun invoke(
gift: Gift.Regular,
ownedGiftId: GiftId? = null,
convertStarCount: Int? = null,
prepaidUpgradeStarCount: Int? = null,
canBeUpgraded: Boolean = false,
text: String? = null,
textSources: TextSourcesList = emptyList(),
position: Int,
isPrivate: Boolean = false
) = ownedGiftId ?.let {
ReceivedInBusinessAccount(
gift,
ownedGiftId,
convertStarCount,
prepaidUpgradeStarCount,
canBeUpgraded,
text,
textSources.toRawMessageEntities(position),
isPrivate
)
} ?: Common(
gift,
convertStarCount,
prepaidUpgradeStarCount,
canBeUpgraded,
text,
textSources.toRawMessageEntities(position),
isPrivate
)
}
}
@Serializable(Unique.Companion::class)
sealed interface Unique : GiftSentOrReceived {
override val gift: Gift.Unique
val origin: String?
val transferStarCount: Int?
@Serializable
data class Common(
@SerialName(giftField)
override val gift: Gift.Unique,
@SerialName(originField)
override val origin: String? = null,
@SerialName(transferStarCountField)
override val transferStarCount: Int? = null
) : Unique {
override val ownedGiftId: GiftId?
get() = null
}
@Serializable
data class ReceivedInBusinessAccount(
@SerialName(giftField)
override val gift: Gift.Unique,
@SerialName(ownedGiftIdField)
override val ownedGiftId: GiftId,
@SerialName(originField)
override val origin: String? = null,
@SerialName(transferStarCountField)
override val transferStarCount: Int? = null
) : Unique, GiftSentOrReceived.ReceivedInBusinessAccount
companion object : KSerializer<GiftSentOrReceived.Unique> {
@Serializable
private data class Surrogate(
@SerialName(giftField)
val gift: Gift.Unique,
@SerialName(ownedGiftIdField)
val ownedGiftId: GiftId? = null,
@SerialName(originField)
val origin: String? = null,
@SerialName(transferStarCountField)
val transferStarCount: Int? = null
)
override val descriptor: SerialDescriptor
get() = Surrogate.serializer().descriptor
override fun serialize(encoder: Encoder, value: Unique) {
when (value) {
is Common -> Common.serializer().serialize(encoder, value)
is ReceivedInBusinessAccount -> ReceivedInBusinessAccount.serializer().serialize(encoder, value)
}
}
override fun deserialize(decoder: Decoder): Unique {
val surrogate = Surrogate.serializer().deserialize(decoder)
return when {
surrogate.ownedGiftId == null -> {
Common(
gift = surrogate.gift,
origin = surrogate.origin,
transferStarCount = surrogate.transferStarCount
)
}
else -> {
ReceivedInBusinessAccount(
gift = surrogate.gift,
ownedGiftId = surrogate.ownedGiftId,
origin = surrogate.origin,
transferStarCount = surrogate.transferStarCount
)
}
}
}
@JvmName("PublicConstructor")
operator fun invoke(
gift: Gift.Unique,
origin: String? = null,
ownedGiftId: GiftId? = null,
transferStarCount: Int? = null
) = ownedGiftId ?.let {
ReceivedInBusinessAccount(
gift,
ownedGiftId,
origin,
transferStarCount,
)
} ?: Common(
gift,
origin,
transferStarCount,
)
}
}
}

View File

@@ -7,5 +7,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class Gifts(
@SerialName(giftsField)
val gifts: List<Gift>
val gifts: List<Gift.Regular>
)

View File

@@ -0,0 +1,18 @@
package dev.inmo.tgbotapi.types.gifts.unique
import dev.inmo.tgbotapi.types.colorsField
import dev.inmo.tgbotapi.types.nameField
import dev.inmo.tgbotapi.types.rarityPerMilleField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class UniqueGiftBackdrop(
@SerialName(nameField)
val name: String,
@SerialName(colorsField)
val colors: UniqueGiftBackdropColors,
@SerialName(rarityPerMilleField)
val rarityPerMille: Int
)

View File

@@ -0,0 +1,22 @@
package dev.inmo.tgbotapi.types.gifts.unique
import dev.inmo.tgbotapi.types.centerColorField
import dev.inmo.tgbotapi.types.edgeColorField
import dev.inmo.tgbotapi.types.symbolColorField
import dev.inmo.tgbotapi.types.textColorField
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class UniqueGiftBackdropColors(
@SerialName(centerColorField)
val centerColor: RGBColor,
@SerialName(edgeColorField)
val edgeColor: RGBColor,
@SerialName(symbolColorField)
val symbolColor: RGBColor,
@SerialName(textColorField)
val textColor: RGBColor
)

View File

@@ -0,0 +1,19 @@
package dev.inmo.tgbotapi.types.gifts.unique
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.nameField
import dev.inmo.tgbotapi.types.rarityPerMilleField
import dev.inmo.tgbotapi.types.stickerField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class UniqueGiftModel(
@SerialName(nameField)
val name: String,
@SerialName(stickerField)
val sticker: Sticker,
@SerialName(rarityPerMilleField)
val rarityPerMille: Int
)

View File

@@ -0,0 +1,19 @@
package dev.inmo.tgbotapi.types.gifts.unique
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.nameField
import dev.inmo.tgbotapi.types.rarityPerMilleField
import dev.inmo.tgbotapi.types.stickerField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class UniqueGiftSymbol(
@SerialName(nameField)
val name: String,
@SerialName(stickerField)
val sticker: Sticker,
@SerialName(rarityPerMilleField)
val rarityPerMille: Int
)

View File

@@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.BusinessContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent
import kotlinx.serialization.SerialName
data class BusinessContentMessageImpl<T: MessageContent>(
override val messageId: MessageId,
@@ -28,6 +29,8 @@ data class BusinessContentMessageImpl<T: MessageContent>(
override val mediaGroupId: MediaGroupId?,
override val senderBusinessBot: PreviewBot?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : BusinessContentMessage<T> {
constructor(
messageId: MessageId,

View File

@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MessageContent
import kotlinx.serialization.SerialName
data class ChannelContentMessageImpl<T: MessageContent>(
override val messageId: MessageId,
@@ -25,6 +26,8 @@ data class ChannelContentMessageImpl<T: MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : ChannelContentMessage<T> {
constructor(
messageId: MessageId,

View File

@@ -20,6 +20,7 @@ sealed interface ForwardInfo {
override val from: User
) : ForwardInfo, FromUser
@ClassCastsIncluded.ExcludeSubName
sealed interface PublicChat : ForwardInfo {
val chat: dev.inmo.tgbotapi.types.chat.PublicChat

View File

@@ -8,6 +8,7 @@ import dev.inmo.tgbotapi.types.chat.CommonBot
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MessageContent
import kotlinx.serialization.SerialName
data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
override val chat: PreviewGroupChat,
@@ -24,6 +25,8 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : ConnectedFromChannelGroupContentMessage<T> {
constructor(
@@ -41,8 +44,23 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
chat = chat,
channel = channel,
messageId = messageId,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
authorSignature = authorSignature,
mediaGroupId = mediaGroupId,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -61,6 +79,8 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : UnconnectedFromChannelGroupContentMessage<T> {
constructor(
chat: PreviewGroupChat,
@@ -77,8 +97,23 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, channel, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
chat = chat,
channel = channel,
messageId = messageId,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
authorSignature = authorSignature,
mediaGroupId = mediaGroupId,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -96,6 +131,8 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : AnonymousGroupContentMessage<T> {
constructor(
chat: PreviewGroupChat,
@@ -111,8 +148,22 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, messageId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
chat = chat,
messageId = messageId,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
authorSignature = authorSignature,
mediaGroupId = mediaGroupId,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -131,6 +182,8 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
override val mediaGroupId: MediaGroupId?,
override val senderBoostsCount: Int?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : CommonGroupContentMessage<T> {
constructor(
chat: PreviewGroupChat,
@@ -147,8 +200,23 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
mediaGroupId: MediaGroupId?,
senderBoostsCount: Int?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, messageId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
chat = chat,
messageId = messageId,
from = from,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
mediaGroupId = mediaGroupId,
senderBoostsCount = senderBoostsCount,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -168,6 +236,8 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : FromChannelForumContentMessage<T> {
constructor(
chat: PreviewForumChat,
@@ -185,8 +255,24 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, channel, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
chat = chat,
channel = channel,
messageId = messageId,
threadId = threadId,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
authorSignature = authorSignature,
mediaGroupId = mediaGroupId,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -205,6 +291,8 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
override val authorSignature: AuthorSignature?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : AnonymousForumContentMessage<T> {
constructor(
chat: PreviewForumChat,
@@ -221,8 +309,23 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
authorSignature: AuthorSignature?,
mediaGroupId: MediaGroupId?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, messageId, threadId, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, authorSignature, mediaGroupId, fromOffline
chat = chat,
messageId = messageId,
threadId = threadId,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
authorSignature = authorSignature,
mediaGroupId = mediaGroupId,
fromOffline = fromOffline,
cost = cost,
)
}
@@ -242,6 +345,8 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
override val mediaGroupId: MediaGroupId?,
override val senderBoostsCount: Int?,
override val fromOffline: Boolean,
@SerialName(paidMessageStarCountField)
override val cost: Int? = null,
) : CommonForumContentMessage<T> {
constructor(
chat: PreviewForumChat,
@@ -259,7 +364,23 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
mediaGroupId: MediaGroupId?,
senderBoostsCount: Int?,
fromOffline: Boolean,
cost: Int? = null,
) : this(
chat, messageId, threadId, from, date, forwardInfo.messageOrigin(), editDate, hasProtectedContent, replyTo ?.let { ReplyInfo.Internal(it) }, replyMarkup, content, senderBot, mediaGroupId, senderBoostsCount, fromOffline
chat = chat,
messageId = messageId,
threadId = threadId,
from = from,
date = date,
forwardOrigin = forwardInfo.messageOrigin(),
editDate = editDate,
hasProtectedContent = hasProtectedContent,
replyInfo = replyTo ?.let { ReplyInfo.Internal(it) },
replyMarkup = replyMarkup,
content = content,
senderBot = senderBot,
mediaGroupId = mediaGroupId,
senderBoostsCount = senderBoostsCount,
fromOffline = fromOffline,
cost = cost,
)
}

View File

@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent
import kotlinx.serialization.SerialName
data class PrivateContentMessageImpl<T: MessageContent>(
override val messageId: MessageId,
@@ -24,7 +25,9 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupId?,
override val fromOffline: Boolean,
override val effectId: EffectId?
override val effectId: EffectId?,
@SerialName(paidStarCountField)
override val cost: Int? = null
) : PrivateContentMessage<T> {
constructor(
messageId: MessageId,

View File

@@ -10,6 +10,7 @@ import dev.inmo.tgbotapi.types.dice.Dice
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.RawGame
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.giveaway.*
import dev.inmo.tgbotapi.types.message.content.GiveawayContent
import dev.inmo.tgbotapi.types.location.Location
@@ -109,6 +110,9 @@ internal data class RawMessage(
private val is_from_offline: Boolean = false,
private val paid_star_count: Int? = null,
private val paid_message_price_changed: PaidMessagePriceChanged? = null,
// Voice Chat Service Messages
private val video_chat_scheduled: VideoChatScheduled? = null,
private val video_chat_started: VideoChatStarted? = null,
@@ -160,6 +164,10 @@ internal data class RawMessage(
private val giveaway: Giveaway? = null,
private val giveaway_winners: GiveawayPublicResults? = null,
private val giveaway_completed: GiveawayPrivateResults? = null,
// Gifts
private val gift: GiftSentOrReceived.Regular? = null,
private val unique_gift: GiftSentOrReceived.Unique? = null,
) {
private val checkedFrom = from ?.takeIf { !it.isFakeTelegramUser() }
private val content: MessageContent? by lazy {
@@ -282,6 +290,9 @@ internal data class RawMessage(
giveaway_completed != null -> giveaway_completed
boost_added != null -> boost_added
chat_background_set != null -> chat_background_set
paid_message_price_changed != null -> paid_message_price_changed
gift != null -> gift
unique_gift != null -> unique_gift
else -> null
}
}
@@ -295,7 +306,7 @@ internal data class RawMessage(
}
try {
chatEvent?.let { chatEvent ->
chatEvent ?.let { chatEvent ->
when (chat) {
is PreviewSupergroupChat -> CommonSupergroupEventMessage(
messageId,
@@ -350,7 +361,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
is PreviewForumChat -> if (messageThreadId != null) {
val chatId = ChatIdWithThreadId(
@@ -376,7 +388,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
is PreviewGroupChat -> AnonymousForumContentMessageImpl(
chat = actualForumChat,
@@ -392,7 +405,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
null -> CommonForumContentMessageImpl(
chat = actualForumChat,
@@ -409,7 +423,8 @@ internal data class RawMessage(
senderBot = via_bot,
mediaGroupId = media_group_id,
senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
} else {
@@ -429,7 +444,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
} else {
UnconnectedFromChannelGroupContentMessageImpl(
@@ -446,7 +462,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
is GroupChat -> AnonymousGroupContentMessageImpl(
@@ -462,7 +479,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
null -> CommonGroupContentMessageImpl(
chat = chat,
@@ -478,7 +496,8 @@ internal data class RawMessage(
senderBot = via_bot,
mediaGroupId = media_group_id,
senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
}
@@ -498,7 +517,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
} else {
UnconnectedFromChannelGroupContentMessageImpl(
@@ -515,7 +535,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
is PreviewGroupChat -> AnonymousGroupContentMessageImpl(
@@ -531,7 +552,8 @@ internal data class RawMessage(
senderBot = via_bot,
authorSignature = author_signature,
mediaGroupId = media_group_id,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
null -> CommonGroupContentMessageImpl(
chat = chat,
@@ -547,7 +569,8 @@ internal data class RawMessage(
senderBot = via_bot,
mediaGroupId = media_group_id,
senderBoostsCount = sender_boost_count,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
}
@@ -566,7 +589,8 @@ internal data class RawMessage(
senderBot = via_bot,
mediaGroupId = media_group_id,
fromOffline = is_from_offline,
effectId = effect_id
effectId = effect_id,
cost = paid_star_count,
)
} else {
BusinessContentMessageImpl(
@@ -587,18 +611,19 @@ internal data class RawMessage(
senderBot = via_bot,
mediaGroupId = media_group_id,
senderBusinessBot = sender_business_bot,
fromOffline = is_from_offline
fromOffline = is_from_offline,
cost = paid_star_count,
)
}
else -> error("Unknown type of chat: $chat")
}
} ?: passport_data ?.let{
PassportMessage(
messageId,
chat,
checkedFrom ?: from ?: error("For passport must be provided user, but got null"),
date.asDate,
passport_data
messageId = messageId,
chat = chat,
from = checkedFrom ?: from ?: error("For passport must be provided user, but got null"),
date = date.asDate,
passportData = passport_data,
)
} ?: error("Was not found supported type of data")
} catch (e: Exception) {

View File

@@ -10,4 +10,5 @@ sealed interface CommonMessage<out T: MessageContent> : AccessibleMessage,
PossiblyBusinessMessage,
PossiblyOfflineMessage,
PossiblyMediaGroupMessage<T>,
PossiblyPaidMessage,
ContentMessage<T>

View File

@@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.types.message.abstracts
interface PossiblyPaidMessage : Message {
val cost: Int?
}

View File

@@ -0,0 +1,14 @@
package dev.inmo.tgbotapi.types.payments.stars
import dev.inmo.tgbotapi.types.amountField
import dev.inmo.tgbotapi.types.nanostarAmountField
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
data class StarAmount(
@SerialName(amountField)
val amount: Long,
@SerialName(nanostarAmountField)
val nanostarAmount: Long = 0,
)

View File

@@ -61,10 +61,10 @@ sealed interface TransactionPartner {
val paidMedia: List<PaidMedia>? = null,
@SerialName(paidMediaPayloadField)
val paidMediaPayload: PaidMediaPayload? = null,
@SerialName(giftField)
val gift: Gift? = null,
@SerialName(premiumSubscriptionDurationField)
val premiumSubscriptionDuration: Int? = null,
@SerialName(giftField)
val gift: Gift.Regular? = null,
) : TransactionPartner, SubscriptionPeriodInfo {
@EncodeDefault
override val type: String = Companion.type
@@ -79,7 +79,7 @@ sealed interface TransactionPartner {
@SerialName(chatField)
val chat: PreviewChat,
@SerialName(giftField)
val gift: Gift? = null
val gift: Gift.Regular? = null
) : TransactionPartner {
@EncodeDefault
override val type: String = Companion.type
@@ -154,9 +154,9 @@ sealed interface TransactionPartner {
val subscription_period: TimeSpan? = null,
val paid_media: List<PaidMedia>? = null,
val paid_media_payload: PaidMediaPayload? = null,
val gift: Gift? = null,
val premium_subscription_duration: Int? = null,
val transaction_type: TransactionType? = null,
val gift: Gift.Regular? = null,
val request_count: Int? = null,
val sponsor_user: PreviewBot? = null,
val commission_per_mille: Int? = null,

View File

@@ -0,0 +1,33 @@
package dev.inmo.tgbotapi.utils
import dev.inmo.micro_utils.common.Either
import dev.inmo.micro_utils.common.EitherFirst
import dev.inmo.micro_utils.common.EitherSecond
import kotlinx.serialization.KSerializer
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.json.JsonDecoder
import kotlinx.serialization.json.JsonElement
fun <T> Decoder.deserializeWithRaw(serializer: KSerializer<T>): Pair<T, JsonElement?> {
return if (this is JsonDecoder) {
val json = decodeJsonElement()
this.json.decodeFromJsonElement(serializer, json) to json
} else {
serializer.deserialize(this) to null
}
}
fun <T> Decoder.deserializeEitherWithRaw(serializer: KSerializer<T>): Either<Pair<T?, JsonElement>, Pair<T, JsonElement?>> {
return if (this is JsonDecoder) {
val json = decodeJsonElement()
EitherFirst(
runCatching {
this.json.decodeFromJsonElement(serializer, json)
}.getOrNull() to json
)
} else {
EitherSecond(
serializer.deserialize(this) to null
)
}
}

View File

@@ -29,7 +29,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is BusinessContentMessage -> BusinessContentMessageImpl(
messageId = sourceMessage.messageId,
@@ -46,7 +47,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
mediaGroupId = sourceMessage.mediaGroupId,
senderBusinessBot = sourceMessage.senderBusinessBot,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is PrivateContentMessage -> PrivateContentMessageImpl(
messageId = sourceMessage.messageId,
@@ -62,7 +64,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline,
effectId = sourceMessage.effectId
effectId = sourceMessage.effectId,
cost = sourceMessage.cost,
)
is AnonymousGroupContentMessage -> AnonymousGroupContentMessageImpl(
chat = sourceMessage.chat,
@@ -77,7 +80,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is CommonGroupContentMessage -> CommonGroupContentMessageImpl(
chat = sourceMessage.chat,
@@ -93,7 +97,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
mediaGroupId = sourceMessage.mediaGroupId,
senderBoostsCount = sourceMessage.senderBoostsCount,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is ConnectedFromChannelGroupContentMessage -> ConnectedFromChannelGroupContentMessageImpl(
chat = sourceMessage.chat,
@@ -109,7 +114,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is UnconnectedFromChannelGroupContentMessage -> UnconnectedFromChannelGroupContentMessageImpl(
chat = sourceMessage.chat,
@@ -125,7 +131,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is AnonymousForumContentMessage -> AnonymousForumContentMessageImpl(
chat = sourceMessage.chat,
@@ -141,7 +148,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is CommonForumContentMessage -> CommonForumContentMessageImpl(
chat = sourceMessage.chat,
@@ -158,7 +166,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
mediaGroupId = sourceMessage.mediaGroupId,
senderBoostsCount = sourceMessage.senderBoostsCount,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
is FromChannelForumContentMessage -> FromChannelForumContentMessageImpl(
chat = sourceMessage.chat,
@@ -175,7 +184,8 @@ fun <T : MediaGroupPartContent> List<PossiblySentViaBotCommonMessage<T>>.asMedia
senderBot = sourceMessage.senderBot,
authorSignature = sourceMessage.authorSignature,
mediaGroupId = sourceMessage.mediaGroupId,
fromOffline = sourceMessage.fromOffline
fromOffline = sourceMessage.fromOffline,
cost = sourceMessage.cost,
)
}
}

View File

@@ -5,7 +5,12 @@ import dev.inmo.tgbotapi.utils.RiskFeature
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
annotation class ClassCastsIncluded(val typesRegex: String = "", val excludeRegex: String = "")
annotation class ClassCastsIncluded(val typesRegex: String = "", val excludeRegex: String = "") {
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
@RiskFeature("It is internal API in tgbotapi.core and should not be used outside")
annotation class ExcludeSubName
}
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)

View File

@@ -9,5 +9,6 @@ repositories {
dependencies {
implementation libs.kotlin.poet
implementation libs.ksp
implementation libs.microutils.ksp.generator
implementation project(":tgbotapi.core")
}

View File

@@ -1,9 +1,13 @@
package dev.inmo.tgbotapi.ksp.processor
import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getAnnotationsByType
import com.google.devtools.ksp.isAnnotationPresent
import com.google.devtools.ksp.symbol.*
import com.squareup.kotlinpoet.*
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
import com.squareup.kotlinpoet.ksp.*
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
private fun FileSpec.Builder.addTopLevelImport(className: ClassName) {
className.topLevelClassName().let {
@@ -27,6 +31,24 @@ private fun FileSpec.Builder.createTypeDefinition(ksClassDeclaration: KSClassDec
}
}
@OptIn(KspExperimental::class)
private fun KSClassDeclaration.buildPrefix(sourceDeclaration: KSClassDeclaration): String {
val ownName = if (isAnnotationPresent(ClassCastsIncluded.ExcludeSubName::class)) {
""
} else {
simpleName.asString()
}
when (val parentDeclaration = parentDeclaration) {
is KSClassDeclaration -> if (parentDeclaration === sourceDeclaration) {
return ownName
} else {
return "${parentDeclaration.buildPrefix(sourceDeclaration)}$ownName"
}
}
return ownName
}
@OptIn(KspExperimental::class)
fun FileSpec.Builder.fill(
sourceKSClassDeclaration: KSClassDeclaration,
subtypesMap: Map<KSClassDeclaration, Set<KSClassDeclaration>>,
@@ -40,8 +62,10 @@ fun FileSpec.Builder.fill(
val sourceClassName = sourceKSClassDeclaration.toClassName()
val targetClassClassName = targetClassDeclaration.toClassName()
val targetClassTypeDefinition = createTypeDefinition(targetClassDeclaration)
val simpleName = targetClassDeclaration.simpleName.asString()
val withFirstLowerCase = simpleName.replaceFirstChar { it.lowercase() }
// val simpleName = targetClassDeclaration.simpleName.asString()
// val additionalPrefix = targetClassDeclaration.buildPrefix()
val resultPrefix = targetClassDeclaration.buildPrefix(sourceKSClassDeclaration)
val withFirstLowerCase = resultPrefix.replaceFirstChar { it.lowercase() }
val castedOrNullName = "${withFirstLowerCase}OrNull"
addTopLevelImport(targetClassClassName)
@@ -68,7 +92,7 @@ fun FileSpec.Builder.fill(
}.build()
)
addFunction(
FunSpec.builder("if$simpleName").apply {
FunSpec.builder("if$resultPrefix").apply {
val genericType = TypeVariableName("T", null)
addTypeVariable(genericType)
receiver(sourceClassName)

View File

@@ -1,22 +1,21 @@
package dev.inmo.tgbotapi.ksp.processor
import com.google.devtools.ksp.KspExperimental
import com.google.devtools.ksp.getAllSuperTypes
import com.google.devtools.ksp.getAnnotationsByType
import com.google.devtools.ksp.isAnnotationPresent
import com.google.devtools.ksp.*
import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration
import com.google.devtools.ksp.symbol.*
import com.squareup.kotlinpoet.AnnotationSpec
import com.squareup.kotlinpoet.ClassName
import com.squareup.kotlinpoet.FileSpec
import com.squareup.kotlinpoet.asClassName
import com.squareup.kotlinpoet.ksp.toClassName
import com.squareup.kotlinpoet.ksp.writeTo
import dev.inmo.micro_ksp.generator.resolveSubclasses
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.internal.ClassCastsExcluded
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import java.io.File
import java.io.InputStream
import java.io.OutputStreamWriter
import java.io.StringWriter
class TelegramBotAPISymbolProcessor(
private val codeGenerator: CodeGenerator,
@@ -37,7 +36,14 @@ class TelegramBotAPISymbolProcessor(
val classesSubtypes = mutableMapOf<KSClassDeclaration, MutableSet<KSClassDeclaration>>()
resolver.getAllFiles().forEach {
it.declarations.forEach { potentialSubtype ->
val declarationsToAnalyze = mutableSetOf<KSDeclaration>()
declarationsToAnalyze.addAll(it.declarations)
val analyzed = mutableSetOf<KSDeclaration>()
while (declarationsToAnalyze.isNotEmpty()) {
val potentialSubtype = declarationsToAnalyze.first()
declarationsToAnalyze.remove(potentialSubtype)
if (analyzed.add(potentialSubtype)) {
if (
potentialSubtype is KSClassDeclaration
&& potentialSubtype.isAnnotationPresent(ClassCastsExcluded::class).not()
@@ -57,6 +63,12 @@ class TelegramBotAPISymbolProcessor(
}
}
}
when (potentialSubtype) {
is KSFile -> declarationsToAnalyze.addAll(potentialSubtype.declarations)
is KSClassDeclaration ->declarationsToAnalyze.addAll(potentialSubtype.declarations)
is KSFunctionDeclaration -> declarationsToAnalyze.addAll(potentialSubtype.declarations)
}
}
}
}
fun fillWithSealeds(source: KSClassDeclaration, current: KSClassDeclaration = source) {
@@ -98,15 +110,21 @@ class TelegramBotAPISymbolProcessor(
)
}
}.build()
runCatching {
outputFolder ?.also {
File(it).apply {
File(it, outputFile).apply {
val text = StringWriter().use {
fileSpec.writeTo(it)
it.toString()
}
if (exists() == false || readText() != text) {
delete()
runCatching { mkdirs() }
fileSpec.writeTo(this)
runCatching { parentFile.mkdirs() }
createNewFile()
writeText(text)
}
}
} ?: fileSpec.writeTo(codeGenerator, false)
}
return emptyList()
}

View File

@@ -1447,6 +1447,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun generalForumTopicUnhiddenOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/message/ChatEvents/forum/GeneralForumTopicUnhidden;
public static final fun giftCodeOrNull (Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource;)Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource$GiftCode;
public static final fun giftCodeOrThrow (Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource;)Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource$GiftCode;
public static final fun giftSentOrReceivedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/gifts/GiftSentOrReceived;
public static final fun giftSentOrReceivedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/gifts/GiftSentOrReceived;
public static final fun giveawayContentOrNull (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/GiveawayContent;
public static final fun giveawayContentOrThrow (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;)Ldev/inmo/tgbotapi/types/message/content/GiveawayContent;
public static final fun giveawayCreatedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/giveaway/GiveawayCreated;
@@ -1676,6 +1678,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun ifGeneralForumTopicHidden (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGeneralForumTopicUnhidden (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGiftCode (Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGiftSentOrReceived (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGiveaway (Ldev/inmo/tgbotapi/types/boosts/ChatBoostSource;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGiveawayContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifGiveawayCreated (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
@@ -1794,6 +1797,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun ifPaidMediaInfoContent (Ldev/inmo/tgbotapi/types/message/content/ResendableContent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPaidMediaPurchased (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPaidMediaPurchasedUpdate (Ldev/inmo/tgbotapi/types/update/abstracts/Update;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPaidMessagePriceChanged (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPassport (Ldev/inmo/tgbotapi/types/passport/encrypted/abstracts/EncryptedPassportElement;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPassportElementErrorDataField (Ldev/inmo/tgbotapi/types/passport/PassportElementError;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPassportElementErrorFile (Ldev/inmo/tgbotapi/types/passport/PassportElementError;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
@@ -1834,6 +1838,7 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun ifPossiblyForwardedMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyMediaGroupMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyOfflineMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyPaidMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyPaymentMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblyPremiumChat (Ldev/inmo/tgbotapi/types/chat/Chat;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
public static final fun ifPossiblySentViaBotCommonMessage (Ldev/inmo/tgbotapi/types/message/abstracts/Message;Lkotlin/jvm/functions/Function1;)Ljava/lang/Object;
@@ -2222,6 +2227,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun paidMediaPurchasedOrThrow (Ldev/inmo/tgbotapi/abstracts/OptionallyWithUser;)Ldev/inmo/tgbotapi/types/message/payments/PaidMediaPurchased;
public static final fun paidMediaPurchasedUpdateOrNull (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PaidMediaPurchasedUpdate;
public static final fun paidMediaPurchasedUpdateOrThrow (Ldev/inmo/tgbotapi/types/update/abstracts/Update;)Ldev/inmo/tgbotapi/types/update/PaidMediaPurchasedUpdate;
public static final fun paidMessagePriceChangedOrNull (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/PaidMessagePriceChanged;
public static final fun paidMessagePriceChangedOrThrow (Ldev/inmo/tgbotapi/types/message/ChatEvents/abstracts/ChatEvent;)Ldev/inmo/tgbotapi/types/PaidMessagePriceChanged;
public static final fun paidOrNull (Ldev/inmo/tgbotapi/types/reactions/Reaction;)Ldev/inmo/tgbotapi/types/reactions/Reaction$Paid;
public static final fun paidOrThrow (Ldev/inmo/tgbotapi/types/reactions/Reaction;)Ldev/inmo/tgbotapi/types/reactions/Reaction$Paid;
public static final fun passportElementErrorDataFieldOrNull (Ldev/inmo/tgbotapi/types/passport/PassportElementError;)Ldev/inmo/tgbotapi/types/passport/PassportElementErrorDataField;
@@ -2304,6 +2311,8 @@ public final class dev/inmo/tgbotapi/extensions/utils/ClassCastsNewKt {
public static final fun possiblyMediaGroupMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyMediaGroupMessage;
public static final fun possiblyOfflineMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyOfflineMessage;
public static final fun possiblyOfflineMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyOfflineMessage;
public static final fun possiblyPaidMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyPaidMessage;
public static final fun possiblyPaidMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyPaidMessage;
public static final fun possiblyPaymentMessageOrNull (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage;
public static final fun possiblyPaymentMessageOrThrow (Ldev/inmo/tgbotapi/types/message/abstracts/Message;)Ldev/inmo/tgbotapi/types/message/abstracts/PossiblyPaymentMessage;
public static final fun possiblyPremiumChatOrNull (Ldev/inmo/tgbotapi/types/chat/Chat;)Ldev/inmo/tgbotapi/types/chat/PossiblyPremiumChat;

View File

@@ -80,6 +80,7 @@ import dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent.InputVenueMessa
import dev.inmo.tgbotapi.types.InlineQueries.query.BaseInlineQuery
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.InlineQueries.query.LocationInlineQuery
import dev.inmo.tgbotapi.types.PaidMessagePriceChanged
import dev.inmo.tgbotapi.types.PrimaryInviteLink
import dev.inmo.tgbotapi.types.ReplyInfo
import dev.inmo.tgbotapi.types.SecondaryChatInviteLink
@@ -215,6 +216,7 @@ import dev.inmo.tgbotapi.types.files.VideoFile
import dev.inmo.tgbotapi.types.files.VideoNoteFile
import dev.inmo.tgbotapi.types.files.VideoSticker
import dev.inmo.tgbotapi.types.files.VoiceFile
import dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
import dev.inmo.tgbotapi.types.location.LiveLocation
@@ -308,6 +310,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyMediaGroupMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyOfflineMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaidMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage
@@ -825,6 +828,15 @@ public inline fun <T>
OptionallyWithUser.ifCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T):
T? = commonSupergroupEventMessageOrNull() ?.let(block)
public inline fun OptionallyWithUser.forwardInfoByUserOrNull(): ForwardInfo.ByUser? = this as?
dev.inmo.tgbotapi.types.message.ForwardInfo.ByUser
public inline fun OptionallyWithUser.forwardInfoByUserOrThrow(): ForwardInfo.ByUser = this as
dev.inmo.tgbotapi.types.message.ForwardInfo.ByUser
public inline fun <T> OptionallyWithUser.ifForwardInfoByUser(block: (ForwardInfo.ByUser) -> T): T? =
forwardInfoByUserOrNull() ?.let(block)
public inline fun OptionallyWithUser.passportMessageOrNull(): PassportMessage? = this as?
dev.inmo.tgbotapi.types.message.PassportMessage
@@ -973,6 +985,24 @@ public inline fun OptionallyWithUser.pollAnswerOrThrow(): PollAnswer = this as
public inline fun <T> OptionallyWithUser.ifPollAnswer(block: (PollAnswer) -> T): T? =
pollAnswerOrNull() ?.let(block)
public inline fun OptionallyWithUser.pollAnswerPublicOrNull(): PollAnswer.Public? = this as?
dev.inmo.tgbotapi.types.polls.PollAnswer.Public
public inline fun OptionallyWithUser.pollAnswerPublicOrThrow(): PollAnswer.Public = this as
dev.inmo.tgbotapi.types.polls.PollAnswer.Public
public inline fun <T> OptionallyWithUser.ifPollAnswerPublic(block: (PollAnswer.Public) -> T): T? =
pollAnswerPublicOrNull() ?.let(block)
public inline fun OptionallyWithUser.pollAnswerAnonymousOrNull(): PollAnswer.Anonymous? = this as?
dev.inmo.tgbotapi.types.polls.PollAnswer.Anonymous
public inline fun OptionallyWithUser.pollAnswerAnonymousOrThrow(): PollAnswer.Anonymous = this as
dev.inmo.tgbotapi.types.polls.PollAnswer.Anonymous
public inline fun <T> OptionallyWithUser.ifPollAnswerAnonymous(block: (PollAnswer.Anonymous) -> T):
T? = pollAnswerAnonymousOrNull() ?.let(block)
public inline fun OptionallyWithUser.abstractMessageCallbackQueryOrNull():
AbstractMessageCallbackQuery? = this as?
dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery
@@ -1126,6 +1156,16 @@ public inline fun <T>
OptionallyWithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T):
T? = messageGameShortNameCallbackQueryOrNull() ?.let(block)
public inline fun InlineQueryResultsButton.webAppOrNull(): InlineQueryResultsButton.WebApp? = this
as? dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp
public inline fun InlineQueryResultsButton.webAppOrThrow(): InlineQueryResultsButton.WebApp = this
as dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp
public inline fun <T>
InlineQueryResultsButton.ifWebApp(block: (InlineQueryResultsButton.WebApp) -> T): T? =
webAppOrNull() ?.let(block)
public inline fun InlineQueryResultsButton.startOrNull(): InlineQueryResultsButton.Start? = this as?
dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.Start
@@ -1146,16 +1186,6 @@ public inline fun <T>
InlineQueryResultsButton.ifUnknown(block: (InlineQueryResultsButton.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun InlineQueryResultsButton.webAppOrNull(): InlineQueryResultsButton.WebApp? = this
as? dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp
public inline fun InlineQueryResultsButton.webAppOrThrow(): InlineQueryResultsButton.WebApp = this
as dev.inmo.tgbotapi.requests.answers.InlineQueryResultsButton.WebApp
public inline fun <T>
InlineQueryResultsButton.ifWebApp(block: (InlineQueryResultsButton.WebApp) -> T): T? =
webAppOrNull() ?.let(block)
public inline fun InputSticker.maskOrNull(): InputSticker.Mask? = this as?
dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask
@@ -1174,24 +1204,45 @@ public inline fun InputSticker.withKeywordsOrThrow(): InputSticker.WithKeywords
public inline fun <T> InputSticker.ifWithKeywords(block: (InputSticker.WithKeywords) -> T): T? =
withKeywordsOrNull() ?.let(block)
public inline fun InputSticker.customEmojiOrNull(): InputSticker.WithKeywords.CustomEmoji? = this
as? dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji
public inline fun InputSticker.withKeywordsRegularOrNull(): InputSticker.WithKeywords.Regular? =
this as? dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
public inline fun InputSticker.customEmojiOrThrow(): InputSticker.WithKeywords.CustomEmoji = this as
public inline fun InputSticker.withKeywordsRegularOrThrow(): InputSticker.WithKeywords.Regular =
this as dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
public inline fun <T>
InputSticker.ifWithKeywordsRegular(block: (InputSticker.WithKeywords.Regular) -> T): T? =
withKeywordsRegularOrNull() ?.let(block)
public inline fun InputSticker.withKeywordsCustomEmojiOrNull():
InputSticker.WithKeywords.CustomEmoji? = this as?
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji
public inline fun InputSticker.withKeywordsCustomEmojiOrThrow():
InputSticker.WithKeywords.CustomEmoji = this as
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji
public inline fun <T>
InputSticker.ifCustomEmoji(block: (InputSticker.WithKeywords.CustomEmoji) -> T): T? =
customEmojiOrNull() ?.let(block)
InputSticker.ifWithKeywordsCustomEmoji(block: (InputSticker.WithKeywords.CustomEmoji) -> T): T?
= withKeywordsCustomEmojiOrNull() ?.let(block)
public inline fun InputSticker.regularOrNull(): InputSticker.WithKeywords.Regular? = this as?
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
public inline fun BackgroundFill.solidOrNull(): BackgroundFill.Solid? = this as?
dev.inmo.tgbotapi.types.BackgroundFill.Solid
public inline fun InputSticker.regularOrThrow(): InputSticker.WithKeywords.Regular = this as
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
public inline fun BackgroundFill.solidOrThrow(): BackgroundFill.Solid = this as
dev.inmo.tgbotapi.types.BackgroundFill.Solid
public inline fun <T> InputSticker.ifRegular(block: (InputSticker.WithKeywords.Regular) -> T): T? =
regularOrNull() ?.let(block)
public inline fun <T> BackgroundFill.ifSolid(block: (BackgroundFill.Solid) -> T): T? = solidOrNull()
?.let(block)
public inline fun BackgroundFill.gradientOrNull(): BackgroundFill.Gradient? = this as?
dev.inmo.tgbotapi.types.BackgroundFill.Gradient
public inline fun BackgroundFill.gradientOrThrow(): BackgroundFill.Gradient = this as
dev.inmo.tgbotapi.types.BackgroundFill.Gradient
public inline fun <T> BackgroundFill.ifGradient(block: (BackgroundFill.Gradient) -> T): T? =
gradientOrNull() ?.let(block)
public inline fun BackgroundFill.freeformGradientOrNull(): BackgroundFill.FreeformGradient? = this
as? dev.inmo.tgbotapi.types.BackgroundFill.FreeformGradient
@@ -1203,24 +1254,6 @@ public inline fun <T>
BackgroundFill.ifFreeformGradient(block: (BackgroundFill.FreeformGradient) -> T): T? =
freeformGradientOrNull() ?.let(block)
public inline fun BackgroundFill.gradientOrNull(): BackgroundFill.Gradient? = this as?
dev.inmo.tgbotapi.types.BackgroundFill.Gradient
public inline fun BackgroundFill.gradientOrThrow(): BackgroundFill.Gradient = this as
dev.inmo.tgbotapi.types.BackgroundFill.Gradient
public inline fun <T> BackgroundFill.ifGradient(block: (BackgroundFill.Gradient) -> T): T? =
gradientOrNull() ?.let(block)
public inline fun BackgroundFill.solidOrNull(): BackgroundFill.Solid? = this as?
dev.inmo.tgbotapi.types.BackgroundFill.Solid
public inline fun BackgroundFill.solidOrThrow(): BackgroundFill.Solid = this as
dev.inmo.tgbotapi.types.BackgroundFill.Solid
public inline fun <T> BackgroundFill.ifSolid(block: (BackgroundFill.Solid) -> T): T? = solidOrNull()
?.let(block)
public inline fun BackgroundFill.unknownOrNull(): BackgroundFill.Unknown? = this as?
dev.inmo.tgbotapi.types.BackgroundFill.Unknown
@@ -1230,14 +1263,14 @@ public inline fun BackgroundFill.unknownOrThrow(): BackgroundFill.Unknown = this
public inline fun <T> BackgroundFill.ifUnknown(block: (BackgroundFill.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun BackgroundType.chatThemeOrNull(): BackgroundType.ChatTheme? = this as?
dev.inmo.tgbotapi.types.BackgroundType.ChatTheme
public inline fun BackgroundType.movableOrNull(): BackgroundType.Movable? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Movable
public inline fun BackgroundType.chatThemeOrThrow(): BackgroundType.ChatTheme = this as
dev.inmo.tgbotapi.types.BackgroundType.ChatTheme
public inline fun BackgroundType.movableOrThrow(): BackgroundType.Movable = this as
dev.inmo.tgbotapi.types.BackgroundType.Movable
public inline fun <T> BackgroundType.ifChatTheme(block: (BackgroundType.ChatTheme) -> T): T? =
chatThemeOrNull() ?.let(block)
public inline fun <T> BackgroundType.ifMovable(block: (BackgroundType.Movable) -> T): T? =
movableOrNull() ?.let(block)
public inline fun BackgroundType.dimmableOrNull(): BackgroundType.Dimmable? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Dimmable
@@ -1248,6 +1281,24 @@ public inline fun BackgroundType.dimmableOrThrow(): BackgroundType.Dimmable = th
public inline fun <T> BackgroundType.ifDimmable(block: (BackgroundType.Dimmable) -> T): T? =
dimmableOrNull() ?.let(block)
public inline fun BackgroundType.fillableOrNull(): BackgroundType.Fillable? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Fillable
public inline fun BackgroundType.fillableOrThrow(): BackgroundType.Fillable = this as
dev.inmo.tgbotapi.types.BackgroundType.Fillable
public inline fun <T> BackgroundType.ifFillable(block: (BackgroundType.Fillable) -> T): T? =
fillableOrNull() ?.let(block)
public inline fun BackgroundType.withDocumentOrNull(): BackgroundType.WithDocument? = this as?
dev.inmo.tgbotapi.types.BackgroundType.WithDocument
public inline fun BackgroundType.withDocumentOrThrow(): BackgroundType.WithDocument = this as
dev.inmo.tgbotapi.types.BackgroundType.WithDocument
public inline fun <T> BackgroundType.ifWithDocument(block: (BackgroundType.WithDocument) -> T): T? =
withDocumentOrNull() ?.let(block)
public inline fun BackgroundType.fillOrNull(): BackgroundType.Fill? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Fill
@@ -1266,15 +1317,6 @@ public inline fun BackgroundType.wallpaperOrThrow(): BackgroundType.Wallpaper =
public inline fun <T> BackgroundType.ifWallpaper(block: (BackgroundType.Wallpaper) -> T): T? =
wallpaperOrNull() ?.let(block)
public inline fun BackgroundType.fillableOrNull(): BackgroundType.Fillable? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Fillable
public inline fun BackgroundType.fillableOrThrow(): BackgroundType.Fillable = this as
dev.inmo.tgbotapi.types.BackgroundType.Fillable
public inline fun <T> BackgroundType.ifFillable(block: (BackgroundType.Fillable) -> T): T? =
fillableOrNull() ?.let(block)
public inline fun BackgroundType.patternOrNull(): BackgroundType.Pattern? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Pattern
@@ -1284,14 +1326,14 @@ public inline fun BackgroundType.patternOrThrow(): BackgroundType.Pattern = this
public inline fun <T> BackgroundType.ifPattern(block: (BackgroundType.Pattern) -> T): T? =
patternOrNull() ?.let(block)
public inline fun BackgroundType.movableOrNull(): BackgroundType.Movable? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Movable
public inline fun BackgroundType.chatThemeOrNull(): BackgroundType.ChatTheme? = this as?
dev.inmo.tgbotapi.types.BackgroundType.ChatTheme
public inline fun BackgroundType.movableOrThrow(): BackgroundType.Movable = this as
dev.inmo.tgbotapi.types.BackgroundType.Movable
public inline fun BackgroundType.chatThemeOrThrow(): BackgroundType.ChatTheme = this as
dev.inmo.tgbotapi.types.BackgroundType.ChatTheme
public inline fun <T> BackgroundType.ifMovable(block: (BackgroundType.Movable) -> T): T? =
movableOrNull() ?.let(block)
public inline fun <T> BackgroundType.ifChatTheme(block: (BackgroundType.ChatTheme) -> T): T? =
chatThemeOrNull() ?.let(block)
public inline fun BackgroundType.unknownOrNull(): BackgroundType.Unknown? = this as?
dev.inmo.tgbotapi.types.BackgroundType.Unknown
@@ -1302,15 +1344,6 @@ public inline fun BackgroundType.unknownOrThrow(): BackgroundType.Unknown = this
public inline fun <T> BackgroundType.ifUnknown(block: (BackgroundType.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun BackgroundType.withDocumentOrNull(): BackgroundType.WithDocument? = this as?
dev.inmo.tgbotapi.types.BackgroundType.WithDocument
public inline fun BackgroundType.withDocumentOrThrow(): BackgroundType.WithDocument = this as
dev.inmo.tgbotapi.types.BackgroundType.WithDocument
public inline fun <T> BackgroundType.ifWithDocument(block: (BackgroundType.WithDocument) -> T): T? =
withDocumentOrNull() ?.let(block)
public inline fun ChatIdentifier.idChatIdentifierOrNull(): IdChatIdentifier? = this as?
dev.inmo.tgbotapi.types.IdChatIdentifier
@@ -1844,51 +1877,6 @@ public inline fun <T>
InputMessageContent.ifInputVenueMessageContent(block: (InputVenueMessageContent) -> T): T? =
inputVenueMessageContentOrNull() ?.let(block)
public inline fun ReplyInfo.externalOrNull(): ReplyInfo.External? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External
public inline fun ReplyInfo.externalOrThrow(): ReplyInfo.External = this as
dev.inmo.tgbotapi.types.ReplyInfo.External
public inline fun <T> ReplyInfo.ifExternal(block: (ReplyInfo.External) -> T): T? = externalOrNull()
?.let(block)
public inline fun ReplyInfo.contentOrNull(): ReplyInfo.External.Content? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Content
public inline fun ReplyInfo.contentOrThrow(): ReplyInfo.External.Content = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Content
public inline fun <T> ReplyInfo.ifContent(block: (ReplyInfo.External.Content) -> T): T? =
contentOrNull() ?.let(block)
public inline fun ReplyInfo.mediaOrNull(): ReplyInfo.External.Content.Media? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media
public inline fun ReplyInfo.mediaOrThrow(): ReplyInfo.External.Content.Media = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media
public inline fun <T> ReplyInfo.ifMedia(block: (ReplyInfo.External.Content.Media) -> T): T? =
mediaOrNull() ?.let(block)
public inline fun ReplyInfo.simpleOrNull(): ReplyInfo.External.Content.Simple? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple
public inline fun ReplyInfo.simpleOrThrow(): ReplyInfo.External.Content.Simple = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple
public inline fun <T> ReplyInfo.ifSimple(block: (ReplyInfo.External.Content.Simple) -> T): T? =
simpleOrNull() ?.let(block)
public inline fun ReplyInfo.textOrNull(): ReplyInfo.External.Text? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Text
public inline fun ReplyInfo.textOrThrow(): ReplyInfo.External.Text = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Text
public inline fun <T> ReplyInfo.ifText(block: (ReplyInfo.External.Text) -> T): T? = textOrNull()
?.let(block)
public inline fun ReplyInfo.internalOrNull(): ReplyInfo.Internal? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.Internal
@@ -1907,6 +1895,53 @@ public inline fun ReplyInfo.toStoryOrThrow(): ReplyInfo.ToStory = this as
public inline fun <T> ReplyInfo.ifToStory(block: (ReplyInfo.ToStory) -> T): T? = toStoryOrNull()
?.let(block)
public inline fun ReplyInfo.externalOrNull(): ReplyInfo.External? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External
public inline fun ReplyInfo.externalOrThrow(): ReplyInfo.External = this as
dev.inmo.tgbotapi.types.ReplyInfo.External
public inline fun <T> ReplyInfo.ifExternal(block: (ReplyInfo.External) -> T): T? = externalOrNull()
?.let(block)
public inline fun ReplyInfo.externalTextOrNull(): ReplyInfo.External.Text? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Text
public inline fun ReplyInfo.externalTextOrThrow(): ReplyInfo.External.Text = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Text
public inline fun <T> ReplyInfo.ifExternalText(block: (ReplyInfo.External.Text) -> T): T? =
externalTextOrNull() ?.let(block)
public inline fun ReplyInfo.externalContentOrNull(): ReplyInfo.External.Content? = this as?
dev.inmo.tgbotapi.types.ReplyInfo.External.Content
public inline fun ReplyInfo.externalContentOrThrow(): ReplyInfo.External.Content = this as
dev.inmo.tgbotapi.types.ReplyInfo.External.Content
public inline fun <T> ReplyInfo.ifExternalContent(block: (ReplyInfo.External.Content) -> T): T? =
externalContentOrNull() ?.let(block)
public inline fun ReplyInfo.externalContentSimpleOrNull(): ReplyInfo.External.Content.Simple? = this
as? dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple
public inline fun ReplyInfo.externalContentSimpleOrThrow(): ReplyInfo.External.Content.Simple = this
as dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Simple
public inline fun <T>
ReplyInfo.ifExternalContentSimple(block: (ReplyInfo.External.Content.Simple) -> T): T? =
externalContentSimpleOrNull() ?.let(block)
public inline fun ReplyInfo.externalContentMediaOrNull(): ReplyInfo.External.Content.Media? = this
as? dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media
public inline fun ReplyInfo.externalContentMediaOrThrow(): ReplyInfo.External.Content.Media = this
as dev.inmo.tgbotapi.types.ReplyInfo.External.Content.Media
public inline fun <T>
ReplyInfo.ifExternalContentMedia(block: (ReplyInfo.External.Content.Media) -> T): T? =
externalContentMediaOrNull() ?.let(block)
public inline fun BotAction.typingActionOrNull(): TypingAction? = this as?
dev.inmo.tgbotapi.types.actions.TypingAction
@@ -2024,24 +2059,6 @@ public inline fun ChatBoostSource.byUserOrThrow(): ChatBoostSource.ByUser = this
public inline fun <T> ChatBoostSource.ifByUser(block: (ChatBoostSource.ByUser) -> T): T? =
byUserOrNull() ?.let(block)
public inline fun ChatBoostSource.giftCodeOrNull(): ChatBoostSource.GiftCode? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode
public inline fun ChatBoostSource.giftCodeOrThrow(): ChatBoostSource.GiftCode = this as
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode
public inline fun <T> ChatBoostSource.ifGiftCode(block: (ChatBoostSource.GiftCode) -> T): T? =
giftCodeOrNull() ?.let(block)
public inline fun ChatBoostSource.claimedOrNull(): ChatBoostSource.Giveaway.Claimed? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed
public inline fun ChatBoostSource.claimedOrThrow(): ChatBoostSource.Giveaway.Claimed = this as
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed
public inline fun <T> ChatBoostSource.ifClaimed(block: (ChatBoostSource.Giveaway.Claimed) -> T): T?
= claimedOrNull() ?.let(block)
public inline fun ChatBoostSource.premiumOrNull(): ChatBoostSource.Premium? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Premium
@@ -2051,6 +2068,15 @@ public inline fun ChatBoostSource.premiumOrThrow(): ChatBoostSource.Premium = th
public inline fun <T> ChatBoostSource.ifPremium(block: (ChatBoostSource.Premium) -> T): T? =
premiumOrNull() ?.let(block)
public inline fun ChatBoostSource.giftCodeOrNull(): ChatBoostSource.GiftCode? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode
public inline fun ChatBoostSource.giftCodeOrThrow(): ChatBoostSource.GiftCode = this as
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.GiftCode
public inline fun <T> ChatBoostSource.ifGiftCode(block: (ChatBoostSource.GiftCode) -> T): T? =
giftCodeOrNull() ?.let(block)
public inline fun ChatBoostSource.giveawayOrNull(): ChatBoostSource.Giveaway? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway
@@ -2060,24 +2086,6 @@ public inline fun ChatBoostSource.giveawayOrThrow(): ChatBoostSource.Giveaway =
public inline fun <T> ChatBoostSource.ifGiveaway(block: (ChatBoostSource.Giveaway) -> T): T? =
giveawayOrNull() ?.let(block)
public inline fun ChatBoostSource.createdOrNull(): ChatBoostSource.Giveaway.Created? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Created
public inline fun ChatBoostSource.createdOrThrow(): ChatBoostSource.Giveaway.Created = this as
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Created
public inline fun <T> ChatBoostSource.ifCreated(block: (ChatBoostSource.Giveaway.Created) -> T): T?
= createdOrNull() ?.let(block)
public inline fun ChatBoostSource.unclaimedOrNull(): ChatBoostSource.Giveaway.Unclaimed? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed
public inline fun ChatBoostSource.unclaimedOrThrow(): ChatBoostSource.Giveaway.Unclaimed = this as
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed
public inline fun <T> ChatBoostSource.ifUnclaimed(block: (ChatBoostSource.Giveaway.Unclaimed) -> T):
T? = unclaimedOrNull() ?.let(block)
public inline fun ChatBoostSource.unknownOrNull(): ChatBoostSource.Unknown? = this as?
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Unknown
@@ -2087,14 +2095,35 @@ public inline fun ChatBoostSource.unknownOrThrow(): ChatBoostSource.Unknown = th
public inline fun <T> ChatBoostSource.ifUnknown(block: (ChatBoostSource.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun BusinessConnection.disabledOrNull(): BusinessConnection.Disabled? = this as?
dev.inmo.tgbotapi.types.business_connection.BusinessConnection.Disabled
public inline fun ChatBoostSource.giveawayCreatedOrNull(): ChatBoostSource.Giveaway.Created? = this
as? dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Created
public inline fun BusinessConnection.disabledOrThrow(): BusinessConnection.Disabled = this as
dev.inmo.tgbotapi.types.business_connection.BusinessConnection.Disabled
public inline fun ChatBoostSource.giveawayCreatedOrThrow(): ChatBoostSource.Giveaway.Created = this
as dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Created
public inline fun <T> BusinessConnection.ifDisabled(block: (BusinessConnection.Disabled) -> T): T? =
disabledOrNull() ?.let(block)
public inline fun <T>
ChatBoostSource.ifGiveawayCreated(block: (ChatBoostSource.Giveaway.Created) -> T): T? =
giveawayCreatedOrNull() ?.let(block)
public inline fun ChatBoostSource.giveawayClaimedOrNull(): ChatBoostSource.Giveaway.Claimed? = this
as? dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed
public inline fun ChatBoostSource.giveawayClaimedOrThrow(): ChatBoostSource.Giveaway.Claimed = this
as dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Claimed
public inline fun <T>
ChatBoostSource.ifGiveawayClaimed(block: (ChatBoostSource.Giveaway.Claimed) -> T): T? =
giveawayClaimedOrNull() ?.let(block)
public inline fun ChatBoostSource.giveawayUnclaimedOrNull(): ChatBoostSource.Giveaway.Unclaimed? =
this as? dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed
public inline fun ChatBoostSource.giveawayUnclaimedOrThrow(): ChatBoostSource.Giveaway.Unclaimed =
this as dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway.Unclaimed
public inline fun <T>
ChatBoostSource.ifGiveawayUnclaimed(block: (ChatBoostSource.Giveaway.Unclaimed) -> T): T? =
giveawayUnclaimedOrNull() ?.let(block)
public inline fun BusinessConnection.enabledOrNull(): BusinessConnection.Enabled? = this as?
dev.inmo.tgbotapi.types.business_connection.BusinessConnection.Enabled
@@ -2105,6 +2134,15 @@ public inline fun BusinessConnection.enabledOrThrow(): BusinessConnection.Enable
public inline fun <T> BusinessConnection.ifEnabled(block: (BusinessConnection.Enabled) -> T): T? =
enabledOrNull() ?.let(block)
public inline fun BusinessConnection.disabledOrNull(): BusinessConnection.Disabled? = this as?
dev.inmo.tgbotapi.types.business_connection.BusinessConnection.Disabled
public inline fun BusinessConnection.disabledOrThrow(): BusinessConnection.Disabled = this as
dev.inmo.tgbotapi.types.business_connection.BusinessConnection.Disabled
public inline fun <T> BusinessConnection.ifDisabled(block: (BusinessConnection.Disabled) -> T): T? =
disabledOrNull() ?.let(block)
public inline fun InlineKeyboardButton.unknownInlineKeyboardButtonOrNull():
UnknownInlineKeyboardButton? = this as?
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton
@@ -2240,16 +2278,6 @@ public inline fun <T>
KeyboardButtonRequestUsers.ifAny(block: (KeyboardButtonRequestUsers.Any) -> T): T? = anyOrNull()
?.let(block)
public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestUsers.Bot? = this as?
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
public inline fun KeyboardButtonRequestUsers.botOrThrow(): KeyboardButtonRequestUsers.Bot = this as
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
public inline fun <T>
KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T): T? = botOrNull()
?.let(block)
public inline fun KeyboardButtonRequestUsers.commonOrNull(): KeyboardButtonRequestUsers.Common? =
this as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common
@@ -2260,6 +2288,16 @@ public inline fun <T>
KeyboardButtonRequestUsers.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? =
commonOrNull() ?.let(block)
public inline fun KeyboardButtonRequestUsers.botOrNull(): KeyboardButtonRequestUsers.Bot? = this as?
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
public inline fun KeyboardButtonRequestUsers.botOrThrow(): KeyboardButtonRequestUsers.Bot = this as
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Bot
public inline fun <T>
KeyboardButtonRequestUsers.ifBot(block: (KeyboardButtonRequestUsers.Bot) -> T): T? = botOrNull()
?.let(block)
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@@ -2648,16 +2686,6 @@ public inline fun Chat.unknownChatTypeOrThrow(): UnknownChatType = this as
public inline fun <T> Chat.ifUnknownChatType(block: (UnknownChatType) -> T): T? =
unknownChatTypeOrNull() ?.let(block)
public inline fun ChatMessageReactionUpdated.byChatOrNull(): ChatMessageReactionUpdated.ByChat? =
this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat
public inline fun ChatMessageReactionUpdated.byChatOrThrow(): ChatMessageReactionUpdated.ByChat =
this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat
public inline fun <T>
ChatMessageReactionUpdated.ifByChat(block: (ChatMessageReactionUpdated.ByChat) -> T): T? =
byChatOrNull() ?.let(block)
public inline fun ChatMessageReactionUpdated.byUserOrNull(): ChatMessageReactionUpdated.ByUser? =
this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByUser
@@ -2668,6 +2696,16 @@ public inline fun <T>
ChatMessageReactionUpdated.ifByUser(block: (ChatMessageReactionUpdated.ByUser) -> T): T? =
byUserOrNull() ?.let(block)
public inline fun ChatMessageReactionUpdated.byChatOrNull(): ChatMessageReactionUpdated.ByChat? =
this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat
public inline fun ChatMessageReactionUpdated.byChatOrThrow(): ChatMessageReactionUpdated.ByChat =
this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByChat
public inline fun <T>
ChatMessageReactionUpdated.ifByChat(block: (ChatMessageReactionUpdated.ByChat) -> T): T? =
byChatOrNull() ?.let(block)
public inline fun ChatMessageReactionUpdated.unknownOrNull(): ChatMessageReactionUpdated.Unknown? =
this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.Unknown
@@ -3292,6 +3330,15 @@ public inline fun <T>
TelegramMedia.ifWithCustomizableCaptionTelegramMedia(block: (WithCustomizableCaptionTelegramMedia) -> T):
T? = withCustomizableCaptionTelegramMediaOrNull() ?.let(block)
public inline fun ChatEvent.paidMessagePriceChangedOrNull(): PaidMessagePriceChanged? = this as?
dev.inmo.tgbotapi.types.PaidMessagePriceChanged
public inline fun ChatEvent.paidMessagePriceChangedOrThrow(): PaidMessagePriceChanged = this as
dev.inmo.tgbotapi.types.PaidMessagePriceChanged
public inline fun <T> ChatEvent.ifPaidMessagePriceChanged(block: (PaidMessagePriceChanged) -> T): T?
= paidMessagePriceChangedOrNull() ?.let(block)
public inline fun ChatEvent.chatBackgroundOrNull(): ChatBackground? = this as?
dev.inmo.tgbotapi.types.chat.ChatBackground
@@ -3301,6 +3348,94 @@ public inline fun ChatEvent.chatBackgroundOrThrow(): ChatBackground = this as
public inline fun <T> ChatEvent.ifChatBackground(block: (ChatBackground) -> T): T? =
chatBackgroundOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedOrNull(): GiftSentOrReceived? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
public inline fun ChatEvent.giftSentOrReceivedOrThrow(): GiftSentOrReceived = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived
public inline fun <T> ChatEvent.ifGiftSentOrReceived(block: (GiftSentOrReceived) -> T): T? =
giftSentOrReceivedOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedReceivedInBusinessAccountOrNull():
GiftSentOrReceived.ReceivedInBusinessAccount? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.ReceivedInBusinessAccount
public inline fun ChatEvent.giftSentOrReceivedReceivedInBusinessAccountOrThrow():
GiftSentOrReceived.ReceivedInBusinessAccount = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.ReceivedInBusinessAccount
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedReceivedInBusinessAccount(block: (GiftSentOrReceived.ReceivedInBusinessAccount) -> T):
T? = giftSentOrReceivedReceivedInBusinessAccountOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedRegularOrNull(): GiftSentOrReceived.Regular? = this
as? dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular
public inline fun ChatEvent.giftSentOrReceivedRegularOrThrow(): GiftSentOrReceived.Regular = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedRegular(block: (GiftSentOrReceived.Regular) -> T): T? =
giftSentOrReceivedRegularOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedUniqueOrNull(): GiftSentOrReceived.Unique? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique
public inline fun ChatEvent.giftSentOrReceivedUniqueOrThrow(): GiftSentOrReceived.Unique = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique
public inline fun <T> ChatEvent.ifGiftSentOrReceivedUnique(block: (GiftSentOrReceived.Unique) -> T):
T? = giftSentOrReceivedUniqueOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedRegularCommonOrNull():
GiftSentOrReceived.Regular.Common? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular.Common
public inline fun ChatEvent.giftSentOrReceivedRegularCommonOrThrow():
GiftSentOrReceived.Regular.Common = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular.Common
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedRegularCommon(block: (GiftSentOrReceived.Regular.Common) -> T): T?
= giftSentOrReceivedRegularCommonOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedRegularReceivedInBusinessAccountOrNull():
GiftSentOrReceived.Regular.ReceivedInBusinessAccount? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular.ReceivedInBusinessAccount
public inline fun ChatEvent.giftSentOrReceivedRegularReceivedInBusinessAccountOrThrow():
GiftSentOrReceived.Regular.ReceivedInBusinessAccount = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Regular.ReceivedInBusinessAccount
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedRegularReceivedInBusinessAccount(block: (GiftSentOrReceived.Regular.ReceivedInBusinessAccount) -> T):
T? = giftSentOrReceivedRegularReceivedInBusinessAccountOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedUniqueCommonOrNull():
GiftSentOrReceived.Unique.Common? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique.Common
public inline fun ChatEvent.giftSentOrReceivedUniqueCommonOrThrow():
GiftSentOrReceived.Unique.Common = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique.Common
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedUniqueCommon(block: (GiftSentOrReceived.Unique.Common) -> T): T? =
giftSentOrReceivedUniqueCommonOrNull() ?.let(block)
public inline fun ChatEvent.giftSentOrReceivedUniqueReceivedInBusinessAccountOrNull():
GiftSentOrReceived.Unique.ReceivedInBusinessAccount? = this as?
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique.ReceivedInBusinessAccount
public inline fun ChatEvent.giftSentOrReceivedUniqueReceivedInBusinessAccountOrThrow():
GiftSentOrReceived.Unique.ReceivedInBusinessAccount = this as
dev.inmo.tgbotapi.types.gifts.GiftSentOrReceived.Unique.ReceivedInBusinessAccount
public inline fun <T>
ChatEvent.ifGiftSentOrReceivedUniqueReceivedInBusinessAccount(block: (GiftSentOrReceived.Unique.ReceivedInBusinessAccount) -> T):
T? = giftSentOrReceivedUniqueReceivedInBusinessAccountOrNull() ?.let(block)
public inline fun ChatEvent.giveawayCreatedOrNull(): GiveawayCreated? = this as?
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
@@ -3310,6 +3445,24 @@ public inline fun ChatEvent.giveawayCreatedOrThrow(): GiveawayCreated = this as
public inline fun <T> ChatEvent.ifGiveawayCreated(block: (GiveawayCreated) -> T): T? =
giveawayCreatedOrNull() ?.let(block)
public inline fun ChatEvent.giveawayCreatedStarsOrNull(): GiveawayCreated.Stars? = this as?
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated.Stars
public inline fun ChatEvent.giveawayCreatedStarsOrThrow(): GiveawayCreated.Stars = this as
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated.Stars
public inline fun <T> ChatEvent.ifGiveawayCreatedStars(block: (GiveawayCreated.Stars) -> T): T? =
giveawayCreatedStarsOrNull() ?.let(block)
public inline fun ChatEvent.giveawayCreatedCompanionOrNull(): GiveawayCreated.Companion? = this as?
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated.Companion
public inline fun ChatEvent.giveawayCreatedCompanionOrThrow(): GiveawayCreated.Companion = this as
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated.Companion
public inline fun <T> ChatEvent.ifGiveawayCreatedCompanion(block: (GiveawayCreated.Companion) -> T):
T? = giveawayCreatedCompanionOrNull() ?.let(block)
public inline fun ChatEvent.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as?
dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
@@ -3591,6 +3744,49 @@ public inline fun ChatEvent.writeAccessAllowedOrThrow(): WriteAccessAllowed = th
public inline fun <T> ChatEvent.ifWriteAccessAllowed(block: (WriteAccessAllowed) -> T): T? =
writeAccessAllowedOrNull() ?.let(block)
public inline fun ChatEvent.writeAccessAllowedOtherOrNull(): WriteAccessAllowed.Other? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.Other
public inline fun ChatEvent.writeAccessAllowedOtherOrThrow(): WriteAccessAllowed.Other = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.Other
public inline fun <T> ChatEvent.ifWriteAccessAllowedOther(block: (WriteAccessAllowed.Other) -> T):
T? = writeAccessAllowedOtherOrNull() ?.let(block)
public inline fun ChatEvent.writeAccessAllowedFromWebAppLinkOrNull():
WriteAccessAllowed.FromWebAppLink? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromWebAppLink
public inline fun ChatEvent.writeAccessAllowedFromWebAppLinkOrThrow():
WriteAccessAllowed.FromWebAppLink = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromWebAppLink
public inline fun <T>
ChatEvent.ifWriteAccessAllowedFromWebAppLink(block: (WriteAccessAllowed.FromWebAppLink) -> T):
T? = writeAccessAllowedFromWebAppLinkOrNull() ?.let(block)
public inline fun ChatEvent.writeAccessAllowedFromRequestOrNull(): WriteAccessAllowed.FromRequest? =
this as? dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromRequest
public inline fun ChatEvent.writeAccessAllowedFromRequestOrThrow(): WriteAccessAllowed.FromRequest =
this as dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromRequest
public inline fun <T>
ChatEvent.ifWriteAccessAllowedFromRequest(block: (WriteAccessAllowed.FromRequest) -> T): T? =
writeAccessAllowedFromRequestOrNull() ?.let(block)
public inline fun ChatEvent.writeAccessAllowedFromAttachmentMenuOrNull():
WriteAccessAllowed.FromAttachmentMenu? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromAttachmentMenu
public inline fun ChatEvent.writeAccessAllowedFromAttachmentMenuOrThrow():
WriteAccessAllowed.FromAttachmentMenu = this as
dev.inmo.tgbotapi.types.message.ChatEvents.forum.WriteAccessAllowed.FromAttachmentMenu
public inline fun <T>
ChatEvent.ifWriteAccessAllowedFromAttachmentMenu(block: (WriteAccessAllowed.FromAttachmentMenu) -> T):
T? = writeAccessAllowedFromAttachmentMenuOrNull() ?.let(block)
public inline fun ChatEvent.videoChatEndedOrNull(): VideoChatEnded? = this as?
dev.inmo.tgbotapi.types.message.ChatEvents.voice.VideoChatEnded
@@ -3691,14 +3887,24 @@ public inline fun ForwardInfo.byUserOrThrow(): ForwardInfo.ByUser = this as
public inline fun <T> ForwardInfo.ifByUser(block: (ForwardInfo.ByUser) -> T): T? = byUserOrNull()
?.let(block)
public inline fun ForwardInfo.publicChatOrNull(): ForwardInfo.PublicChat? = this as?
public inline fun ForwardInfo.OrNull(): ForwardInfo.PublicChat? = this as?
dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat
public inline fun ForwardInfo.publicChatOrThrow(): ForwardInfo.PublicChat = this as
public inline fun ForwardInfo.OrThrow(): ForwardInfo.PublicChat = this as
dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat
public inline fun <T> ForwardInfo.ifPublicChat(block: (ForwardInfo.PublicChat) -> T): T? =
publicChatOrNull() ?.let(block)
public inline fun <T> ForwardInfo.`if`(block: (ForwardInfo.PublicChat) -> T): T? = OrNull()
?.let(block)
public inline fun ForwardInfo.sentByChannelOrNull(): ForwardInfo.PublicChat.SentByChannel? = this
as? dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat.SentByChannel
public inline fun ForwardInfo.sentByChannelOrThrow(): ForwardInfo.PublicChat.SentByChannel = this as
dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat.SentByChannel
public inline fun <T>
ForwardInfo.ifSentByChannel(block: (ForwardInfo.PublicChat.SentByChannel) -> T): T? =
sentByChannelOrNull() ?.let(block)
public inline fun ForwardInfo.fromChannelOrNull(): ForwardInfo.PublicChat.FromChannel? = this as?
dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat.FromChannel
@@ -3719,16 +3925,6 @@ public inline fun <T>
ForwardInfo.ifFromSupergroup(block: (ForwardInfo.PublicChat.FromSupergroup) -> T): T? =
fromSupergroupOrNull() ?.let(block)
public inline fun ForwardInfo.sentByChannelOrNull(): ForwardInfo.PublicChat.SentByChannel? = this
as? dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat.SentByChannel
public inline fun ForwardInfo.sentByChannelOrThrow(): ForwardInfo.PublicChat.SentByChannel = this as
dev.inmo.tgbotapi.types.message.ForwardInfo.PublicChat.SentByChannel
public inline fun <T>
ForwardInfo.ifSentByChannel(block: (ForwardInfo.PublicChat.SentByChannel) -> T): T? =
sentByChannelOrNull() ?.let(block)
public inline fun Message.channelEventMessageOrNull(): ChannelEventMessage<ChannelEvent>? = this as?
dev.inmo.tgbotapi.types.message.ChannelEventMessage<dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent>
@@ -4058,6 +4254,15 @@ public inline fun Message.possiblyOfflineMessageOrThrow(): PossiblyOfflineMessag
public inline fun <T> Message.ifPossiblyOfflineMessage(block: (PossiblyOfflineMessage) -> T): T? =
possiblyOfflineMessageOrNull() ?.let(block)
public inline fun Message.possiblyPaidMessageOrNull(): PossiblyPaidMessage? = this as?
dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaidMessage
public inline fun Message.possiblyPaidMessageOrThrow(): PossiblyPaidMessage = this as
dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaidMessage
public inline fun <T> Message.ifPossiblyPaidMessage(block: (PossiblyPaidMessage) -> T): T? =
possiblyPaidMessageOrNull() ?.let(block)
public inline fun Message.possiblyPaymentMessageOrNull(): PossiblyPaymentMessage? = this as?
dev.inmo.tgbotapi.types.message.abstracts.PossiblyPaymentMessage
@@ -5286,15 +5491,6 @@ public inline fun <T>
EncryptedPassportElement.ifEncryptedPassportElementWithSelfie(block: (EncryptedPassportElementWithSelfie) -> T):
T? = encryptedPassportElementWithSelfieOrNull() ?.let(block)
public inline fun RevenueWithdrawalState.failedOrNull(): RevenueWithdrawalState.Failed? = this as?
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Failed
public inline fun RevenueWithdrawalState.failedOrThrow(): RevenueWithdrawalState.Failed = this as
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Failed
public inline fun <T> RevenueWithdrawalState.ifFailed(block: (RevenueWithdrawalState.Failed) -> T):
T? = failedOrNull() ?.let(block)
public inline fun RevenueWithdrawalState.pendingOrNull(): RevenueWithdrawalState.Pending? = this as?
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Pending
@@ -5315,6 +5511,15 @@ public inline fun <T>
RevenueWithdrawalState.ifSucceeded(block: (RevenueWithdrawalState.Succeeded) -> T): T? =
succeededOrNull() ?.let(block)
public inline fun RevenueWithdrawalState.failedOrNull(): RevenueWithdrawalState.Failed? = this as?
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Failed
public inline fun RevenueWithdrawalState.failedOrThrow(): RevenueWithdrawalState.Failed = this as
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Failed
public inline fun <T> RevenueWithdrawalState.ifFailed(block: (RevenueWithdrawalState.Failed) -> T):
T? = failedOrNull() ?.let(block)
public inline fun RevenueWithdrawalState.unknownOrNull(): RevenueWithdrawalState.Unknown? = this as?
dev.inmo.tgbotapi.types.payments.stars.RevenueWithdrawalState.Unknown
@@ -5352,34 +5557,6 @@ public inline fun StarTransaction.unknownOrThrow(): StarTransaction.Unknown = th
public inline fun <T> StarTransaction.ifUnknown(block: (StarTransaction.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun TransactionPartner.adsOrNull(): TransactionPartner.Ads? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Ads
public inline fun TransactionPartner.adsOrThrow(): TransactionPartner.Ads = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Ads
public inline fun <T> TransactionPartner.ifAds(block: (TransactionPartner.Ads) -> T): T? =
adsOrNull() ?.let(block)
public inline fun TransactionPartner.affiliateProgramOrNull(): TransactionPartner.AffiliateProgram?
= this as? dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram
public inline fun TransactionPartner.affiliateProgramOrThrow(): TransactionPartner.AffiliateProgram
= this as dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram
public inline fun <T>
TransactionPartner.ifAffiliateProgram(block: (TransactionPartner.AffiliateProgram) -> T): T? =
affiliateProgramOrNull() ?.let(block)
public inline fun TransactionPartner.chatOrNull(): TransactionPartner.Chat? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Chat
public inline fun TransactionPartner.chatOrThrow(): TransactionPartner.Chat = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Chat
public inline fun <T> TransactionPartner.ifChat(block: (TransactionPartner.Chat) -> T): T? =
chatOrNull() ?.let(block)
public inline fun TransactionPartner.fragmentOrNull(): TransactionPartner.Fragment? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Fragment
@@ -5389,14 +5566,23 @@ public inline fun TransactionPartner.fragmentOrThrow(): TransactionPartner.Fragm
public inline fun <T> TransactionPartner.ifFragment(block: (TransactionPartner.Fragment) -> T): T? =
fragmentOrNull() ?.let(block)
public inline fun TransactionPartner.otherOrNull(): TransactionPartner.Other? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Other
public inline fun TransactionPartner.userOrNull(): TransactionPartner.User? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.User
public inline fun TransactionPartner.otherOrThrow(): TransactionPartner.Other = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Other
public inline fun TransactionPartner.userOrThrow(): TransactionPartner.User = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.User
public inline fun <T> TransactionPartner.ifOther(block: (TransactionPartner.Other) -> T): T? =
otherOrNull() ?.let(block)
public inline fun <T> TransactionPartner.ifUser(block: (TransactionPartner.User) -> T): T? =
userOrNull() ?.let(block)
public inline fun TransactionPartner.chatOrNull(): TransactionPartner.Chat? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Chat
public inline fun TransactionPartner.chatOrThrow(): TransactionPartner.Chat = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Chat
public inline fun <T> TransactionPartner.ifChat(block: (TransactionPartner.Chat) -> T): T? =
chatOrNull() ?.let(block)
public inline fun TransactionPartner.telegramAPIOrNull(): TransactionPartner.TelegramAPI? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.TelegramAPI
@@ -5408,6 +5594,34 @@ public inline fun <T>
TransactionPartner.ifTelegramAPI(block: (TransactionPartner.TelegramAPI) -> T): T? =
telegramAPIOrNull() ?.let(block)
public inline fun TransactionPartner.affiliateProgramOrNull(): TransactionPartner.AffiliateProgram?
= this as? dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram
public inline fun TransactionPartner.affiliateProgramOrThrow(): TransactionPartner.AffiliateProgram
= this as dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.AffiliateProgram
public inline fun <T>
TransactionPartner.ifAffiliateProgram(block: (TransactionPartner.AffiliateProgram) -> T): T? =
affiliateProgramOrNull() ?.let(block)
public inline fun TransactionPartner.adsOrNull(): TransactionPartner.Ads? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Ads
public inline fun TransactionPartner.adsOrThrow(): TransactionPartner.Ads = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Ads
public inline fun <T> TransactionPartner.ifAds(block: (TransactionPartner.Ads) -> T): T? =
adsOrNull() ?.let(block)
public inline fun TransactionPartner.otherOrNull(): TransactionPartner.Other? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Other
public inline fun TransactionPartner.otherOrThrow(): TransactionPartner.Other = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Other
public inline fun <T> TransactionPartner.ifOther(block: (TransactionPartner.Other) -> T): T? =
otherOrNull() ?.let(block)
public inline fun TransactionPartner.unknownOrNull(): TransactionPartner.Unknown? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.Unknown
@@ -5417,15 +5631,6 @@ public inline fun TransactionPartner.unknownOrThrow(): TransactionPartner.Unknow
public inline fun <T> TransactionPartner.ifUnknown(block: (TransactionPartner.Unknown) -> T): T? =
unknownOrNull() ?.let(block)
public inline fun TransactionPartner.userOrNull(): TransactionPartner.User? = this as?
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.User
public inline fun TransactionPartner.userOrThrow(): TransactionPartner.User = this as
dev.inmo.tgbotapi.types.payments.stars.TransactionPartner.User
public inline fun <T> TransactionPartner.ifUser(block: (TransactionPartner.User) -> T): T? =
userOrNull() ?.let(block)
public inline fun ScheduledCloseInfo.exactScheduledCloseInfoOrNull(): ExactScheduledCloseInfo? =
this as? dev.inmo.tgbotapi.types.polls.ExactScheduledCloseInfo
@@ -5481,15 +5686,6 @@ public inline fun Poll.quizPollOrThrow(): QuizPoll = this as dev.inmo.tgbotapi.t
public inline fun <T> Poll.ifQuizPoll(block: (QuizPoll) -> T): T? = quizPollOrNull() ?.let(block)
public inline fun Reaction.customEmojiOrNull(): Reaction.CustomEmoji? = this as?
dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji
public inline fun Reaction.customEmojiOrThrow(): Reaction.CustomEmoji = this as
dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji
public inline fun <T> Reaction.ifCustomEmoji(block: (Reaction.CustomEmoji) -> T): T? =
customEmojiOrNull() ?.let(block)
public inline fun Reaction.emojiOrNull(): Reaction.Emoji? = this as?
dev.inmo.tgbotapi.types.reactions.Reaction.Emoji
@@ -5499,6 +5695,15 @@ public inline fun Reaction.emojiOrThrow(): Reaction.Emoji = this as
public inline fun <T> Reaction.ifEmoji(block: (Reaction.Emoji) -> T): T? = emojiOrNull()
?.let(block)
public inline fun Reaction.customEmojiOrNull(): Reaction.CustomEmoji? = this as?
dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji
public inline fun Reaction.customEmojiOrThrow(): Reaction.CustomEmoji = this as
dev.inmo.tgbotapi.types.reactions.Reaction.CustomEmoji
public inline fun <T> Reaction.ifCustomEmoji(block: (Reaction.CustomEmoji) -> T): T? =
customEmojiOrNull() ?.let(block)
public inline fun Reaction.paidOrNull(): Reaction.Paid? = this as?
dev.inmo.tgbotapi.types.reactions.Reaction.Paid

View File

@@ -12,6 +12,8 @@ import dev.inmo.tgbotapi.webapps.invoice.InvoiceClosedInfo
import dev.inmo.tgbotapi.webapps.location.LocationManager
import dev.inmo.tgbotapi.webapps.orientation.DeviceOrientation
import dev.inmo.tgbotapi.webapps.popup.*
import dev.inmo.tgbotapi.webapps.storage.DeviceStorage
import dev.inmo.tgbotapi.webapps.storage.SecureStorage
import dev.inmo.tgbotapi.webapps.stories.StoryShareParams
external class WebApp {
@@ -104,6 +106,13 @@ external class WebApp {
@JsName("SettingsButton")
val settingsButton: SettingsButton
@JsName("DeviceStorage")
val deviceStorage: DeviceStorage
@JsName("SecureStorage")
val secureStorage: SecureStorage
internal fun onEvent(type: String, callback: () -> Unit)
fun offEvent(type: String, callback: () -> Unit)

View File

@@ -0,0 +1,167 @@
package dev.inmo.tgbotapi.webapps.storage
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.Deferred
/**
* This object is used to access the device's local storage.
*
* See [https://core.telegram.org/bots/webapps#devicestorage](https://core.telegram.org/bots/webapps#devicestorage) for more information.
*/
external interface DeviceStorage {
/**
* Stores a key-value pair.
*
* @param key The key to store the value under.
* @param value The value to store.
* @param callback A callback function that is called when the operation is complete. The first argument is an error object, if any, and the second argument is a boolean indicating whether the operation was successful.
*/
fun setItem(key: String, value: String, callback: (Throwable?, Boolean?) -> Unit): DeviceStorage
/**
* Retrieves the value associated with a key.
*
* @param key The key to retrieve the value for.
* @param callback A callback function that is called when the operation is complete. The first argument is an error object, if any, and the second argument is the value associated with the key, or null if the key is not found.
*/
fun getItem(key: String, callback: (Throwable?, String?) -> Unit): DeviceStorage
/**
* Removes the key-value pair associated with a key.
*
* @param key The key to remove.
* @param callback A callback function that is called when the operation is complete. The first argument is an error object, if any, and the second argument is a boolean indicating whether the operation was successful.
*/
fun removeItem(key: String, callback: (Throwable?, Boolean?) -> Unit): DeviceStorage
/**
* Clears all key-value pairs from the storage.
*
* @param callback A callback function that is called when the operation is complete. The first argument is an error object, if any, and the second argument is a boolean indicating whether the operation was successful.
*/
fun clear(callback: (Throwable?, Boolean?) -> Unit): DeviceStorage
}
/**
* Stores a key-value pair. This function uses a [CompletableDeferred] to handle the asynchronous callback and returns a [Result] object.
*
* @param key The key to store the value under.
* @param value The value to store.
* @return A [Result] object containing the result of the operation.
*/
suspend fun DeviceStorage.setWithResult(key: String, value: String): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
setItem(key, value) { error, result ->
if (error == null) {
deferred.complete(Result.success(result ?: false))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Retrieves the value associated with a key. This function uses a [CompletableDeferred] to handle the asynchronous callback and returns a [Result] object.
*
* @param key The key to retrieve the value for.
* @return A [Result] object containing the result of the operation.
*/
suspend fun DeviceStorage.getWithResult(key: String): Result<String?> {
val deferred = CompletableDeferred<Result<String?>>()
getItem(key) { error, result ->
if (error == null) {
deferred.complete(Result.success(result))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Removes the key-value pair associated with a key. This function uses a [CompletableDeferred] to handle the asynchronous callback and returns a [Result] object.
*
* @param key The key to remove.
* @return A [Result] object containing the result of the operation.
*/
suspend fun DeviceStorage.removeWithResult(key: String): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
removeItem(key) { error, result ->
if (error == null) {
deferred.complete(Result.success(result ?: false))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Clears all key-value pairs from the storage. This function uses a [CompletableDeferred] to handle the asynchronous callback and returns a [Result] object.
*
* @return A [Result] object containing the result of the operation.
*/
suspend fun DeviceStorage.clearWithResult(): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
clear { error, result ->
if (error == null) {
deferred.complete(Result.success(result ?: false))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Stores a key-value pair. This function suspends until the result is available and returns the result directly or throws an exception if an error occurred.
*
* @param key The key to store the value under.
* @param value The value to store.
* @return Boolean indicating whether the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun DeviceStorage.setItem(key: String, value: String): Boolean {
return setWithResult(key, value).getOrThrow()
}
/**
* Retrieves the value associated with a key. This function suspends until the result is available and returns the result directly or throws an exception if an error occurred.
*
* @param key The key to retrieve the value for.
* @return The value associated with the key, or null if the key is not found.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun DeviceStorage.getItem(key: String): String? {
return getWithResult(key).getOrThrow()
}
/**
* Removes the key-value pair associated with a key. This function suspends until the result is available and returns the result directly or throws an exception if an error occurred.
*
* @param key The key to remove.
* @return Boolean indicating whether the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun DeviceStorage.removeItem(key: String): Boolean {
return removeWithResult(key).getOrThrow()
}
/**
* Clears all key-value pairs from the storage. This function suspends until the result is available and returns the result directly or throws an exception if an error occurred.
*
* @return Boolean indicating whether the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun DeviceStorage.clear(): Boolean {
return clearWithResult().getOrThrow()
}

View File

@@ -0,0 +1,231 @@
package dev.inmo.tgbotapi.webapps.storage
import dev.inmo.micro_utils.common.Either
import dev.inmo.micro_utils.common.either
import kotlinx.coroutines.CompletableDeferred
/**
* This class provides access to the secure local storage, which is persistent and
* tied to the user's Telegram account. Data stored in secure storage is accessible
* only to the Web App that saved it.
*
* Use this storage to save sensitive data like access tokens or user preferences
* that should persist across sessions. Keep in mind that storage size is limited
* to 2 kilobytes.
*
* For non-sensitive data, consider using [DeviceStorage].
*
* @see [https://core.telegram.org/bots/webapps#securestorage](https://core.telegram.org/bots/webapps#securestorage)
*/
external class SecureStorage {
/**
* Stores a key-value pair in secure storage.
*
* @param key The key to store the value under.
* @param value The value to store.
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object, if any, and the second argument is a boolean
* indicating whether the operation was successful.
*/
fun setItem(key: String, value: String, callback: (error: Throwable?, isSuccessful: Boolean) -> Unit)
/**
* Retrieves the value associated with a key from secure storage.
*
* @param key The key to retrieve the value for.
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object, if any, the second argument is the value
* associated with the key, or null if the key is not found, and the third argument
* indicates whether the value can be restored.
*/
fun getItem(key: String, callback: (error: Throwable?, value: String?, canBeRestored: Boolean?) -> Unit)
/**
* Restores the value associated with a key in secure storage. This is useful if the
* value was previously removed using [removeItem] and needs to be retrieved again.
* Note that restoring a value is only possible if it hasn't been overwritten
* by a new value for the same key.
*
* @param key The key to restore the value for.
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object, if any, and the second argument is the restored
* value, or null if the key is not found or cannot be restored.
*/
fun restoreItem(key: String, callback: (error: Throwable?, value: String?) -> Unit)
/**
* Removes the key-value pair associated with a key from secure storage.
*
* @param key The key to remove.
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object, if any, and the second argument is a boolean
* indicating whether the operation was successful.
*/
fun removeItem(key: String, callback: (error: Throwable?, isSuccessful: Boolean) -> Unit)
/**
* Clears all key-value pairs from the secure storage.
*
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object, if any, and the second argument is a boolean
* indicating whether the operation was successful.
*/
fun clear(callback: (error: Throwable?, isSuccessful: Boolean) -> Unit)
}
/**
* Stores a key-value pair in secure storage using a [CompletableDeferred] and returns a [Result].
*
* @param key The key to store the value under.
* @param value The value to store.
* @return A [Result] object containing the result of the operation.
*/
suspend fun SecureStorage.setWithResult(key: String, value: String): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
setItem(key, value) { error, isSuccessful ->
if (error == null) {
deferred.complete(Result.success(isSuccessful))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Retrieves the value associated with a key from secure storage using a [CompletableDeferred] and returns a [Result].
* This suspending function encapsulates the asynchronous operation of retrieving a value
* and provides a structured way to handle both successful retrieval and potential errors.
* It uses a [CompletableDeferred] to manage the asynchronous result.
*
* @param key The key to retrieve the value for.
* @return A [Result] object containing the retrieved value (which can be null if the key is not found)
* or a [Throwable] representing the error that occurred.
*/
suspend fun SecureStorage.getWithResult(key: String): Result<Either<String?, Boolean>> {
val deferred = CompletableDeferred<Result<Either<String?, Boolean>>>()
getItem(key) { error, value, canBeRestored ->
when {
error != null -> deferred.complete(Result.failure(error))
value != null -> deferred.complete(Result.success(value.either()))
else -> deferred.complete(Result.success((canBeRestored == true).either()))
}
}
return deferred.await()
}
/**
* Restores the value associated with a key in secure storage using a [CompletableDeferred] and returns a [Result].
*
* @param key The key to restore the value for.
* @return A [Result] object containing the result of the operation.
*/
suspend fun SecureStorage.restoreWithResult(key: String): Result<String?> {
val deferred = CompletableDeferred<Result<String?>>()
restoreItem(key) { error, value ->
if (error == null) {
deferred.complete(Result.success(value))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Removes the key-value pair associated with a key from secure storage using a [CompletableDeferred] and returns a [Result].
*
* @param key The key to remove.
* @return A [Result] object containing the result of the operation.
*/
suspend fun SecureStorage.removeWithResult(key: String): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
removeItem(key) { error, isSuccessful ->
if (error == null) {
deferred.complete(Result.success(isSuccessful))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Clears all key-value pairs from the secure storage using a [CompletableDeferred] and returns a [Result].
*
* @return A [Result] object containing the result of the operation.
*/
suspend fun SecureStorage.clearWithResult(): Result<Boolean> {
val deferred = CompletableDeferred<Result<Boolean>>()
clear { error, isSuccessful ->
if (error == null) {
deferred.complete(Result.success(isSuccessful))
} else {
deferred.complete(Result.failure(error))
}
}
return deferred.await()
}
/**
* Stores a key-value pair in secure storage. This suspending function handles the result directly
* and throws an exception if an error occurs.
*
* @param key The key to store the value under.
* @param value The value to store.
* @return True if the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun SecureStorage.setItem(key: String, value: String): Boolean {
return setWithResult(key, value).getOrThrow()
}
/**
* Retrieves the value associated with a key from secure storage. This function uses a callback-based approach
* for handling the asynchronous result of the operation.
*
* @param key The key to retrieve the value for.
* @param callback A callback function that is called when the operation is complete.
* The first argument is an error object (a [Throwable] if an error occurred, or null otherwise),
* the second argument is the retrieved value (a [String] or null if the key is not found),
* and the third argument is a boolean indicating whether the value can be restored
* (useful if the value was previously removed and might be restorable).
*/
suspend fun SecureStorage.getItem(key: String): Either<String?, Boolean> {
return getWithResult(key).getOrThrow()
}
/**
* Restores the value associated with a key in secure storage. This suspending function handles
* the result directly and throws an exception if an error occurs.
*
* @param key The key to restore the value for.
* @return The restored value, or null if the key is not found or cannot be restored.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun SecureStorage.restoreItem(key: String): String? {
return restoreWithResult(key).getOrThrow()
}
/**
* Removes the key-value pair associated with a key from secure storage.
* This suspending function handles the result directly and throws an exception if an error occurs.
*
* @param key The key to remove.
* @return True if the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun SecureStorage.removeItem(key: String): Boolean {
return removeWithResult(key).getOrThrow()
}
/**
* Clears all key-value pairs from secure storage. This suspending function handles the result
* directly and throws an exception if an error occurs.
*
* @return True if the operation was successful.
* @throws Throwable If an error occurs during the operation.
*/
suspend fun SecureStorage.clear(): Boolean {
return clearWithResult().getOrThrow()
}