mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-27 16:39:20 +00:00
Compare commits
23 Commits
9.4.3
...
e66537ee32
| Author | SHA1 | Date | |
|---|---|---|---|
| e66537ee32 | |||
| 825ecc1d73 | |||
| 05bfbfe381 | |||
| 430240a6ad | |||
| 860e35258c | |||
| d9c39d7a26 | |||
| 52fd55eea5 | |||
| cb11532b58 | |||
| dce63713f9 | |||
| fb9ff653ef | |||
| 57f53813c8 | |||
| fc183bfd2f | |||
| c025a027c6 | |||
| db2101d85c | |||
| a01a9910b5 | |||
| 4e1ecc0e34 | |||
| 90225a9380 | |||
| 3026c8708d | |||
| 63975cc88e | |||
| a622c4d6fa | |||
| e124bb18df | |||
| 152728afca | |||
| 38d672b665 |
@@ -1,5 +1,11 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 10.0.0
|
||||
|
||||
**IN THIS UPDATE KLOCK DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-time` UP TO 5.3.0 VERSION**
|
||||
|
||||
**IN THIS UPDATE KRYPTO DEPENDENCY CHANGED TO `com.soywiz.korge:korlibs-crypto` UP TO 5.3.0 VERSION**
|
||||
|
||||
## 9.4.3
|
||||
|
||||
**IetfLanguageCode has been renamed to IetfLang in MicroUtils**
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=9.4.3
|
||||
library_version=10.0.0
|
||||
|
||||
@@ -6,14 +6,14 @@ kotlin-coroutines = "1.7.3"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "4.0.10"
|
||||
korlibs = "5.3.0"
|
||||
uuid = "0.8.2"
|
||||
ktor = "2.3.7"
|
||||
|
||||
ksp = "1.9.21-1.0.16"
|
||||
ksp = "1.9.22-1.0.16"
|
||||
kotlin-poet = "1.15.3"
|
||||
|
||||
microutils = "0.20.23"
|
||||
microutils = "0.20.25"
|
||||
kslog = "1.3.1"
|
||||
|
||||
versions = "0.50.0"
|
||||
@@ -41,11 +41,12 @@ ktor-server-host-common = { module = "io.ktor:ktor-server-host-common", version.
|
||||
|
||||
javax-activation = { module = "javax.activation:activation", version.ref = "javax-activation" }
|
||||
|
||||
korlibs-klock = { module = "com.soywiz.korlibs.klock:klock", version.ref = "korlibs" }
|
||||
korlibs-krypto = { module = "com.soywiz.korlibs.krypto:krypto", version.ref = "korlibs" }
|
||||
korlibs-klock = { module = "com.soywiz.korge:korlibs-time", version.ref = "korlibs" }
|
||||
korlibs-krypto = { module = "com.soywiz.korge:korlibs-crypto", version.ref = "korlibs" }
|
||||
|
||||
uuid = { module = "com.benasher44:uuid", version.ref = "uuid" }
|
||||
|
||||
microutils-colors-common = { module = "dev.inmo:micro_utils.colors.common", version.ref = "microutils" }
|
||||
microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.ref = "microutils" }
|
||||
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", version.ref = "microutils" }
|
||||
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.DeleteMessage
|
||||
import dev.inmo.tgbotapi.requests.DeleteMessages
|
||||
import dev.inmo.tgbotapi.requests.ForwardMessages
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.deleteMessages(
|
||||
chatId: ChatIdentifier,
|
||||
messageIds: List<MessageId>
|
||||
) = messageIds.chunked(deleteMessagesLimit.last).map {
|
||||
execute(
|
||||
DeleteMessages(
|
||||
chatId = chatId,
|
||||
messageIds = it
|
||||
)
|
||||
)
|
||||
}.all { it }
|
||||
|
||||
suspend fun TelegramBot.deleteMessages(
|
||||
chatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>
|
||||
) = deleteMessages(
|
||||
chatId = chatId,
|
||||
messageIds = messageIds.toList()
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteMessages(
|
||||
chatId: ChatIdentifier,
|
||||
firstMessageId: MessageId,
|
||||
vararg messageIds: MessageId
|
||||
) = deleteMessages(
|
||||
chatId = chatId,
|
||||
messageIds = (listOf(firstMessageId) + messageIds.toList())
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.deleteMessages(
|
||||
messages: List<Message>
|
||||
) = messages.groupBy { it.chat }.map { (chat, messages) ->
|
||||
deleteMessages(
|
||||
chatId = chat.id,
|
||||
messageIds = messages.map { it.messageId }
|
||||
)
|
||||
}.all { it }
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
messageIds: List<MessageId>
|
||||
) = deleteMessages(chatId = chatId, messageIds = messageIds)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>
|
||||
) = deleteMessages(chatId = chatId, messageIds = messageIds)
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
chatId: ChatIdentifier,
|
||||
firstMessageId: MessageId,
|
||||
secondMessageId: MessageId,
|
||||
vararg messageIds: MessageId
|
||||
) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList()))
|
||||
|
||||
suspend fun TelegramBot.delete(
|
||||
messages: List<Message>
|
||||
) = deleteMessages(messages)
|
||||
@@ -0,0 +1,156 @@
|
||||
package dev.inmo.tgbotapi.extensions.api
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.ForwardMessages
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.forwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: List<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = messageIds.chunked(forwardMessagesLimit.last).flatMap {
|
||||
execute(
|
||||
ForwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = it,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.forwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds.toList(),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
firstMessageId: MessageId,
|
||||
vararg messageIds: MessageId,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = (listOf(firstMessageId) + messageIds.toList()),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<Message>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = messages.groupBy { it.chat }.flatMap { (chat, messages) ->
|
||||
forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = chat.id,
|
||||
messageIds = messages.map { it.messageId },
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.forward(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: List<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forward(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forward(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
firstMessageId: MessageId,
|
||||
vararg messageIds: MessageId,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
firstMessageId = firstMessageId,
|
||||
messageIds = *messageIds,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.forward(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<Message>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = forwardMessages(
|
||||
toChatId = toChatId,
|
||||
messages = messages,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
@@ -24,6 +24,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
||||
import io.ktor.utils.io.core.Closeable
|
||||
import korlibs.time.millisecondsLong
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.CoroutineStart
|
||||
import kotlinx.coroutines.currentCoroutineContext
|
||||
|
||||
@@ -194,9 +194,9 @@ suspend fun TelegramBot.edit(
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -206,9 +206,9 @@ suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -218,10 +218,10 @@ suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -231,10 +231,10 @@ suspend fun TelegramBot.edit(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -244,9 +244,9 @@ suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
) = edit(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -255,9 +255,9 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = edit(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -266,10 +266,10 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -278,10 +278,10 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -290,10 +290,10 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -302,7 +302,7 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(message, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
@@ -74,9 +74,9 @@ suspend fun TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -85,9 +85,9 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -96,10 +96,10 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -108,7 +108,7 @@ suspend fun TelegramBot.edit(
|
||||
suspend fun TelegramBot.edit(
|
||||
messageId: InlineMessageIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = edit(messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = edit(messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
@@ -23,10 +24,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
EditChatMessageText(chatId, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -38,9 +39,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chat.id, messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -50,9 +51,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, text, parseMode, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -62,10 +63,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(
|
||||
EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
EditChatMessageText(chatId, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -76,10 +77,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -89,10 +90,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -102,9 +103,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chat.id, messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -114,10 +115,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -127,10 +128,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -139,9 +140,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -150,10 +151,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -162,10 +163,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: ContentMessage<TextContent>,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -175,9 +176,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, entities, linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -187,10 +188,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -200,7 +201,7 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
message: Message,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
@@ -18,9 +19,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, disableWebPagePreview, replyMarkup))
|
||||
) = execute(EditInlineMessageText(inlineMessageId, text, parseMode, linkPreviewOptions, replyMarkup))
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -29,9 +30,9 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup))
|
||||
) = execute(EditInlineMessageText(inlineMessageId, entities, linkPreviewOptions, replyMarkup))
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -40,10 +41,10 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -52,7 +53,7 @@ suspend fun TelegramBot.editMessageText(
|
||||
suspend fun TelegramBot.editMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
|
||||
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), linkPreviewOptions, replyMarkup)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.get
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.get.GetUserChatBoosts
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
|
||||
suspend fun TelegramBot.getUserChatBoosts(
|
||||
chatId: ChatIdentifier,
|
||||
userId: UserId
|
||||
) = execute(
|
||||
GetUserChatBoosts(chatId = chatId, userId = userId)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.getUserChatBoosts(
|
||||
chat: Chat,
|
||||
userId: UserId
|
||||
) = getUserChatBoosts(chatId = chat.id, userId = userId)
|
||||
@@ -0,0 +1,84 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.CopyMessages
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
|
||||
suspend fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: List<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = messageIds.chunked(copyMessagesLimit.last).flatMap {
|
||||
execute(
|
||||
CopyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = it,
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = copyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds.toList(),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
firstMessageId: MessageId,
|
||||
vararg messageIds: MessageId,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = copyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = (listOf(firstMessageId) + messageIds.toList()),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.copyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
messages: List<Message>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = messages.groupBy { it.chat }.flatMap { (chat, messages) ->
|
||||
copyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = chat.id,
|
||||
messageIds = messages.map { it.messageId },
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
}
|
||||
@@ -176,7 +176,7 @@ suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@@ -185,7 +185,7 @@ suspend inline fun TelegramBot.reply(
|
||||
to.chat,
|
||||
text,
|
||||
parseMode,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
to.threadIdOrNull,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -201,7 +201,7 @@ suspend inline fun TelegramBot.reply(
|
||||
suspend inline fun TelegramBot.reply(
|
||||
to: Message,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
@@ -209,7 +209,7 @@ suspend inline fun TelegramBot.reply(
|
||||
) = sendTextMessage(
|
||||
to.chat,
|
||||
entities,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
to.threadIdOrNull,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -225,13 +225,13 @@ suspend inline fun TelegramBot.reply(
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -240,13 +240,13 @@ suspend fun TelegramBot.reply(
|
||||
suspend fun TelegramBot.reply(
|
||||
to: Message,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
) = reply(to, buildEntities(separator, builderBody), linkPreviewOptions, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Venue
|
||||
|
||||
@@ -187,7 +187,7 @@ suspend inline fun TelegramBot.reply(
|
||||
toMessageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -197,7 +197,7 @@ suspend inline fun TelegramBot.reply(
|
||||
toChatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
threadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -214,7 +214,7 @@ suspend inline fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -223,7 +223,7 @@ suspend inline fun TelegramBot.reply(
|
||||
) = sendTextMessage(
|
||||
toChatId,
|
||||
entities,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
threadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -240,14 +240,14 @@ suspend fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -257,14 +257,14 @@ suspend fun TelegramBot.reply(
|
||||
toChatId: IdChatIdentifier,
|
||||
toMessageId: MessageId,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
// Venue
|
||||
|
||||
@@ -19,7 +19,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -31,7 +31,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
chatId,
|
||||
text,
|
||||
parseMode,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
threadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
@@ -49,7 +49,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -57,7 +57,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(
|
||||
chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -68,14 +68,14 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -86,14 +86,14 @@ suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chat.id, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -102,7 +102,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -110,7 +110,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = execute(
|
||||
SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
SendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -120,7 +120,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -128,7 +128,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -146,7 +146,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -155,7 +155,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -163,7 +163,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(
|
||||
chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
|
||||
)
|
||||
|
||||
/**
|
||||
@@ -173,7 +173,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -181,7 +181,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -191,7 +191,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -199,7 +199,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||
@@ -208,14 +208,14 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -224,7 +224,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -232,7 +232,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -242,7 +242,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendMessage(
|
||||
chat: Chat,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -250,7 +250,7 @@ suspend fun TelegramBot.sendMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -260,14 +260,14 @@ suspend fun TelegramBot.sendMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat.id, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -276,7 +276,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -284,7 +284,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -294,7 +294,7 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
suspend fun TelegramBot.sendTextMessage(
|
||||
chat: Chat,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -302,4 +302,4 @@ suspend fun TelegramBot.sendTextMessage(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
@@ -550,14 +550,14 @@ suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chatId, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chatId, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendTextMessage] request
|
||||
@@ -568,14 +568,14 @@ suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat, text, parseMode, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendTextMessage] request
|
||||
@@ -585,14 +585,14 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chatId, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -601,7 +601,7 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -609,7 +609,7 @@ suspend fun TelegramBot.send(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -619,7 +619,7 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chatId: ChatIdentifier,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -627,7 +627,7 @@ suspend fun TelegramBot.send(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = send(chatId, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -638,14 +638,14 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
replyToMessageId: MessageId? = null,
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null
|
||||
) = sendTextMessage(chat, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = sendTextMessage(chat, entities, linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||
@@ -654,7 +654,7 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
separator: TextSource? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -662,7 +662,7 @@ suspend fun TelegramBot.send(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
|
||||
/**
|
||||
@@ -672,7 +672,7 @@ suspend fun TelegramBot.send(
|
||||
suspend fun TelegramBot.send(
|
||||
chat: Chat,
|
||||
separator: String,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chat.id.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -680,7 +680,7 @@ suspend fun TelegramBot.send(
|
||||
allowSendingWithoutReply: Boolean? = null,
|
||||
replyMarkup: KeyboardMarkup? = null,
|
||||
builderBody: EntitiesBuilderBody
|
||||
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
) = send(chat, buildEntities(separator, builderBody), linkPreviewOptions, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||
|
||||
/**
|
||||
* Will execute [sendPhoto] request
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package dev.inmo.tgbotapi.extensions.api.send
|
||||
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.requests.send.SendAction
|
||||
import dev.inmo.tgbotapi.requests.send.SetMessageReactions
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
import dev.inmo.tgbotapi.types.actions.*
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import dev.inmo.tgbotapi.types.threadId
|
||||
|
||||
suspend fun TelegramBot.setMessageReactions(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
reactions: List<Reaction>,
|
||||
big: Boolean = false
|
||||
) = execute(
|
||||
SetMessageReactions(chatId, messageId, reactions, big)
|
||||
)
|
||||
|
||||
suspend fun TelegramBot.setMessageReaction(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
reaction: Reaction?,
|
||||
big: Boolean = false
|
||||
) = setMessageReactions(chatId, messageId, listOfNotNull(reaction), big)
|
||||
|
||||
suspend fun TelegramBot.setMessageReactions(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
reactions: List<Reaction>,
|
||||
big: Boolean = false
|
||||
) = setMessageReactions(chat.id, messageId, reactions, big)
|
||||
|
||||
suspend fun TelegramBot.setMessageReaction(
|
||||
chat: Chat,
|
||||
messageId: MessageId,
|
||||
reaction: Reaction?,
|
||||
big: Boolean = false
|
||||
) = setMessageReaction(chat.id, messageId, reaction, big)
|
||||
|
||||
suspend fun TelegramBot.setMessageReactions(
|
||||
message: Message,
|
||||
reactions: List<Reaction>,
|
||||
big: Boolean = false
|
||||
) = setMessageReactions(message.chat, message.messageId, reactions, big)
|
||||
|
||||
suspend fun TelegramBot.setMessageReaction(
|
||||
message: Message,
|
||||
reaction: Reaction?,
|
||||
big: Boolean = false
|
||||
) = setMessageReaction(message.chat, message.messageId, reaction, big)
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatBoostRemovedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostRemoved(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ChatBoostRemoved> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.chatBoostRemovedUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatBoostUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
suspend fun BehaviourContext.waitChatBoostUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ChatBoostUpdated> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
it.chatBoostUpdatedUpdateOrNull() ?.data.let(::listOfNotNull)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||
suspend inline fun <reified O : ChatMessageReactionUpdated> BehaviourContext.waitChatMessageReactionUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<O> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? O).let(::listOfNotNull)
|
||||
}
|
||||
|
||||
suspend fun BehaviourContext.waitChatMessageReactionUpdatedByUser(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChatMessageReactionUpdated<ChatMessageReactionUpdated.ByUser>(initRequest, errorFactory)
|
||||
|
||||
|
||||
suspend fun BehaviourContext.waitChatMessageReactionUpdatedByChat(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitChatMessageReactionUpdated<ChatMessageReactionUpdated.ByChat>(initRequest, errorFactory)
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionsCountUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
suspend inline fun BehaviourContext.waitChatMessageReactionsCountUpdated(
|
||||
initRequest: Request<*>? = null,
|
||||
noinline errorFactory: NullableRequestBuilder<*> = { null }
|
||||
): Flow<ChatMessageReactionsCountUpdated> = expectFlow(
|
||||
initRequest,
|
||||
errorFactory
|
||||
) {
|
||||
(it.chatMessageReactionsCountUpdatedUpdateOrNull() ?.data).let(::listOfNotNull)
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -202,7 +202,7 @@ suspend fun BehaviourContext.waitChatSharedRequest(
|
||||
suspend fun BehaviourContext.waitUserShared(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEvents<UserShared>(initRequest, errorFactory)
|
||||
) = waitEvents<UsersShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatShared(
|
||||
initRequest: Request<*>? = null,
|
||||
|
||||
@@ -19,7 +19,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -196,7 +196,7 @@ suspend fun BehaviourContext.waitChatSharedRequestEventsMessages(
|
||||
suspend fun BehaviourContext.waitUserSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
errorFactory: NullableRequestBuilder<*> = { null }
|
||||
) = waitEventsMessages<UserShared>(initRequest, errorFactory)
|
||||
) = waitEventsMessages<UsersShared>(initRequest, errorFactory)
|
||||
|
||||
suspend fun BehaviourContext.waitChatSharedEventsMessages(
|
||||
initRequest: Request<*>? = null,
|
||||
|
||||
@@ -55,7 +55,7 @@ suspend fun <BC : BehaviourContext> BC.onUnhandledInlineMessageIdDataCallbackQue
|
||||
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||
) = onCallbackQuery (
|
||||
initialFilter * !SimpleFilter<MessageDataCallbackQuery> { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) },
|
||||
initialFilter * !SimpleFilter<InlineMessageIdDataCallbackQuery> { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) },
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTwoTypesReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTypeReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdChatBoostRemovedMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatBoostRemovedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
/**
|
||||
* @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] 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.onChatBoostRemoved(
|
||||
initialFilter: SimpleFilter<ChatBoostRemoved>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatBoostRemoved, Update>? = null,
|
||||
markerFactory: MarkerFactory<ChatBoostRemoved, Any> = ByIdChatBoostRemovedMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatBoostRemoved>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.chatBoostRemovedUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTwoTypesReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.CustomBehaviourContextAndTypeReceiver
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdChatBoostUpdatedMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatBoostUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
/**
|
||||
* @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] 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.onChatBoostUpdated(
|
||||
initialFilter: SimpleFilter<ChatBoostUpdated>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatBoostUpdated, Update>? = null,
|
||||
markerFactory: MarkerFactory<ChatBoostUpdated, Any> = ByIdChatBoostUpdatedMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatBoostUpdated>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.chatBoostUpdatedUpdateOrNull() ?.data) ?.let(::listOfNotNull)
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
@file:Suppress("unused")
|
||||
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatIdChatMessageReactionUpdatedMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||
import dev.inmo.tgbotapi.extensions.utils.chatMessageReactionUpdatedUpdateOrNull
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatMessageReactionUpdated> BC.onChatMessageReactionUpdated(
|
||||
initialFilter: SimpleFilter<T>? = null,
|
||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
|
||||
markerFactory: MarkerFactory<in T, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||
(it.chatMessageReactionUpdatedUpdateOrNull() ?.data as? T) ?.let(::listOfNotNull)
|
||||
}
|
||||
|
||||
/**
|
||||
* @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] 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.onChatMessageReactionUpdatedByUser(
|
||||
initialFilter: SimpleFilter<ChatMessageReactionUpdated.ByUser>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.ByUser, Update>? = null,
|
||||
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.ByUser, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.ByUser>
|
||||
) = onChatMessageReactionUpdated(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
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] 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.onChatMessageReactionUpdatedByChat(
|
||||
initialFilter: SimpleFilter<ChatMessageReactionUpdated.ByChat>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.ByChat, Update>? = null,
|
||||
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.ByChat, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.ByChat>
|
||||
) = onChatMessageReactionUpdated(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
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] 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.onChatMessageReactionUpdatedUnknown(
|
||||
initialFilter: SimpleFilter<ChatMessageReactionUpdated.Unknown>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatMessageReactionUpdated.Unknown, Update>? = null,
|
||||
markerFactory: MarkerFactory<in ChatMessageReactionUpdated.Unknown, Any> = ByChatIdChatMessageReactionUpdatedMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatMessageReactionUpdated.Unknown>
|
||||
) = onChatMessageReactionUpdated(
|
||||
initialFilter,
|
||||
subcontextUpdatesFilter,
|
||||
markerFactory,
|
||||
scenarioReceiver
|
||||
)
|
||||
@@ -25,7 +25,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
|
||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.onEvent(
|
||||
@@ -776,10 +776,10 @@ suspend fun <BC : BehaviourContext> BC.onChatSharedRequest(
|
||||
* data
|
||||
*/
|
||||
suspend fun <BC : BehaviourContext> BC.onUserShared(
|
||||
initialFilter: SimpleFilter<PrivateEventMessage<UserShared>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UserShared>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<UserShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UserShared>>
|
||||
initialFilter: SimpleFilter<PrivateEventMessage<UsersShared>>? = null,
|
||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<UsersShared>, Update>? = MessageFilterByChat,
|
||||
markerFactory: MarkerFactory<in ChatEventMessage<UsersShared>, Any> = ByChatMessageMarkerFactory,
|
||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<UsersShared>>
|
||||
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||
|
||||
object ByIdChatBoostRemovedMarkerFactory : MarkerFactory<ChatBoostRemoved, Any> {
|
||||
override suspend fun invoke(data: ChatBoostRemoved) = data.chat.id
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||
|
||||
object ByIdChatBoostUpdatedMarkerFactory : MarkerFactory<ChatBoostUpdated, Any> {
|
||||
override suspend fun invoke(data: ChatBoostUpdated) = data.chat.id
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
|
||||
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
|
||||
object ByChatIdChatMessageReactionUpdatedMarkerFactory : MarkerFactory<ChatMessageReactionUpdated, Any> {
|
||||
override suspend fun invoke(data: ChatMessageReactionUpdated) = data.chat.id
|
||||
}
|
||||
@@ -22,6 +22,7 @@ kotlin {
|
||||
api libs.korlibs.krypto
|
||||
api libs.uuid
|
||||
|
||||
api libs.microutils.colors.common
|
||||
api libs.microutils.coroutines
|
||||
api libs.microutils.serialization.base64
|
||||
api libs.microutils.serialization.encapsulator
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
|
||||
/**
|
||||
* All inheritors of this interface have [messageId] field and related to this [messageId]
|
||||
*/
|
||||
interface WithMessageId {
|
||||
val messageId: MessageId
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package dev.inmo.tgbotapi.abstracts
|
||||
|
||||
interface WithPreviewChatAndMessageId : WithPreviewChat, WithMessageId
|
||||
@@ -1,5 +0,0 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
interface DisableWebPagePreview {
|
||||
val disableWebPagePreview: Boolean?
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||
|
||||
interface LinkPreviewOptionsContainer {
|
||||
val linkPreviewOptions: LinkPreviewOptions?
|
||||
val disableWebPagePreview: Boolean?
|
||||
get() = linkPreviewOptions ?.isDisabled != true
|
||||
}
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("LinkPreviewOptionsContainer", "dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer"))
|
||||
typealias DisableWebPagePreview = LinkPreviewOptionsContainer
|
||||
@@ -1,7 +1,5 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.abstracts.WithMessageId
|
||||
|
||||
interface MessageAction: ChatRequest {
|
||||
val messageId: MessageId
|
||||
}
|
||||
interface MessageAction : ChatRequest, WithMessageId
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.inmo.tgbotapi.abstracts.types
|
||||
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
|
||||
interface MessagesAction: ChatRequest {
|
||||
val messageIds: List<MessageId>
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.inmo.tgbotapi.requests
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class DeleteMessages(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(messageIdsField)
|
||||
override val messageIds: List<MessageId>
|
||||
) : SimpleRequest<Boolean>, MessagesAction {
|
||||
override fun method(): String = "deleteMessages"
|
||||
|
||||
init {
|
||||
require(messageIds.size in deleteMessagesLimit) {
|
||||
"Messages count for deleteMessages must be in $deleteMessagesLimit range"
|
||||
}
|
||||
}
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package dev.inmo.tgbotapi.requests
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
fun ForwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = ForwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds.toList(),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
fun ForwardMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
vararg messageIds: MessageId,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = ForwardMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = (listOf(messageId) + messageIds.toList()),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class ForwardMessages (
|
||||
@SerialName(chatIdField)
|
||||
val toChatId: ChatIdentifier,
|
||||
@SerialName(fromChatIdField)
|
||||
val fromChatId: ChatIdentifier,
|
||||
@SerialName(messageIdsField)
|
||||
override val messageIds: List<MessageId>,
|
||||
@SerialName(messageThreadIdField)
|
||||
override val threadId: MessageThreadId? = toChatId.threadId,
|
||||
@SerialName(disableNotificationField)
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(protectContentField)
|
||||
override val protectContent: Boolean = false,
|
||||
@SerialName(removeCaptionField)
|
||||
private val removeCaption: Boolean = false
|
||||
): SimpleRequest<List<MessageId>>,
|
||||
MessagesAction,
|
||||
ProtectContent,
|
||||
OptionallyMessageThreadRequest,
|
||||
DisableNotification {
|
||||
override val chatId: ChatIdentifier
|
||||
get() = fromChatId
|
||||
|
||||
init {
|
||||
require(messageIds.size in forwardMessagesLimit) {
|
||||
"Messages count for forwardMessages must be in $forwardMessagesLimit range"
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "forwardMessages"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<List<MessageId>>
|
||||
get() = ListSerializer(MessageIdSerializer)
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package dev.inmo.tgbotapi.requests.edit.abstracts
|
||||
|
||||
interface EditDisableWebPagePreviewMessage {
|
||||
val disableWebPagePreview: Boolean?
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.requests.edit.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||
|
||||
interface EditLinkPreviewOptionsContainer : LinkPreviewOptionsContainer
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("EditLinkPreviewOptionsContainer", "dev.inmo.tgbotapi.requests.edit.abstracts.EditLinkPreviewOptionsContainer"))
|
||||
typealias EditDisableWebPagePreviewMessage = EditLinkPreviewOptionsContainer
|
||||
@@ -22,7 +22,7 @@ fun EditChatMessageText(
|
||||
messageId: MessageId,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditChatMessageText(
|
||||
chatId,
|
||||
@@ -30,7 +30,7 @@ fun EditChatMessageText(
|
||||
text,
|
||||
parseMode,
|
||||
null,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@@ -38,7 +38,7 @@ fun EditChatMessageText(
|
||||
chatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditChatMessageText(
|
||||
chatId,
|
||||
@@ -46,7 +46,7 @@ fun EditChatMessageText(
|
||||
entities.makeString(),
|
||||
null,
|
||||
entities.toRawMessageEntities(),
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@@ -62,11 +62,11 @@ data class EditChatMessageText internal constructor(
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(entitiesField)
|
||||
private val rawEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null,
|
||||
@SerialName(linkPreviewOptionsField)
|
||||
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
) : EditChatMessage<TextContent>, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
}
|
||||
|
||||
@@ -16,28 +16,28 @@ fun EditInlineMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditInlineMessageText(
|
||||
inlineMessageId,
|
||||
text,
|
||||
parseMode,
|
||||
null,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
fun EditInlineMessageText(
|
||||
inlineMessageId: InlineMessageIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
replyMarkup: InlineKeyboardMarkup? = null
|
||||
) = EditInlineMessageText(
|
||||
inlineMessageId,
|
||||
entities.makeString(),
|
||||
null,
|
||||
entities.toRawMessageEntities(),
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
replyMarkup
|
||||
)
|
||||
|
||||
@@ -51,11 +51,11 @@ data class EditInlineMessageText internal constructor(
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(entitiesField)
|
||||
private val rawEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null,
|
||||
@SerialName(linkPreviewOptionsField)
|
||||
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
@SerialName(replyMarkupField)
|
||||
override val replyMarkup: InlineKeyboardMarkup? = null
|
||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditDisableWebPagePreviewMessage {
|
||||
) : EditInlineMessage, EditTextChatMessage, EditReplyMessage, EditLinkPreviewOptionsContainer {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.inmo.tgbotapi.requests.get
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.boosts.UserChatBoosts
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
|
||||
@Serializable
|
||||
data class GetUserChatBoosts(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId
|
||||
) : SimpleRequest<UserChatBoosts>, ChatRequest {
|
||||
override fun method(): String = "getUserChatBoosts"
|
||||
override val resultDeserializer: DeserializationStrategy<UserChatBoosts>
|
||||
get() = UserChatBoosts.serializer()
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package dev.inmo.tgbotapi.requests.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||
import dev.inmo.tgbotapi.abstracts.types.MessagesAction
|
||||
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.message.*
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
fun CopyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageIds: Array<MessageId>,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = CopyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = messageIds.toList(),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
fun CopyMessages(
|
||||
toChatId: ChatIdentifier,
|
||||
fromChatId: ChatIdentifier,
|
||||
messageId: MessageId,
|
||||
vararg messageIds: MessageId,
|
||||
threadId: MessageThreadId? = toChatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
removeCaption: Boolean = false
|
||||
) = CopyMessages(
|
||||
toChatId = toChatId,
|
||||
fromChatId = fromChatId,
|
||||
messageIds = (listOf(messageId) + messageIds.toList()),
|
||||
threadId = threadId,
|
||||
disableNotification = disableNotification,
|
||||
protectContent = protectContent,
|
||||
removeCaption = removeCaption
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class CopyMessages (
|
||||
@SerialName(chatIdField)
|
||||
val toChatId: ChatIdentifier,
|
||||
@SerialName(fromChatIdField)
|
||||
val fromChatId: ChatIdentifier,
|
||||
@SerialName(messageIdsField)
|
||||
override val messageIds: List<MessageId>,
|
||||
@SerialName(messageThreadIdField)
|
||||
override val threadId: MessageThreadId? = toChatId.threadId,
|
||||
@SerialName(disableNotificationField)
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(protectContentField)
|
||||
override val protectContent: Boolean = false,
|
||||
@SerialName(removeCaptionField)
|
||||
private val removeCaption: Boolean = false
|
||||
): SimpleRequest<List<MessageId>>,
|
||||
MessagesAction,
|
||||
ProtectContent,
|
||||
OptionallyMessageThreadRequest,
|
||||
DisableNotification {
|
||||
override val chatId: ChatIdentifier
|
||||
get() = fromChatId
|
||||
|
||||
init {
|
||||
require(messageIds.size in copyMessagesLimit) {
|
||||
"Messages count for copyMessages must be in $copyMessagesLimit range"
|
||||
}
|
||||
}
|
||||
|
||||
override fun method(): String = "copyMessages"
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<List<MessageId>>
|
||||
get() = ListSerializer(MessageIdSerializer)
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package dev.inmo.tgbotapi.requests.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview
|
||||
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
@@ -24,7 +24,7 @@ fun SendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -37,7 +37,7 @@ fun SendTextMessage(
|
||||
parseMode,
|
||||
null,
|
||||
threadId,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
@@ -48,7 +48,7 @@ fun SendTextMessage(
|
||||
fun SendTextMessage(
|
||||
chatId: ChatIdentifier,
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null,
|
||||
linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
threadId: MessageThreadId? = chatId.threadId,
|
||||
disableNotification: Boolean = false,
|
||||
protectContent: Boolean = false,
|
||||
@@ -61,7 +61,7 @@ fun SendTextMessage(
|
||||
null,
|
||||
entities.toRawMessageEntities(),
|
||||
threadId,
|
||||
disableWebPagePreview,
|
||||
linkPreviewOptions,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
replyToMessageId,
|
||||
@@ -81,8 +81,8 @@ data class SendTextMessage internal constructor(
|
||||
private val rawEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(messageThreadIdField)
|
||||
override val threadId: MessageThreadId? = chatId.threadId,
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null,
|
||||
@SerialName(linkPreviewOptionsField)
|
||||
override val linkPreviewOptions: LinkPreviewOptions? = null,
|
||||
@SerialName(disableNotificationField)
|
||||
override val disableNotification: Boolean = false,
|
||||
@SerialName(protectContentField)
|
||||
@@ -96,7 +96,7 @@ data class SendTextMessage internal constructor(
|
||||
) : SendMessageRequest<ContentMessage<TextContent>>,
|
||||
ReplyingMarkupSendMessageRequest<ContentMessage<TextContent>>,
|
||||
TextableSendMessageRequest<ContentMessage<TextContent>>,
|
||||
DisableWebPagePreview
|
||||
LinkPreviewOptionsContainer
|
||||
{
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package dev.inmo.tgbotapi.requests.send
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.SerializationStrategy
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
|
||||
@Serializable
|
||||
data class SetMessageReactions(
|
||||
@SerialName(chatIdField)
|
||||
override val chatId: ChatIdentifier,
|
||||
@SerialName(messageIdField)
|
||||
val messageId: MessageId,
|
||||
@SerialName(reactionField)
|
||||
val reactions: List<Reaction>,
|
||||
@SerialName(isBigField)
|
||||
val big: Boolean = false
|
||||
) : SimpleRequest<Boolean>, ChatRequest {
|
||||
override fun method(): String = "setMessageReaction"
|
||||
|
||||
override val requestSerializer: SerializationStrategy<*>
|
||||
get() = serializer()
|
||||
|
||||
override val resultDeserializer: DeserializationStrategy<Boolean>
|
||||
get() = Boolean.serializer()
|
||||
}
|
||||
@@ -16,6 +16,8 @@ import dev.inmo.tgbotapi.types.message.content.PollContent
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.types.polls.*
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import korlibs.time.millisecondsLong
|
||||
import korlibs.time.seconds
|
||||
import kotlinx.serialization.*
|
||||
|
||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PollContent>> = TelegramBotAPIMessageDeserializationStrategyClass()
|
||||
|
||||
@@ -145,7 +145,7 @@ sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||
object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
||||
MapperSerializer<CreateNewStickerSet.SurrogateCreateNewSticker, CreateNewStickerSet>(
|
||||
CreateNewStickerSet.SurrogateCreateNewSticker.serializer(),
|
||||
{
|
||||
{ it ->
|
||||
CreateNewStickerSet.SurrogateCreateNewSticker(
|
||||
it.userId,
|
||||
it.name,
|
||||
@@ -156,7 +156,7 @@ object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
||||
(it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting
|
||||
)
|
||||
},
|
||||
{
|
||||
{ it ->
|
||||
when (it.stickerType) {
|
||||
StickerType.CustomEmoji -> CreateNewStickerSet.CustomEmoji(
|
||||
it.userId,
|
||||
|
||||
@@ -57,7 +57,7 @@ sealed interface InputSticker {
|
||||
|
||||
object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<InputStickerSerializer.SurrogateInputSticker, InputSticker>(
|
||||
SurrogateInputSticker.serializer(),
|
||||
{
|
||||
{ it ->
|
||||
when (it) {
|
||||
is InputSticker.Mask -> SurrogateInputSticker(
|
||||
it.sticker,
|
||||
@@ -82,7 +82,7 @@ object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<Inpu
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
{ it ->
|
||||
when (it.internalType) {
|
||||
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||
it.sticker,
|
||||
|
||||
@@ -175,6 +175,12 @@ val keywordsInStickerLimit = 0 .. 20
|
||||
|
||||
val stickerKeywordLengthLimit = 0 .. 64
|
||||
|
||||
val keyboardButtonRequestUserLimit = 1 .. 10
|
||||
|
||||
val forwardMessagesLimit = 1 .. 100
|
||||
val copyMessagesLimit = forwardMessagesLimit
|
||||
val deleteMessagesLimit = forwardMessagesLimit
|
||||
|
||||
const val botActionActualityTime: Seconds = 5
|
||||
|
||||
val cloudStorageKeyLimit = 1 .. 128
|
||||
@@ -196,13 +202,18 @@ const val tgWebAppStartParamField = "tgWebAppStartParam"
|
||||
const val chatIdField = "chat_id"
|
||||
const val senderChatIdField = "sender_chat_id"
|
||||
const val messageIdField = "message_id"
|
||||
const val giveawayMessageIdField = "giveaway_message_id"
|
||||
const val messageIdsField = "message_ids"
|
||||
const val actorChatField = "actor_chat"
|
||||
const val messageThreadIdField = "message_thread_id"
|
||||
const val mediaGroupIdField = "media_group_id"
|
||||
const val updateIdField = "update_id"
|
||||
const val fromChatIdField = "from_chat_id"
|
||||
const val disableWebPagePreviewField = "disable_web_page_preview"
|
||||
const val linkPreviewOptionsField = "link_preview_options"
|
||||
const val disableNotificationField = "disable_notification"
|
||||
const val protectContentField = "protect_content"
|
||||
const val removeCaptionField = "remove_caption"
|
||||
const val replyToMessageIdField = "reply_to_message_id"
|
||||
const val allowSendingWithoutReplyField = "allow_sending_without_reply"
|
||||
const val replyMarkupField = "reply_markup"
|
||||
@@ -221,6 +232,10 @@ const val hasPrivateForwardsField = "has_private_forwards"
|
||||
const val hasRestrictedVoiceAndVideoMessagesField = "has_restricted_voice_and_video_messages"
|
||||
const val emojiStatusCustomEmojiIdField = "emoji_status_custom_emoji_id"
|
||||
const val emojiStatusExpirationDateField = "emoji_status_expiration_date"
|
||||
const val accentColorIdField = "accent_color_id"
|
||||
const val profileAccentColorIdField = "profile_accent_color_id"
|
||||
const val backgroundCustomEmojiIdField = "background_custom_emoji_id"
|
||||
const val profileBackgroundCustomEmojiIdField = "profile_background_custom_emoji_id"
|
||||
const val iconCustomEmojiIdField = "icon_custom_emoji_id"
|
||||
const val canJoinGroupsField = "can_join_groups"
|
||||
const val canReadAllGroupMessagesField = "can_read_all_group_messages"
|
||||
@@ -229,6 +244,7 @@ const val textEntitiesField = "text_entities"
|
||||
const val entitiesField = "entities"
|
||||
const val stickerSetNameField = "set_name"
|
||||
const val customEmojiIdField = "custom_emoji_id"
|
||||
const val customEmojiField = "custom_emoji"
|
||||
const val customEmojiIdsField = "custom_emoji_ids"
|
||||
const val premiumAnimationField = "premium_animation"
|
||||
const val stickerSetNameFullField = "sticker_set_name"
|
||||
@@ -236,6 +252,7 @@ const val slowModeDelayField = "slow_mode_delay"
|
||||
const val maskPositionField = "mask_position"
|
||||
const val phoneNumberField = "phone_number"
|
||||
const val userIdField = "user_id"
|
||||
const val userIdsField = "user_ids"
|
||||
const val onlyIfBannedField = "only_if_banned"
|
||||
const val containsMasksField = "contains_masks"
|
||||
const val resultIdField = "result_id"
|
||||
@@ -322,8 +339,10 @@ const val requestContactField = "request_contact"
|
||||
const val requestLocationField = "request_location"
|
||||
const val requestPollField = "request_poll"
|
||||
const val requestUserField = "request_user"
|
||||
const val requestUsersField = "request_users"
|
||||
const val requestChatField = "request_chat"
|
||||
const val requestIdField = "request_id"
|
||||
const val maxQuantityField = "max_quantity"
|
||||
|
||||
const val userIsBotField = "user_is_bot"
|
||||
const val userIsPremiumField = "user_is_premium"
|
||||
@@ -460,7 +479,14 @@ const val fromField = "from"
|
||||
const val userChatIdField = "user_chat_id"
|
||||
const val userField = "user"
|
||||
const val dateField = "date"
|
||||
const val reactionsField = "reactions"
|
||||
const val reactionField = "reaction"
|
||||
const val availableReactionsField = "available_reactions"
|
||||
const val isBigField = "is_big"
|
||||
const val oldReactionField = "old_reaction"
|
||||
const val newReactionField = "new_reaction"
|
||||
const val chatField = "chat"
|
||||
const val chatsField = "chats"
|
||||
const val usernameField = "username"
|
||||
const val bioField = "bio"
|
||||
const val nameField = "name"
|
||||
@@ -523,6 +549,8 @@ const val shippingQueryIdField = "shipping_query_id"
|
||||
const val preCheckoutQueryIdField = "pre_checkout_query_id"
|
||||
const val shippingOptionsField = "shipping_options"
|
||||
const val countryCodeField = "country_code"
|
||||
const val countryCodesField = "country_codes"
|
||||
const val totalCountField = "total_count"
|
||||
const val stateField = "state"
|
||||
const val cityField = "city"
|
||||
const val firstStreetLineField = "street_line1"
|
||||
@@ -536,6 +564,10 @@ const val providerTokenField = "provider_token"
|
||||
const val providerDataField = "provider_data"
|
||||
const val usersField = "users"
|
||||
const val startDateField = "start_date"
|
||||
const val showAboveTextField = "show_above_text"
|
||||
const val isDisabledField = "is_disabled"
|
||||
const val preferSmallMediaField = "prefer_small_media"
|
||||
const val preferLargeMediaField = "prefer_large_media"
|
||||
|
||||
const val requireNameField = "need_name"
|
||||
const val requirePhoneNumberField = "need_phone_number"
|
||||
@@ -584,6 +616,7 @@ const val secretField = "secret"
|
||||
|
||||
const val errorsField = "errors"
|
||||
const val sourceField = "source"
|
||||
const val isUnclaimedField = "is_unclaimed"
|
||||
const val fieldNameField = "field_name"
|
||||
const val dataHashField = "data_hash"
|
||||
const val fileHashField = "file_hash"
|
||||
@@ -609,3 +642,20 @@ const val buttonTextField = "button_text"
|
||||
const val webAppField = "web_app"
|
||||
const val webAppNameField = "web_app_name"
|
||||
const val menuButtonField = "menu_button"
|
||||
|
||||
const val boostIdField = "boost_id"
|
||||
const val boostField = "boost"
|
||||
const val addDateField = "add_date"
|
||||
const val expirationDateField = "expiration_date"
|
||||
const val removeDateField = "remove_date"
|
||||
const val boostsField = "boosts"
|
||||
const val winnersSelectionDateField = "winners_selection_date"
|
||||
const val winnersCountField = "winner_count"
|
||||
const val onlyNewMembersField = "only_new_members"
|
||||
const val hasPublicWinnersField = "has_public_winners"
|
||||
const val prizeDescriptionField = "prize_description"
|
||||
const val premiumSubscriptionMonthCountField = "premium_subscription_month_count"
|
||||
const val winnersField = "winners"
|
||||
const val additionalChatCountField = "additional_chat_count"
|
||||
const val unclaimedPrizeCountField = "unclaimed_prize_count"
|
||||
const val wasRefundedField = "was_refunded"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.InlineQueries.InputMessageContent
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||
import dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview
|
||||
import dev.inmo.tgbotapi.abstracts.types.LinkPreviewOptionsContainer
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||
@@ -19,16 +19,16 @@ import kotlinx.serialization.Serializable
|
||||
fun InputTextMessageContent(
|
||||
text: String,
|
||||
parseMode: ParseMode? = null,
|
||||
disableWebPagePreview: Boolean? = null
|
||||
) = InputTextMessageContent(text, parseMode, null, disableWebPagePreview)
|
||||
linkPreviewOptions: LinkPreviewOptions? = null
|
||||
) = InputTextMessageContent(text, parseMode, null, linkPreviewOptions)
|
||||
|
||||
/**
|
||||
* Represents the [InputMessageContent] of a text message to be sent as the result of an inline query.
|
||||
*/
|
||||
fun InputTextMessageContent(
|
||||
entities: TextSourcesList,
|
||||
disableWebPagePreview: Boolean? = null
|
||||
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), disableWebPagePreview)
|
||||
linkPreviewOptions: LinkPreviewOptions? = null
|
||||
) = InputTextMessageContent(entities.makeString(), null, entities.toRawMessageEntities(), linkPreviewOptions)
|
||||
|
||||
@Serializable
|
||||
data class InputTextMessageContent internal constructor(
|
||||
@@ -38,9 +38,9 @@ data class InputTextMessageContent internal constructor(
|
||||
override val parseMode: ParseMode? = null,
|
||||
@SerialName(entitiesField)
|
||||
private val rawEntities: List<RawMessageEntity>? = null,
|
||||
@SerialName(disableWebPagePreviewField)
|
||||
override val disableWebPagePreview: Boolean? = null
|
||||
) : TextedOutput, DisableWebPagePreview, InputMessageContent {
|
||||
@SerialName(linkPreviewOptionsField)
|
||||
override val linkPreviewOptions: LinkPreviewOptions? = null
|
||||
) : TextedOutput, LinkPreviewOptionsContainer, InputMessageContent {
|
||||
override val textSources: TextSourcesList? by lazy {
|
||||
rawEntities ?.asTextSources(text)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package dev.inmo.tgbotapi.types
|
||||
|
||||
import kotlinx.serialization.Required
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface LinkPreviewOptions {
|
||||
val isDisabled: Boolean
|
||||
val url: String?
|
||||
val preferSmallMedia: Boolean
|
||||
val preferLargeMedia: Boolean
|
||||
val showAboveText: Boolean
|
||||
|
||||
@Serializable
|
||||
data object Disabled : LinkPreviewOptions {
|
||||
@Required
|
||||
@SerialName(isDisabledField)
|
||||
override val isDisabled: Boolean = true
|
||||
override val url: String?
|
||||
get() = null
|
||||
override val preferSmallMedia: Boolean
|
||||
get() = false
|
||||
override val preferLargeMedia: Boolean
|
||||
get() = false
|
||||
override val showAboveText: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Large(
|
||||
@SerialName(urlField)
|
||||
override val url: String?,
|
||||
@SerialName(showAboveTextField)
|
||||
override val showAboveText: Boolean
|
||||
) : LinkPreviewOptions {
|
||||
@Required
|
||||
@SerialName(isDisabledField)
|
||||
override val isDisabled: Boolean = false
|
||||
@Required
|
||||
@SerialName(preferLargeMediaField)
|
||||
override val preferLargeMedia: Boolean = true
|
||||
override val preferSmallMedia: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Small(
|
||||
@SerialName(urlField)
|
||||
override val url: String?,
|
||||
@SerialName(showAboveTextField)
|
||||
override val showAboveText: Boolean
|
||||
) : LinkPreviewOptions {
|
||||
@Required
|
||||
@SerialName(isDisabledField)
|
||||
override val isDisabled: Boolean = false
|
||||
@Required
|
||||
@SerialName(preferSmallMediaField)
|
||||
override val preferSmallMedia: Boolean = true
|
||||
override val preferLargeMedia: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Medium(
|
||||
@SerialName(urlField)
|
||||
override val url: String?,
|
||||
@SerialName(showAboveTextField)
|
||||
override val showAboveText: Boolean
|
||||
) : LinkPreviewOptions {
|
||||
@Required
|
||||
@SerialName(isDisabledField)
|
||||
override val isDisabled: Boolean = false
|
||||
override val preferSmallMedia: Boolean
|
||||
get() = false
|
||||
override val preferLargeMedia: Boolean
|
||||
get() = false
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,29 @@ const val UPDATE_POLL_ANSWER = "poll_answer"
|
||||
const val UPDATE_MY_CHAT_MEMBER = "my_chat_member"
|
||||
const val UPDATE_CHAT_MEMBER = "chat_member"
|
||||
const val UPDATE_CHAT_JOIN_REQUEST = "chat_join_request"
|
||||
const val UPDATE_MESSAGE_REACTION = "message_reaction"
|
||||
const val UPDATE_MESSAGE_REACTION_COUNT = "message_reaction_count"
|
||||
|
||||
val ALL_UPDATES_LIST = listOf(
|
||||
UPDATE_MESSAGE,
|
||||
UPDATE_EDITED_MESSAGE,
|
||||
UPDATE_CHANNEL_POST,
|
||||
UPDATE_EDITED_CHANNEL_POST,
|
||||
UPDATE_CHOSEN_INLINE_RESULT,
|
||||
UPDATE_INLINE_QUERY,
|
||||
UPDATE_CALLBACK_QUERY,
|
||||
UPDATE_SHIPPING_QUERY,
|
||||
UPDATE_PRE_CHECKOUT_QUERY,
|
||||
UPDATE_POLL,
|
||||
UPDATE_POLL_ANSWER,
|
||||
UPDATE_MY_CHAT_MEMBER,
|
||||
UPDATE_CHAT_MEMBER,
|
||||
UPDATE_CHAT_JOIN_REQUEST,
|
||||
UPDATE_MESSAGE_REACTION,
|
||||
UPDATE_MESSAGE_REACTION_COUNT
|
||||
)
|
||||
|
||||
val ALL_UPDATES_LIST_WITHOUT_REACTIONS = listOf(
|
||||
UPDATE_MESSAGE,
|
||||
UPDATE_EDITED_MESSAGE,
|
||||
UPDATE_CHANNEL_POST,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class BoostId(
|
||||
val string: String
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoost(
|
||||
@SerialName(boostIdField)
|
||||
val id: BoostId,
|
||||
@SerialName(addDateField)
|
||||
val addDate: TelegramDate,
|
||||
@SerialName(expirationDateField)
|
||||
val expirationDate: TelegramDate,
|
||||
@SerialName(sourceField)
|
||||
val source: ChatBoostSource
|
||||
)
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostRemoved(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(boostIdField)
|
||||
val boostId: BoostId,
|
||||
@SerialName(removeDateField)
|
||||
val removeDate: TelegramDate,
|
||||
@SerialName(sourceField)
|
||||
val source: ChatBoostSource
|
||||
) : WithPreviewChat
|
||||
@@ -0,0 +1,171 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Required
|
||||
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.JsonDecoder
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.json.decodeFromJsonElement
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface ChatBoostSource {
|
||||
val sourceName: String
|
||||
val user: PreviewUser?
|
||||
|
||||
sealed interface ByUser : ChatBoostSource {
|
||||
override val user: PreviewUser
|
||||
}
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
data class Premium(
|
||||
@SerialName(userField)
|
||||
override val user: PreviewUser
|
||||
) : ByUser {
|
||||
@Required
|
||||
@SerialName(sourceField)
|
||||
override val sourceName: String = sourceCode
|
||||
|
||||
companion object {
|
||||
const val sourceCode = "premium"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
data class GiftCode(
|
||||
@SerialName(userField)
|
||||
override val user: PreviewUser
|
||||
) : ByUser {
|
||||
@Required
|
||||
@SerialName(sourceField)
|
||||
override val sourceName: String = sourceCode
|
||||
|
||||
companion object {
|
||||
const val sourceCode = "gift_code"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
sealed interface Giveaway : ChatBoostSource, WithMessageId {
|
||||
val unclaimed: Boolean
|
||||
val claimed: Boolean
|
||||
get() = !unclaimed
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
data class Claimed(
|
||||
@SerialName(giveawayMessageIdField)
|
||||
override val messageId: MessageId,
|
||||
@SerialName(userField)
|
||||
override val user: PreviewUser
|
||||
) : Giveaway, ByUser {
|
||||
@Required
|
||||
@SerialName(sourceField)
|
||||
override val sourceName: String = Giveaway.sourceCode
|
||||
@Required
|
||||
@SerialName(isUnclaimedField)
|
||||
override val unclaimed: Boolean = false
|
||||
}
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
data class Unclaimed(
|
||||
@SerialName(giveawayMessageIdField)
|
||||
override val messageId: MessageId
|
||||
) : Giveaway {
|
||||
@Required
|
||||
@SerialName(sourceField)
|
||||
override val sourceName: String = Giveaway.sourceCode
|
||||
@Required
|
||||
@SerialName(isUnclaimedField)
|
||||
override val unclaimed: Boolean = true
|
||||
@SerialName(userField)
|
||||
override val user: PreviewUser? = null
|
||||
}
|
||||
|
||||
companion object {
|
||||
val sourceCode = "giveaway"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(ChatBoostSource.Companion::class)
|
||||
data class Unknown(
|
||||
override val sourceName: String,
|
||||
override val user: PreviewUser?,
|
||||
val json: JsonElement?
|
||||
) : ChatBoostSource
|
||||
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
@Required
|
||||
@SerialName(sourceField)
|
||||
val sourceName: String,
|
||||
@SerialName(userField)
|
||||
val user: PreviewUser? = null,
|
||||
@SerialName(giveawayMessageIdField)
|
||||
val messageId: MessageId? = null,
|
||||
@SerialName(isUnclaimedField)
|
||||
val unclaimed: Boolean? = null
|
||||
)
|
||||
|
||||
companion object : KSerializer<ChatBoostSource> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatBoostSource {
|
||||
val (surrogate, json) = when {
|
||||
decoder is JsonDecoder -> {
|
||||
val json = decoder.decodeJsonElement()
|
||||
val surrogate = decoder.json.decodeFromJsonElement(Surrogate.serializer(), json)
|
||||
surrogate to json
|
||||
}
|
||||
else -> Surrogate.serializer().deserialize(decoder) to null
|
||||
}
|
||||
|
||||
return when {
|
||||
surrogate.sourceName == Premium.sourceCode && surrogate.user != null -> {
|
||||
Premium(surrogate.user)
|
||||
}
|
||||
surrogate.sourceName == GiftCode.sourceCode && surrogate.user != null -> {
|
||||
GiftCode(surrogate.user)
|
||||
}
|
||||
surrogate.sourceName == Giveaway.sourceCode && surrogate.messageId != null -> {
|
||||
when {
|
||||
surrogate.user != null && surrogate.unclaimed == false -> Giveaway.Claimed(
|
||||
surrogate.messageId,
|
||||
surrogate.user
|
||||
)
|
||||
surrogate.unclaimed == true -> Giveaway.Unclaimed(
|
||||
surrogate.messageId
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
} ?: Unknown(surrogate.sourceName, surrogate.user, json)
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ChatBoostSource) {
|
||||
if (value is Unknown && value.json != null) {
|
||||
JsonElement.serializer().serialize(encoder, value.json)
|
||||
return
|
||||
}
|
||||
|
||||
val surrogate = Surrogate(
|
||||
value.sourceName,
|
||||
value.user,
|
||||
(value as? Giveaway) ?.messageId,
|
||||
(value as? Giveaway) ?.unclaimed,
|
||||
)
|
||||
|
||||
Surrogate.serializer().serialize(encoder, surrogate)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.types.boostField
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.chatField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostUpdated(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(boostField)
|
||||
val boost: ChatBoost
|
||||
) : WithPreviewChat
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.boosts
|
||||
|
||||
import dev.inmo.tgbotapi.types.boostsField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserChatBoosts(
|
||||
@SerialName(boostsField)
|
||||
val boosts: List<ChatBoost>
|
||||
)
|
||||
@@ -103,13 +103,13 @@ data class RequestPollKeyboardButton(
|
||||
*
|
||||
* In case you will use [dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUserShared] it is
|
||||
* recommended to use [kotlinx.coroutines.flow.Flow] [kotlinx.coroutines.flow.filter] with checking of incoming
|
||||
* [dev.inmo.tgbotapi.types.request.UserShared.requestId]
|
||||
* [dev.inmo.tgbotapi.types.request.UsersShared.requestId]
|
||||
*/
|
||||
@Serializable
|
||||
data class RequestUserKeyboardButton(
|
||||
override val text: String,
|
||||
@SerialName(requestUserField)
|
||||
val requestUser: KeyboardButtonRequestUser
|
||||
@SerialName(requestUsersField)
|
||||
val requestUsers: KeyboardButtonRequestUsers
|
||||
) : KeyboardButton
|
||||
|
||||
/**
|
||||
@@ -160,11 +160,11 @@ object KeyboardButtonSerializer : KSerializer<KeyboardButton> {
|
||||
asJson[requestPollField] ?.jsonObject ?: buildJsonObject { }
|
||||
)
|
||||
)
|
||||
asJson is JsonObject && asJson[requestUserField] != null -> RequestUserKeyboardButton(
|
||||
asJson is JsonObject && asJson[requestUsersField] != null -> RequestUserKeyboardButton(
|
||||
asJson[textField]!!.jsonPrimitive.content,
|
||||
nonstrictJsonFormat.decodeFromJsonElement(
|
||||
KeyboardButtonRequestUser.serializer(),
|
||||
asJson[requestUserField] ?.jsonObject ?: buildJsonObject { }
|
||||
KeyboardButtonRequestUsers.serializer(),
|
||||
asJson[requestUsersField] ?.jsonObject ?: buildJsonObject { }
|
||||
)
|
||||
)
|
||||
asJson is JsonObject && asJson[requestChatField] != null -> RequestChatKeyboardButton(
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.buttons
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.request.RequestId
|
||||
import dev.inmo.tgbotapi.types.requestIdField
|
||||
import dev.inmo.tgbotapi.types.userIsBotField
|
||||
import dev.inmo.tgbotapi.types.userIsPremiumField
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import kotlinx.serialization.EncodeDefault
|
||||
import kotlinx.serialization.KSerializer
|
||||
@@ -14,17 +12,20 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(KeyboardButtonRequestUser.Companion::class)
|
||||
@Serializable(KeyboardButtonRequestUsers.Companion::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface KeyboardButtonRequestUser {
|
||||
sealed interface KeyboardButtonRequestUsers {
|
||||
val requestId: RequestId
|
||||
val isBot: Boolean?
|
||||
val maxCount: Int
|
||||
|
||||
@Serializable
|
||||
data class Any(
|
||||
@SerialName(requestIdField)
|
||||
override val requestId: RequestId
|
||||
) : KeyboardButtonRequestUser {
|
||||
override val requestId: RequestId,
|
||||
@SerialName(maxQuantityField)
|
||||
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||
) : KeyboardButtonRequestUsers {
|
||||
@SerialName(userIsBotField)
|
||||
@EncodeDefault
|
||||
override val isBot: Boolean? = null
|
||||
@@ -35,8 +36,10 @@ sealed interface KeyboardButtonRequestUser {
|
||||
@SerialName(requestIdField)
|
||||
override val requestId: RequestId,
|
||||
@SerialName(userIsPremiumField)
|
||||
val isPremium: Boolean? = null
|
||||
) : KeyboardButtonRequestUser {
|
||||
val isPremium: Boolean? = null,
|
||||
@SerialName(maxQuantityField)
|
||||
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||
) : KeyboardButtonRequestUsers {
|
||||
@SerialName(userIsBotField)
|
||||
@EncodeDefault
|
||||
override val isBot: Boolean = false
|
||||
@@ -45,15 +48,17 @@ sealed interface KeyboardButtonRequestUser {
|
||||
@Serializable
|
||||
data class Bot(
|
||||
@SerialName(requestIdField)
|
||||
override val requestId: RequestId
|
||||
) : KeyboardButtonRequestUser {
|
||||
override val requestId: RequestId,
|
||||
@SerialName(maxQuantityField)
|
||||
override val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||
) : KeyboardButtonRequestUsers {
|
||||
@SerialName(userIsBotField)
|
||||
@EncodeDefault
|
||||
override val isBot: Boolean = true
|
||||
}
|
||||
|
||||
@Serializer(KeyboardButtonRequestUser::class)
|
||||
companion object : KSerializer<KeyboardButtonRequestUser> {
|
||||
@Serializer(KeyboardButtonRequestUsers::class)
|
||||
companion object : KSerializer<KeyboardButtonRequestUsers> {
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
@SerialName(requestIdField)
|
||||
@@ -61,31 +66,37 @@ sealed interface KeyboardButtonRequestUser {
|
||||
@SerialName(userIsBotField)
|
||||
val userIsBot: Boolean? = null,
|
||||
@SerialName(userIsPremiumField)
|
||||
val userIsPremium: Boolean? = null
|
||||
val userIsPremium: Boolean? = null,
|
||||
@SerialName(maxQuantityField)
|
||||
val maxCount: Int = keyboardButtonRequestUserLimit.first
|
||||
)
|
||||
private val realSerializer = Surrogate.serializer()
|
||||
|
||||
override val descriptor: SerialDescriptor = realSerializer.descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUser {
|
||||
override fun deserialize(decoder: Decoder): KeyboardButtonRequestUsers {
|
||||
val surrogate = realSerializer.deserialize(decoder)
|
||||
|
||||
return when (surrogate.userIsBot) {
|
||||
true -> Bot(surrogate.requestId)
|
||||
false -> Common(surrogate.requestId, surrogate.userIsPremium)
|
||||
null -> Any(surrogate.requestId)
|
||||
true -> Bot(surrogate.requestId, surrogate.maxCount)
|
||||
false -> Common(surrogate.requestId, surrogate.userIsPremium, surrogate.maxCount)
|
||||
null -> Any(surrogate.requestId, surrogate.maxCount)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUser) {
|
||||
override fun serialize(encoder: Encoder, value: KeyboardButtonRequestUsers) {
|
||||
realSerializer.serialize(
|
||||
encoder,
|
||||
Surrogate(
|
||||
value.requestId,
|
||||
value.isBot,
|
||||
(value as? Common) ?.isPremium
|
||||
(value as? Common) ?.isPremium,
|
||||
value.maxCount
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("KeyboardButtonRequestUsers", "dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers"))
|
||||
typealias KeyboardButtonRequestUser = KeyboardButtonRequestUsers
|
||||
@@ -57,25 +57,25 @@ inline fun webAppReplyButton(
|
||||
*/
|
||||
inline fun requestUserReplyButton(
|
||||
text: String,
|
||||
requestUser: KeyboardButtonRequestUser
|
||||
requestUser: KeyboardButtonRequestUsers
|
||||
) = RequestUserKeyboardButton(
|
||||
text,
|
||||
requestUser
|
||||
)
|
||||
|
||||
/**
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Bot]
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Bot]
|
||||
*/
|
||||
inline fun requestBotReplyButton(
|
||||
text: String,
|
||||
requestId: RequestId
|
||||
) = requestUserReplyButton(
|
||||
text,
|
||||
KeyboardButtonRequestUser.Bot(requestId)
|
||||
KeyboardButtonRequestUsers.Bot(requestId)
|
||||
)
|
||||
|
||||
/**
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Common]
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Common]
|
||||
*/
|
||||
inline fun requestUserReplyButton(
|
||||
text: String,
|
||||
@@ -83,18 +83,18 @@ inline fun requestUserReplyButton(
|
||||
premiumUser: Boolean? = null
|
||||
) = requestUserReplyButton(
|
||||
text,
|
||||
KeyboardButtonRequestUser.Common(requestId, premiumUser)
|
||||
KeyboardButtonRequestUsers.Common(requestId, premiumUser)
|
||||
)
|
||||
|
||||
/**
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUser.Any]
|
||||
* Creates [RequestUserKeyboardButton] with [KeyboardButtonRequestUsers.Any]
|
||||
*/
|
||||
inline fun requestUserOrBotReplyButton(
|
||||
text: String,
|
||||
requestId: RequestId
|
||||
) = requestUserReplyButton(
|
||||
text,
|
||||
KeyboardButtonRequestUser.Any(requestId)
|
||||
KeyboardButtonRequestUsers.Any(requestId)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
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 kotlinx.serialization.json.JsonDecoder
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@Serializable(ChatMessageReactionUpdated.Companion::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface ChatMessageReactionUpdated : WithPreviewChatAndMessageId {
|
||||
val reactedUser: PreviewUser?
|
||||
val reactedChat: PreviewChat?
|
||||
val date: TelegramDate
|
||||
val old: List<Reaction>
|
||||
val new: List<Reaction>
|
||||
|
||||
@Serializable(Companion::class)
|
||||
data class ByUser(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(userField)
|
||||
override val reactedUser: PreviewUser,
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(oldReactionField)
|
||||
override val old: List<Reaction>,
|
||||
@SerialName(newReactionField)
|
||||
override val new: List<Reaction>
|
||||
) : ChatMessageReactionUpdated {
|
||||
override val reactedChat: PreviewChat?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable(Companion::class)
|
||||
data class ByChat(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(actorChatField)
|
||||
override val reactedChat: PreviewChat,
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(oldReactionField)
|
||||
override val old: List<Reaction>,
|
||||
@SerialName(newReactionField)
|
||||
override val new: List<Reaction>
|
||||
) : ChatMessageReactionUpdated {
|
||||
override val reactedUser: PreviewUser?
|
||||
get() = null
|
||||
}
|
||||
|
||||
@Serializable(Companion::class)
|
||||
data class Unknown(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier,
|
||||
@SerialName(actorChatField)
|
||||
override val reactedChat: PreviewChat?,
|
||||
@SerialName(userField)
|
||||
override val reactedUser: PreviewUser?,
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
@SerialName(dateField)
|
||||
override val date: TelegramDate,
|
||||
@SerialName(oldReactionField)
|
||||
override val old: List<Reaction>,
|
||||
@SerialName(newReactionField)
|
||||
override val new: List<Reaction>,
|
||||
val source: JsonElement?
|
||||
) : ChatMessageReactionUpdated
|
||||
|
||||
@Serializable
|
||||
data class Surrogate internal constructor(
|
||||
@SerialName(chatField)
|
||||
val chat: PreviewChat,
|
||||
@SerialName(messageIdField)
|
||||
val messageId: MessageIdentifier,
|
||||
@SerialName(userField)
|
||||
val reactedUser: PreviewUser? = null,
|
||||
@SerialName(actorChatField)
|
||||
val reactedChat: PreviewChat? = null,
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
@SerialName(dateField)
|
||||
val date: TelegramDate,
|
||||
@SerialName(oldReactionField)
|
||||
val old: List<Reaction>,
|
||||
@SerialName(newReactionField)
|
||||
val new: List<Reaction>
|
||||
)
|
||||
|
||||
companion object : KSerializer<ChatMessageReactionUpdated> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): ChatMessageReactionUpdated {
|
||||
val (surrogate, jsonElement) = if (decoder is JsonDecoder) {
|
||||
val jsonElement = decoder.decodeJsonElement()
|
||||
decoder.json.decodeFromJsonElement(Surrogate.serializer(), jsonElement) to jsonElement
|
||||
} else {
|
||||
Surrogate.serializer().deserialize(decoder) to null
|
||||
}
|
||||
return when {
|
||||
surrogate.reactedUser != null -> ByUser(
|
||||
surrogate.chat,
|
||||
surrogate.messageId,
|
||||
surrogate.reactedUser,
|
||||
surrogate.date,
|
||||
surrogate.old,
|
||||
surrogate.new
|
||||
)
|
||||
surrogate.reactedChat != null -> ByChat(
|
||||
surrogate.chat,
|
||||
surrogate.messageId,
|
||||
surrogate.reactedChat,
|
||||
surrogate.date,
|
||||
surrogate.old,
|
||||
surrogate.new
|
||||
)
|
||||
else -> Unknown(
|
||||
surrogate.chat,
|
||||
surrogate.messageId,
|
||||
surrogate.reactedUser,
|
||||
surrogate.reactedChat,
|
||||
surrogate.date,
|
||||
surrogate.old,
|
||||
surrogate.new,
|
||||
jsonElement
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: ChatMessageReactionUpdated) {
|
||||
if (value is Unknown && value.source != null) {
|
||||
JsonElement.serializer().serialize(encoder, value.source)
|
||||
} else {
|
||||
Surrogate(
|
||||
value.chat,
|
||||
value.messageId,
|
||||
value.reactedUser,
|
||||
value.reactedChat,
|
||||
value.date,
|
||||
value.old,
|
||||
value.new
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.reactions.ReactionsCount
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatMessageReactionsCountUpdated(
|
||||
@SerialName(chatField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(messageIdField)
|
||||
override val messageId: MessageIdentifier,
|
||||
@Serializable(TelegramDateSerializer::class)
|
||||
@SerialName(dateField)
|
||||
val date: TelegramDate,
|
||||
@SerialName(reactionsField)
|
||||
val reactions: List<ReactionsCount>
|
||||
) : WithPreviewChatAndMessageId
|
||||
@@ -1,8 +1,10 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
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
|
||||
@@ -32,7 +34,21 @@ data class ExtendedChannelChatImpl(
|
||||
@SerialName(linkedChatIdField)
|
||||
override val linkedGroupChatId: IdChatIdentifier? = null,
|
||||
@SerialName(hasHiddenMembersField)
|
||||
override val membersHidden: Boolean = false
|
||||
override val membersHidden: Boolean = false,
|
||||
@SerialName(availableReactionsField)
|
||||
override val availableReactions: List<Reaction>? = null,
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
override val statusEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(emojiStatusExpirationDateField)
|
||||
override val statusEmojiExpiration: TelegramDate? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : ExtendedChannelChat
|
||||
|
||||
@Serializable
|
||||
@@ -54,7 +70,21 @@ data class ExtendedGroupChatImpl(
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
override val pinnedMessage: Message? = null,
|
||||
@SerialName(hasHiddenMembersField)
|
||||
override val membersHidden: Boolean = false
|
||||
override val membersHidden: Boolean = false,
|
||||
@SerialName(availableReactionsField)
|
||||
override val availableReactions: List<Reaction>? = null,
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
override val statusEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(emojiStatusExpirationDateField)
|
||||
override val statusEmojiExpiration: TelegramDate? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : ExtendedGroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -81,7 +111,15 @@ data class ExtendedPrivateChatImpl(
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
override val statusEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(emojiStatusExpirationDateField)
|
||||
override val statusEmojiExpiration: TelegramDate? = null
|
||||
override val statusEmojiExpiration: TelegramDate? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : ExtendedPrivateChat
|
||||
|
||||
typealias ExtendedUser = ExtendedPrivateChatImpl
|
||||
@@ -125,7 +163,21 @@ data class ExtendedSupergroupChatImpl(
|
||||
@SerialName(hasAggressiveAntiSpamEnabledField)
|
||||
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
||||
@SerialName(hasHiddenMembersField)
|
||||
override val membersHidden: Boolean = false
|
||||
override val membersHidden: Boolean = false,
|
||||
@SerialName(availableReactionsField)
|
||||
override val availableReactions: List<Reaction>? = null,
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
override val statusEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(emojiStatusExpirationDateField)
|
||||
override val statusEmojiExpiration: TelegramDate? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : ExtendedSupergroupChat
|
||||
|
||||
@Serializable
|
||||
@@ -167,7 +219,21 @@ data class ExtendedForumChatImpl(
|
||||
@SerialName(hasAggressiveAntiSpamEnabledField)
|
||||
override val isAggressiveAntiSpamEnabled: Boolean = false,
|
||||
@SerialName(hasHiddenMembersField)
|
||||
override val membersHidden: Boolean = false
|
||||
override val membersHidden: Boolean = false,
|
||||
@SerialName(availableReactionsField)
|
||||
override val availableReactions: List<Reaction>? = null,
|
||||
@SerialName(emojiStatusCustomEmojiIdField)
|
||||
override val statusEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(emojiStatusExpirationDateField)
|
||||
override val statusEmojiExpiration: TelegramDate? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : ExtendedForumChat
|
||||
|
||||
@Serializable
|
||||
@@ -186,7 +252,15 @@ data class ExtendedBot(
|
||||
@SerialName(supportInlineQueriesField)
|
||||
val supportsInlineQueries: Boolean = false,
|
||||
@SerialName(photoField)
|
||||
override val chatPhoto: ChatPhoto? = null
|
||||
override val chatPhoto: ChatPhoto? = null,
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0),
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null,
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,
|
||||
) : Bot(), ExtendedChat {
|
||||
@SerialName(isBotField)
|
||||
private val isBot = true
|
||||
@@ -198,4 +272,12 @@ data class UnknownExtendedChat(
|
||||
val rawJson: JsonObject
|
||||
) : ExtendedChat {
|
||||
override val chatPhoto: ChatPhoto? = null
|
||||
@SerialName(accentColorIdField)
|
||||
override val accentColorId: ColorId = ColorId(0)
|
||||
@SerialName(profileAccentColorIdField)
|
||||
override val profileAccentColorId: ColorId? = null
|
||||
@SerialName(backgroundCustomEmojiIdField)
|
||||
override val backgroundCustomEmojiId: CustomEmojiId? = null
|
||||
@SerialName(profileBackgroundCustomEmojiIdField)
|
||||
override val profileBackgroundCustomEmojiId: CustomEmojiId? = null,\
|
||||
}
|
||||
|
||||
@@ -1,11 +1,28 @@
|
||||
package dev.inmo.tgbotapi.types.chat
|
||||
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.colors.ColorId
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import korlibs.time.DateTime
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedChat : Chat {
|
||||
val chatPhoto: ChatPhoto?
|
||||
val accentColorId: ColorId
|
||||
val profileAccentColorId: ColorId?
|
||||
val backgroundCustomEmojiId: CustomEmojiId?
|
||||
val profileBackgroundCustomEmojiId: CustomEmojiId?
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedNonBotChat : ExtendedChat {
|
||||
val statusEmojiId: CustomEmojiId?
|
||||
val statusEmojiExpiration: TelegramDate?
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedChannelChat : ChannelChat, ExtendedPublicChat, ExtendedChatWithUsername {
|
||||
val linkedGroupChatId: IdChatIdentifier?
|
||||
@@ -17,23 +34,22 @@ sealed interface ExtendedGroupChat : GroupChat, ExtendedPublicChat {
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername {
|
||||
sealed interface ExtendedPrivateChat : PrivateChat, ExtendedChatWithUsername, ExtendedNonBotChat {
|
||||
val bio: String
|
||||
val hasPrivateForwards: Boolean
|
||||
val hasRestrictedVoiceAndVideoMessages: Boolean
|
||||
val statusEmojiId: CustomEmojiId?
|
||||
val statusEmojiExpiration: TelegramDate?
|
||||
|
||||
val allowCreateUserIdLink: Boolean
|
||||
get() = hasPrivateForwards
|
||||
}
|
||||
|
||||
sealed interface ExtendedPublicChat : ExtendedChat, PublicChat {
|
||||
sealed interface ExtendedPublicChat : ExtendedChat, PublicChat, ExtendedNonBotChat {
|
||||
val description: String
|
||||
val inviteLink: String?
|
||||
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
|
||||
val pinnedMessage: Message?
|
||||
val membersHidden: Boolean
|
||||
val availableReactions: List<Reaction>?
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
@@ -63,11 +79,6 @@ sealed interface ExtendedSupergroupChat : SupergroupChat, ExtendedGroupChat, Ext
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedForumChat : ExtendedSupergroupChat, ForumChat
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedChat : Chat {
|
||||
val chatPhoto: ChatPhoto?
|
||||
}
|
||||
|
||||
@Serializable(ExtendedChatSerializer.Companion::class)
|
||||
sealed interface ExtendedChatWithUsername : UsernameChat, ExtendedChat {
|
||||
val activeUsernames: List<Username>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.colors
|
||||
|
||||
import dev.inmo.micro_utils.colors.common.HEXAColor
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable
|
||||
@JvmInline
|
||||
value class ColorId(
|
||||
val int: Int
|
||||
)
|
||||
@@ -0,0 +1,30 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Giveaway(
|
||||
@SerialName(chatsField)
|
||||
val chats: List<PreviewChat>,
|
||||
@SerialName(winnersSelectionDateField)
|
||||
override val selectionDate: TelegramDate,
|
||||
@SerialName(winnersCountField)
|
||||
val count: Int,
|
||||
@SerialName(onlyNewMembersField)
|
||||
override val onlyNewMembers: Boolean = false,
|
||||
@SerialName(hasPublicWinnersField)
|
||||
val publicWinners: Boolean = false,
|
||||
@SerialName(prizeDescriptionField)
|
||||
override val additionalPrizeDescription: String? = null,
|
||||
@SerialName(countryCodesField)
|
||||
val countries: List<IetfLang>? = null,
|
||||
@SerialName(premiumSubscriptionMonthCountField)
|
||||
override val premiumMonths: Int? = null
|
||||
) : GiveawayInfo, ChatEvent, PublicChatEvent
|
||||
@@ -0,0 +1,8 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
object GiveawayCreated : ChatEvent, PublicChatEvent
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.micro_utils.language_codes.IetfLang
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface GiveawayInfo {
|
||||
val selectionDate: TelegramDate
|
||||
val onlyNewMembers: Boolean
|
||||
val premiumMonths: Int?
|
||||
val additionalPrizeDescription: String?
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.Transient
|
||||
|
||||
@Serializable
|
||||
data class GiveawayPrivateResults(
|
||||
override val chat: PreviewChat,
|
||||
override val unclaimedCount: Int,
|
||||
@Transient // TODO::Add message serializer
|
||||
val message: Message? = null
|
||||
) : GiveawayResults
|
||||
@@ -0,0 +1,161 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewChat
|
||||
import dev.inmo.tgbotapi.types.chat.PreviewUser
|
||||
import kotlinx.serialization.KSerializer
|
||||
import kotlinx.serialization.Required
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@Serializable(GiveawayPublicResults.Companion::class)
|
||||
sealed interface GiveawayPublicResults: GiveawayInfo, GiveawayResults, WithPreviewChatAndMessageId {
|
||||
val count: Int
|
||||
val winners: List<PreviewUser>
|
||||
val additionalChats: Int
|
||||
val publicWinners: Boolean
|
||||
val refunded: Boolean
|
||||
|
||||
@Serializable
|
||||
data class Refunded(
|
||||
@SerialName(chatsField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(giveawayMessageIdField)
|
||||
override val messageId: MessageId,
|
||||
@SerialName(winnersSelectionDateField)
|
||||
override val selectionDate: TelegramDate,
|
||||
) : GiveawayPublicResults {
|
||||
@SerialName(wasRefundedField)
|
||||
@Required
|
||||
override val refunded: Boolean = true
|
||||
@SerialName(winnersCountField)
|
||||
override val count: Int = 0
|
||||
@SerialName(winnersField)
|
||||
override val winners: List<PreviewUser> = emptyList()
|
||||
@SerialName(additionalChatCountField)
|
||||
override val additionalChats: Int = 0
|
||||
@SerialName(unclaimedPrizeCountField)
|
||||
override val unclaimedCount: Int = 0
|
||||
@SerialName(onlyNewMembersField)
|
||||
override val onlyNewMembers: Boolean = false
|
||||
@SerialName(hasPublicWinnersField)
|
||||
override val publicWinners: Boolean = false
|
||||
@SerialName(prizeDescriptionField)
|
||||
override val additionalPrizeDescription: String? = null
|
||||
@SerialName(premiumSubscriptionMonthCountField)
|
||||
override val premiumMonths: Int? = null
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class Winners (
|
||||
@SerialName(chatsField)
|
||||
override val chat: PreviewChat,
|
||||
@SerialName(giveawayMessageIdField)
|
||||
override val messageId: MessageId,
|
||||
@SerialName(winnersSelectionDateField)
|
||||
override val selectionDate: TelegramDate,
|
||||
@SerialName(winnersCountField)
|
||||
override val count: Int,
|
||||
@SerialName(winnersField)
|
||||
override val winners: List<PreviewUser>,
|
||||
@SerialName(additionalChatCountField)
|
||||
override val additionalChats: Int = 0,
|
||||
@SerialName(unclaimedPrizeCountField)
|
||||
override val unclaimedCount: Int = 0,
|
||||
@SerialName(onlyNewMembersField)
|
||||
override val onlyNewMembers: Boolean = false,
|
||||
@SerialName(hasPublicWinnersField)
|
||||
override val publicWinners: Boolean = false,
|
||||
@SerialName(prizeDescriptionField)
|
||||
override val additionalPrizeDescription: String? = null,
|
||||
@SerialName(premiumSubscriptionMonthCountField)
|
||||
override val premiumMonths: Int? = null
|
||||
) : GiveawayPublicResults {
|
||||
@SerialName(wasRefundedField)
|
||||
@Required
|
||||
override val refunded: Boolean = false
|
||||
}
|
||||
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
@SerialName(chatsField)
|
||||
val chat: PreviewChat,
|
||||
@SerialName(giveawayMessageIdField)
|
||||
val messageId: MessageId,
|
||||
@SerialName(winnersSelectionDateField)
|
||||
val selectionDate: TelegramDate,
|
||||
@SerialName(winnersCountField)
|
||||
val count: Int,
|
||||
@SerialName(winnersField)
|
||||
val winners: List<PreviewUser>,
|
||||
@SerialName(additionalChatCountField)
|
||||
val additionalChats: Int = 0,
|
||||
@SerialName(unclaimedPrizeCountField)
|
||||
val unclaimedCount: Int = 0,
|
||||
@SerialName(onlyNewMembersField)
|
||||
val onlyNewMembers: Boolean = false,
|
||||
@SerialName(hasPublicWinnersField)
|
||||
val publicWinners: Boolean = false,
|
||||
@SerialName(wasRefundedField)
|
||||
val refunded: Boolean = false,
|
||||
@SerialName(prizeDescriptionField)
|
||||
val additionalPrizeDescription: String? = null,
|
||||
@SerialName(premiumSubscriptionMonthCountField)
|
||||
val premiumMonths: Int? = null
|
||||
)
|
||||
|
||||
companion object : KSerializer<GiveawayPublicResults> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): GiveawayPublicResults {
|
||||
val surrogate = Surrogate.serializer().deserialize(decoder)
|
||||
|
||||
return when (surrogate.refunded) {
|
||||
true -> Refunded(
|
||||
chat = surrogate.chat,
|
||||
messageId = surrogate.messageId,
|
||||
selectionDate = surrogate.selectionDate
|
||||
)
|
||||
false -> {
|
||||
Winners(
|
||||
chat = surrogate.chat,
|
||||
messageId = surrogate.messageId,
|
||||
selectionDate = surrogate.selectionDate,
|
||||
count = surrogate.count,
|
||||
winners = surrogate.winners,
|
||||
additionalChats = surrogate.additionalChats,
|
||||
unclaimedCount = surrogate.unclaimedCount,
|
||||
onlyNewMembers = surrogate.onlyNewMembers,
|
||||
publicWinners = surrogate.publicWinners,
|
||||
additionalPrizeDescription = surrogate.additionalPrizeDescription,
|
||||
premiumMonths = surrogate.premiumMonths,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: GiveawayPublicResults) {
|
||||
val surrogate = Surrogate(
|
||||
chat = value.chat,
|
||||
messageId = value.messageId,
|
||||
selectionDate = value.selectionDate,
|
||||
count = value.count,
|
||||
winners = value.winners,
|
||||
additionalChats = value.additionalChats,
|
||||
unclaimedCount = value.unclaimedCount,
|
||||
onlyNewMembers = value.onlyNewMembers,
|
||||
publicWinners = value.publicWinners,
|
||||
additionalPrizeDescription = value.additionalPrizeDescription,
|
||||
premiumMonths = value.premiumMonths,
|
||||
refunded = value.refunded
|
||||
)
|
||||
|
||||
Surrogate.serializer().serialize(encoder, surrogate)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package dev.inmo.tgbotapi.types.giveaway
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed interface GiveawayResults : WithPreviewChat, ChatEvent, PublicChatEvent {
|
||||
val unclaimedCount: Int
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import korlibs.time.seconds
|
||||
import dev.inmo.tgbotapi.types.Seconds
|
||||
import dev.inmo.tgbotapi.types.durationField
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.VideoChatEvent
|
||||
import korlibs.time.milliseconds
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ 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.giveaway.Giveaway
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
|
||||
import dev.inmo.tgbotapi.types.giveaway.GiveawayResults
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||
@@ -30,7 +34,7 @@ import dev.inmo.tgbotapi.types.payments.Invoice
|
||||
import dev.inmo.tgbotapi.types.payments.SuccessfulPayment
|
||||
import dev.inmo.tgbotapi.types.polls.Poll
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||
import dev.inmo.tgbotapi.types.stories.Story
|
||||
import dev.inmo.tgbotapi.types.venue.Venue
|
||||
import kotlinx.serialization.SerialName
|
||||
@@ -97,7 +101,7 @@ internal data class RawMessage(
|
||||
private val dice: Dice? = null,
|
||||
private val successful_payment: SuccessfulPayment? = null,
|
||||
|
||||
private val user_shared: UserShared? = null,
|
||||
private val users_shared: UsersShared? = null,
|
||||
private val chat_shared: ChatShared? = null,
|
||||
|
||||
// Voice Chat Service Messages
|
||||
@@ -128,7 +132,15 @@ internal data class RawMessage(
|
||||
private val passport_data: PassportData? = null,
|
||||
private val proximity_alert_triggered: ProximityAlertTriggered? = null,
|
||||
|
||||
private val reply_markup: InlineKeyboardMarkup? = null
|
||||
private val link_preview_options: LinkPreviewOptions? = null,
|
||||
|
||||
private val reply_markup: InlineKeyboardMarkup? = null,
|
||||
|
||||
// Giveaways
|
||||
private val giveaway_created: GiveawayCreated? = null,
|
||||
private val giveaway: Giveaway? = null,
|
||||
private val giveaway_winners: GiveawayResults? = null,
|
||||
private val giveaway_completed: GiveawayPrivateResults? = null,
|
||||
) {
|
||||
private val content: MessageContent? by lazy {
|
||||
val adaptedCaptionEntities = caption ?.let {
|
||||
@@ -141,7 +153,7 @@ internal data class RawMessage(
|
||||
messageId,
|
||||
story
|
||||
)
|
||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text))
|
||||
text != null -> TextContent(text, (entities ?: emptyList()).asTextSources(text), link_preview_options)
|
||||
audio != null -> AudioContent(
|
||||
audio,
|
||||
caption,
|
||||
@@ -264,8 +276,12 @@ internal data class RawMessage(
|
||||
successful_payment != null -> SuccessfulPaymentEvent(successful_payment)
|
||||
connected_website != null -> UserLoggedIn(connected_website)
|
||||
web_app_data != null -> web_app_data
|
||||
user_shared != null -> user_shared
|
||||
users_shared != null -> users_shared
|
||||
chat_shared != null -> chat_shared
|
||||
giveaway_created != null -> giveaway_created
|
||||
giveaway != null -> giveaway
|
||||
giveaway_winners != null -> giveaway_winners
|
||||
giveaway_completed != null -> giveaway_completed
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,24 +22,25 @@ internal data class RawMessageEntity(
|
||||
val priority by lazy {
|
||||
when (type) {
|
||||
// Types with potential subsources should have priority
|
||||
"mention" -> 0
|
||||
"hashtag" -> 0
|
||||
"cashtag" -> 0
|
||||
"email" -> 0
|
||||
"phone_number" -> 0
|
||||
"bold" -> 0
|
||||
"italic" -> 0
|
||||
"text_mention" -> 0
|
||||
"strikethrough" -> 0
|
||||
"underline" -> 0
|
||||
"spoiler" -> 0
|
||||
"custom_emoji" -> 0
|
||||
"bot_command" -> 1
|
||||
"url" -> 1
|
||||
"code" -> 1
|
||||
"pre" -> 1
|
||||
"text_link" -> 1
|
||||
else -> 1
|
||||
"mention" -> 1
|
||||
"hashtag" -> 1
|
||||
"cashtag" -> 1
|
||||
"email" -> 1
|
||||
"phone_number" -> 1
|
||||
"bold" -> 1
|
||||
"blockquote" -> 0
|
||||
"italic" -> 1
|
||||
"text_mention" -> 1
|
||||
"strikethrough" -> 1
|
||||
"underline" -> 1
|
||||
"spoiler" -> 1
|
||||
"custom_emoji" -> 1
|
||||
"bot_command" -> 2
|
||||
"url" -> 2
|
||||
"code" -> 2
|
||||
"pre" -> 2
|
||||
"text_link" -> 2
|
||||
else -> 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +62,7 @@ internal fun RawMessageEntity.asTextSource(
|
||||
"email" -> EMailTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"phone_number" -> PhoneNumberTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"bold" -> BoldTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"blockquote" -> BlockquoteTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"italic" -> ItalicTextSource(sourceSubstring, subPartsWithRegulars)
|
||||
"code" -> CodeTextSource(sourceSubstring)
|
||||
"pre" -> PreTextSource(sourceSubstring, language)
|
||||
@@ -180,6 +182,7 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEn
|
||||
is EMailTextSource -> RawMessageEntity("email", offset, length)
|
||||
is PhoneNumberTextSource -> RawMessageEntity("phone_number", offset, length)
|
||||
is BoldTextSource -> RawMessageEntity("bold", offset, length)
|
||||
is BlockquoteTextSource -> RawMessageEntity("blockquote", offset, length)
|
||||
is ItalicTextSource -> RawMessageEntity("italic", offset, length)
|
||||
is CodeTextSource -> RawMessageEntity("code", offset, length)
|
||||
is PreTextSource -> RawMessageEntity("pre", offset, length, language = language)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.inmo.tgbotapi.types.message.abstracts
|
||||
|
||||
import dev.inmo.tgbotapi.abstracts.WithMessageId
|
||||
import korlibs.time.DateTime
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
|
||||
import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId
|
||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
@@ -13,8 +15,7 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
@ClassCastsIncluded(excludeRegex = ".*Impl")
|
||||
interface Message : WithPreviewChat {
|
||||
val messageId: MessageId
|
||||
interface Message : WithPreviewChatAndMessageId {
|
||||
val date: DateTime
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedInput
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.LinkPreviewOptions
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.MessageId
|
||||
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||
@@ -15,6 +16,7 @@ import kotlinx.serialization.Serializable
|
||||
data class TextContent(
|
||||
override val text: String,
|
||||
override val textSources: TextSourcesList = emptyList(),
|
||||
val linkPreviewOptions: LinkPreviewOptions? = null
|
||||
) : TextedContent {
|
||||
override fun createResend(
|
||||
chatId: ChatIdentifier,
|
||||
@@ -27,7 +29,7 @@ data class TextContent(
|
||||
): Request<ContentMessage<TextContent>> = SendTextMessage(
|
||||
chatId,
|
||||
textSources,
|
||||
false,
|
||||
linkPreviewOptions,
|
||||
messageThreadId,
|
||||
disableNotification,
|
||||
protectContent,
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package dev.inmo.tgbotapi.types.message.textsources
|
||||
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
/**
|
||||
* @see blockquote
|
||||
*/
|
||||
@Serializable
|
||||
data class BlockquoteTextSource @RiskFeature(DirectInvocationOfTextSourceConstructor) constructor (
|
||||
override val source: String,
|
||||
override val subsources: TextSourcesList
|
||||
) : MultilevelTextSource {
|
||||
override val markdown: String by lazy { source.blockquoteMarkdown() }
|
||||
override val markdownV2: String by lazy { blockquoteMarkdownV2() }
|
||||
override val html: String by lazy { blockquoteHTML() }
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun blockquote(parts: TextSourcesList) = BlockquoteTextSource(parts.makeString(), parts)
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun blockquote(vararg parts: TextSource) = blockquote(parts.toList())
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
inline fun blockquote(text: String) = blockquote(regular(text))
|
||||
@@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||
import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import korlibs.time.seconds
|
||||
import kotlinx.serialization.*
|
||||
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package dev.inmo.tgbotapi.types.reactions
|
||||
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.customEmojiField
|
||||
import dev.inmo.tgbotapi.types.emojiField
|
||||
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 kotlinx.serialization.json.JsonDecoder
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
|
||||
@Serializable(Reaction.Companion::class)
|
||||
@ClassCastsIncluded
|
||||
sealed interface Reaction {
|
||||
val type: String
|
||||
|
||||
@Serializable(Reaction.Companion::class)
|
||||
data class Emoji(
|
||||
val emoji: String
|
||||
) : Reaction {
|
||||
override val type: String
|
||||
get() = Companion.type
|
||||
companion object {
|
||||
const val type: String = "emoji"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(Reaction.Companion::class)
|
||||
data class CustomEmoji(
|
||||
val customEmoji: CustomEmojiId
|
||||
) : Reaction {
|
||||
override val type: String
|
||||
get() = Companion.type
|
||||
companion object {
|
||||
const val type: String = "custom_emoji"
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable(Reaction.Companion::class)
|
||||
data class Unknown(
|
||||
override val type: String,
|
||||
val sourceJson: JsonElement?
|
||||
) : Reaction
|
||||
|
||||
@Serializable
|
||||
private data class Surrogate(
|
||||
val type: String,
|
||||
@SerialName(emojiField)
|
||||
val emoji: String? = null,
|
||||
@SerialName(customEmojiField)
|
||||
val customEmoji: CustomEmojiId? = null
|
||||
)
|
||||
|
||||
companion object : KSerializer<Reaction> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = Surrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): Reaction {
|
||||
val (surrogate, json) = if (decoder is JsonDecoder) {
|
||||
val json = decoder.decodeJsonElement()
|
||||
decoder.json.decodeFromJsonElement(Surrogate.serializer(), json) to json
|
||||
} else {
|
||||
Surrogate.serializer().deserialize(decoder) to null
|
||||
}
|
||||
|
||||
return when {
|
||||
surrogate.emoji != null -> Emoji(surrogate.emoji)
|
||||
surrogate.customEmoji != null -> CustomEmoji(surrogate.customEmoji)
|
||||
else -> Unknown(surrogate.type, json)
|
||||
}
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: Reaction) {
|
||||
if (value is Unknown && value.sourceJson != null) {
|
||||
JsonElement.serializer().serialize(encoder, value.sourceJson)
|
||||
} else {
|
||||
Surrogate.serializer().serialize(
|
||||
encoder,
|
||||
Surrogate(
|
||||
type = value.type,
|
||||
emoji = (value as? Emoji) ?.emoji,
|
||||
customEmoji = (value as? CustomEmoji) ?.customEmoji,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.types.reactions
|
||||
|
||||
import dev.inmo.tgbotapi.types.totalCountField
|
||||
import dev.inmo.tgbotapi.types.typeField
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ReactionsCount(
|
||||
@SerialName(typeField)
|
||||
val reaction: Reaction,
|
||||
@SerialName(totalCountField)
|
||||
val count: Int
|
||||
)
|
||||
@@ -1,19 +1,22 @@
|
||||
package dev.inmo.tgbotapi.types.request
|
||||
|
||||
import dev.inmo.tgbotapi.types.ChatId
|
||||
import dev.inmo.tgbotapi.types.UserId
|
||||
import dev.inmo.tgbotapi.types.requestIdField
|
||||
import dev.inmo.tgbotapi.types.userIdField
|
||||
import dev.inmo.tgbotapi.types.*
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class UserShared(
|
||||
data class UsersShared(
|
||||
@SerialName(requestIdField)
|
||||
override val requestId: RequestId,
|
||||
@SerialName(userIdField)
|
||||
val userId: UserId
|
||||
@SerialName(userIdsField)
|
||||
val userIds: List<UserId>
|
||||
) : ChatSharedRequest {
|
||||
val userId: UserId
|
||||
get() = userIds.first()
|
||||
constructor(
|
||||
requestId: RequestId,
|
||||
userId: UserId
|
||||
) : this(requestId, listOf(userId))
|
||||
override val chatId: ChatId
|
||||
get() = userId
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package dev.inmo.tgbotapi.types.update
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostRemovedUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: ChatBoostRemoved
|
||||
) : Update
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.update
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatBoostUpdatedUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: ChatBoostUpdated
|
||||
) : Update
|
||||
@@ -0,0 +1,12 @@
|
||||
package dev.inmo.tgbotapi.types.update
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatMessageReactionUpdatedUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: ChatMessageReactionUpdated
|
||||
) : Update
|
||||
@@ -0,0 +1,13 @@
|
||||
package dev.inmo.tgbotapi.types.update
|
||||
|
||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ChatMessageReactionsCountUpdatedUpdate(
|
||||
override val updateId: UpdateIdentifier,
|
||||
override val data: ChatMessageReactionsCountUpdated
|
||||
) : Update
|
||||
@@ -4,7 +4,11 @@ import dev.inmo.tgbotapi.types.*
|
||||
import dev.inmo.tgbotapi.types.queries.callback.RawCallbackQuery
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.RawChosenInlineResult
|
||||
import dev.inmo.tgbotapi.types.InlineQueries.query.RawInlineQuery
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostRemoved
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionsCountUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||
@@ -38,8 +42,13 @@ internal data class RawUpdate constructor(
|
||||
private val poll_answer: PollAnswer? = null,
|
||||
private val my_chat_member: ChatMemberUpdated? = null,
|
||||
private val chat_member: ChatMemberUpdated? = null,
|
||||
private val chat_join_request: ChatJoinRequest? = null
|
||||
private val chat_join_request: ChatJoinRequest? = null,
|
||||
private val message_reaction: ChatMessageReactionUpdated? = null,
|
||||
private val message_reaction_count: ChatMessageReactionsCountUpdated? = null,
|
||||
private val chat_boost: ChatBoostUpdated? = null,
|
||||
private val removed_chat_boost: ChatBoostRemoved? = null
|
||||
) {
|
||||
@Transient
|
||||
private var initedUpdate: Update? = null
|
||||
/**
|
||||
* @return One of children of [Update] interface or null in case of unknown type of update
|
||||
@@ -65,6 +74,10 @@ internal data class RawUpdate constructor(
|
||||
my_chat_member != null -> MyChatMemberUpdatedUpdate(updateId, my_chat_member)
|
||||
chat_member != null -> CommonChatMemberUpdatedUpdate(updateId, chat_member)
|
||||
chat_join_request != null -> ChatJoinRequestUpdate(updateId, chat_join_request)
|
||||
message_reaction != null -> ChatMessageReactionUpdatedUpdate(updateId, message_reaction)
|
||||
message_reaction_count != null -> ChatMessageReactionsCountUpdatedUpdate(updateId, message_reaction_count)
|
||||
chat_boost != null -> ChatBoostUpdatedUpdate(updateId, chat_boost)
|
||||
removed_chat_boost != null -> ChatBoostRemovedUpdate(updateId, removed_chat_boost)
|
||||
else -> UnknownUpdate(
|
||||
updateId,
|
||||
raw
|
||||
|
||||
@@ -37,6 +37,10 @@ interface FlowsUpdatesFilter : UpdatesFilter {
|
||||
val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate>
|
||||
val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate>
|
||||
val chatJoinRequestUpdateFlow: Flow<ChatJoinRequestUpdate>
|
||||
val chatMessageReactionUpdatedUpdateFlow: Flow<ChatMessageReactionUpdatedUpdate>
|
||||
val chatMessageReactionsCountUpdatedUpdateFlow: Flow<ChatMessageReactionsCountUpdatedUpdate>
|
||||
val chatBoostUpdatedUpdateFlow: Flow<ChatBoostUpdatedUpdate>
|
||||
val chatBoostRemovedUpdateFlow: Flow<ChatBoostRemovedUpdate>
|
||||
val unknownUpdatesFlow: Flow<UnknownUpdate>
|
||||
}
|
||||
|
||||
@@ -55,7 +59,11 @@ abstract class AbstractFlowsUpdatesFilter : FlowsUpdatesFilter {
|
||||
override val chatMemberUpdatesFlow: Flow<CommonChatMemberUpdatedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val myChatMemberUpdatesFlow: Flow<MyChatMemberUpdatedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val chatJoinRequestUpdateFlow: Flow<ChatJoinRequestUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val chatMessageReactionUpdatedUpdateFlow: Flow<ChatMessageReactionUpdatedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val chatMessageReactionsCountUpdatedUpdateFlow: Flow<ChatMessageReactionsCountUpdatedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val unknownUpdatesFlow: Flow<UnknownUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val chatBoostUpdatedUpdateFlow: Flow<ChatBoostUpdatedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
override val chatBoostRemovedUpdateFlow: Flow<ChatBoostRemovedUpdate> by lazy { allUpdatesFlow.filterIsInstance() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -103,6 +103,43 @@ inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.mess
|
||||
*/
|
||||
inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine
|
||||
|
||||
/**
|
||||
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote]
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquote(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.blockquote] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquoteln(parts: TextSourcesList) = blockquote(parts) + newLine
|
||||
/**
|
||||
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote].
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquote(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(
|
||||
buildEntities(separator, init)
|
||||
))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.blockquote] with new line at the end.
|
||||
* Will reuse separator config from [buildEntities]
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquoteln(noinline init: EntitiesBuilderBody) = blockquote(init) + newLine
|
||||
/**
|
||||
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote]
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquote(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(*parts))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.blockquote] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquoteln(vararg parts: TextSource) = blockquote(*parts) + newLine
|
||||
/**
|
||||
* Add blockquote using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.blockquote]
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquote(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.blockquote(text))
|
||||
/**
|
||||
* Version of [EntitiesBuilder.blockquote] with new line at the end
|
||||
*/
|
||||
inline fun EntitiesBuilder.blockquoteln(text: String) = blockquote(text) + newLine
|
||||
|
||||
/**
|
||||
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package dev.inmo.tgbotapi.utils.extensions
|
||||
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||
import dev.inmo.tgbotapi.types.message.*
|
||||
|
||||
val eachLineRegex = Regex("^[^\n]")
|
||||
|
||||
inline fun TextSourcesList.makeString(
|
||||
parseMode: ParseMode? = null
|
||||
) = when (parseMode) {
|
||||
@@ -21,8 +23,23 @@ inline fun TextSourcesList.makeHtmlString() = joinToString("") {
|
||||
it.html
|
||||
}
|
||||
|
||||
inline fun TextSourcesList.makeMarkdownV2String() = joinToString("") {
|
||||
inline fun TextSourcesList.makeMarkdownV2String(eachLineSeparator: String? = null) = joinToString("") {
|
||||
it.markdownV2
|
||||
}.let {
|
||||
if (eachLineSeparator == null) {
|
||||
it
|
||||
} else {
|
||||
it.let {
|
||||
if (it.startsWith("\n")) {
|
||||
it
|
||||
} else {
|
||||
"$eachLineSeparator$it"
|
||||
}
|
||||
}.replace(
|
||||
"\n",
|
||||
"\n$eachLineSeparator"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
inline fun TextSourcesList.makeMarkdownString() = joinToString("") {
|
||||
|
||||
@@ -6,8 +6,9 @@ import dev.inmo.tgbotapi.utils.extensions.*
|
||||
|
||||
internal fun MultilevelTextSource.markdownV2Default(
|
||||
openControlSymbol: String,
|
||||
closeControlSymbol: String = openControlSymbol
|
||||
) = "$openControlSymbol${subsources.makeMarkdownV2String()}$closeControlSymbol"
|
||||
closeControlSymbol: String = openControlSymbol,
|
||||
eachLineSeparator: String? = null
|
||||
) = "$openControlSymbol${subsources.makeMarkdownV2String(eachLineSeparator)}$closeControlSymbol"
|
||||
internal fun MultilevelTextSource.htmlDefault(
|
||||
openControlSymbol: String,
|
||||
closeControlSymbol: String = openControlSymbol
|
||||
@@ -40,6 +41,10 @@ internal fun MultilevelTextSource.boldMarkdownV2(): String = markdownV2Default(m
|
||||
internal fun MultilevelTextSource.boldHTML(): String = htmlDefault(htmlBoldControl)
|
||||
|
||||
|
||||
internal fun MultilevelTextSource.blockquoteMarkdownV2(): String = markdownV2Default("", eachLineSeparator = markdownBlockquoteControl)
|
||||
internal fun MultilevelTextSource.blockquoteHTML(): String = htmlDefault(htmlBlockquoteControl)
|
||||
|
||||
|
||||
internal fun MultilevelTextSource.cashTagMarkdownV2(): String = subsources.makeMarkdownV2String()
|
||||
internal fun MultilevelTextSource.cashTagHTML(): String = subsources.makeHtmlString()
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.types.message.*
|
||||
import dev.inmo.tgbotapi.utils.extensions.*
|
||||
|
||||
const val markdownBoldControl = "*"
|
||||
const val markdownBlockquoteControl = ">"
|
||||
const val markdownItalicControl = "_"
|
||||
const val markdownSpoilerControl = "||"
|
||||
const val markdownCodeControl = "`"
|
||||
@@ -17,6 +18,7 @@ const val markdownV2UnderlineEndControl = "$markdownV2UnderlineControl$markdownV
|
||||
const val markdownV2ItalicEndControl = "$markdownItalicControl$markdownV2ItalicUnderlineDelimiter"
|
||||
|
||||
const val htmlBoldControl = "b"
|
||||
const val htmlBlockquoteControl = "blockquote"
|
||||
const val htmlItalicControl = "i"
|
||||
const val htmlSpoilerControl = "span class=\"tg-spoiler\""
|
||||
const val htmlSpoilerClosingControl = "span"
|
||||
@@ -47,6 +49,8 @@ internal fun String.linkHTML(link: String): String = "<a href=\"$link\">${toHtml
|
||||
|
||||
internal fun String.boldMarkdown(): String = markdownDefault(markdownBoldControl)
|
||||
|
||||
internal fun String.blockquoteMarkdown(): String = regularMarkdown()
|
||||
|
||||
internal fun String.italicMarkdown(): String = markdownDefault(markdownItalicControl)
|
||||
|
||||
internal fun String.spoilerMarkdown(): String = regularMarkdown()
|
||||
|
||||
@@ -4,9 +4,11 @@ import dev.inmo.tgbotapi.types.message.RawMessageEntity
|
||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
const val testText = "It (is?) is simple hello world with #tag and @mention"
|
||||
const val formattedV2Text = "It \\(is?\\) *_is_ ~__simple__~* ||hello world|| with \\#tag and @mention"
|
||||
const val formattedHtmlText = "It (is?) <b><i>is</i> <s><u>simple</u></s></b> <span class=\"tg-spoiler\">hello world</span> with #tag and @mention"
|
||||
const val testText = "It (is?) is simple hello world with #tag and @mention. Start of blockquote: Block quotation started\n" +
|
||||
"Block quotation continued\n" +
|
||||
"The last line of the block quotation"
|
||||
const val formattedV2Text = "It \\(is?\\) *_is_ ~__simple__~* ||hello world|| with \\#tag and @mention\\. Start of blockquote: >Block quotation started\n>Block quotation continued\n>The last line of the block quotation"
|
||||
const val formattedHtmlText = "It (is?) <b><i>is</i> <s><u>simple</u></s></b> <span class=\"tg-spoiler\">hello world</span> with #tag and @mention. Start of blockquote: <blockquote>Block quotation started\nBlock quotation continued\nThe last line of the block quotation</blockquote>"
|
||||
internal val testTextEntities = listOf(
|
||||
RawMessageEntity(
|
||||
"bold",
|
||||
@@ -42,6 +44,11 @@ internal val testTextEntities = listOf(
|
||||
"mention",
|
||||
45,
|
||||
8
|
||||
),
|
||||
RawMessageEntity(
|
||||
"blockquote",
|
||||
76,
|
||||
86
|
||||
)
|
||||
)
|
||||
|
||||
@@ -54,10 +61,15 @@ fun TextSourcesList.testTextSources() {
|
||||
assertTrue (get(5) is HashTagTextSource)
|
||||
assertTrue (get(6) is RegularTextSource)
|
||||
assertTrue (get(7) is MentionTextSource)
|
||||
assertTrue (get(8) is RegularTextSource)
|
||||
assertTrue (get(9) is BlockquoteTextSource)
|
||||
|
||||
val boldSource = get(1) as BoldTextSource
|
||||
assertTrue (boldSource.subsources.first() is ItalicTextSource)
|
||||
assertTrue (boldSource.subsources[1] is RegularTextSource)
|
||||
assertTrue (boldSource.subsources[2] is StrikethroughTextSource)
|
||||
assertTrue ((boldSource.subsources[2] as StrikethroughTextSource).subsources.first() is UnderlineTextSource)
|
||||
|
||||
val blockquoteSource = get(9) as BlockquoteTextSource
|
||||
assertTrue (blockquoteSource.subsources.first() is RegularTextSource)
|
||||
}
|
||||
|
||||
@@ -48,7 +48,13 @@ class StringFormattingTests {
|
||||
" with " +
|
||||
hashtag("tag") +
|
||||
" and " +
|
||||
mention("mention")
|
||||
mention("mention") +
|
||||
". Start of blockquote: " +
|
||||
blockquote(
|
||||
"Block quotation started\n" +
|
||||
"Block quotation continued\n" +
|
||||
"The last line of the block quotation"
|
||||
)
|
||||
sources.testTextSources()
|
||||
|
||||
assertEquals(formattedV2Text, sources.toMarkdownV2Texts().first())
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package dev.inmo.tgbotapi.types.message.ChatEvents
|
||||
|
||||
import dev.inmo.tgbotapi.TestsJsonFormat
|
||||
import dev.inmo.tgbotapi.extensions.utils.asMessageUpdate
|
||||
import dev.inmo.tgbotapi.extensions.utils.asMigratedToSupergroup
|
||||
import dev.inmo.tgbotapi.extensions.utils.asSupergroupEventMessage
|
||||
import dev.inmo.tgbotapi.extensions.utils.*
|
||||
import dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy
|
||||
import kotlin.test.Test
|
||||
@@ -41,9 +39,9 @@ class MigratedToSupergroupTest {
|
||||
}
|
||||
""".trimIndent()
|
||||
val update = TestsJsonFormat.decodeFromString(UpdateDeserializationStrategy, payload)
|
||||
val message = update.asMessageUpdate() ?: fail("update should be of MessageUpdate subtype")
|
||||
val data = message.data.asSupergroupEventMessage() ?: fail("message should be of SupergroupEventMessage subtype")
|
||||
val event = data.chatEvent.asMigratedToSupergroup() ?: fail("event should be of SupergroupChatCreated subtype")
|
||||
val message = update.messageUpdateOrThrow()
|
||||
val data = message.data.supergroupEventMessageOrThrow()
|
||||
val event = data.chatEvent.migratedToSupergroupOrThrow()
|
||||
|
||||
assertEquals(IdChatIdentifier(57005), event.migratedFrom)
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ import dev.inmo.tgbotapi.types.actions.UploadPhotoAction
|
||||
import dev.inmo.tgbotapi.types.actions.UploadVideoAction
|
||||
import dev.inmo.tgbotapi.types.actions.UploadVideoNoteAction
|
||||
import dev.inmo.tgbotapi.types.actions.UploadVoiceAction
|
||||
import dev.inmo.tgbotapi.types.boosts.ChatBoostSource
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackDataInlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.CallbackGameInlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton
|
||||
@@ -102,7 +103,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.URLInlineKeyboardBu
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.WebAppInlineKeyboardButton
|
||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers
|
||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||
import dev.inmo.tgbotapi.types.buttons.ReplyForce
|
||||
import dev.inmo.tgbotapi.types.buttons.ReplyKeyboardMarkup
|
||||
@@ -112,6 +113,7 @@ import dev.inmo.tgbotapi.types.chat.Bot
|
||||
import dev.inmo.tgbotapi.types.chat.ChannelChat
|
||||
import dev.inmo.tgbotapi.types.chat.Chat
|
||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||
import dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated
|
||||
import dev.inmo.tgbotapi.types.chat.CommonBot
|
||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedBot
|
||||
@@ -120,6 +122,7 @@ import dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedForumChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
|
||||
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
|
||||
@@ -194,6 +197,11 @@ 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.giveaway.Giveaway
|
||||
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.giveaway.GiveawayResults
|
||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||
import dev.inmo.tgbotapi.types.location.Location
|
||||
import dev.inmo.tgbotapi.types.location.StaticLocation
|
||||
@@ -313,6 +321,7 @@ import dev.inmo.tgbotapi.types.message.content.VideoNoteContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent
|
||||
import dev.inmo.tgbotapi.types.message.content.VoiceContent
|
||||
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BoldTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||
import dev.inmo.tgbotapi.types.message.textsources.CashTagTextSource
|
||||
@@ -415,13 +424,18 @@ import dev.inmo.tgbotapi.types.queries.callback.MessageCallbackQuery
|
||||
import dev.inmo.tgbotapi.types.queries.callback.MessageDataCallbackQuery
|
||||
import dev.inmo.tgbotapi.types.queries.callback.MessageGameShortNameCallbackQuery
|
||||
import dev.inmo.tgbotapi.types.queries.callback.UnknownCallbackQueryType
|
||||
import dev.inmo.tgbotapi.types.reactions.Reaction
|
||||
import dev.inmo.tgbotapi.types.request.ChatShared
|
||||
import dev.inmo.tgbotapi.types.request.ChatSharedRequest
|
||||
import dev.inmo.tgbotapi.types.request.RequestResponse
|
||||
import dev.inmo.tgbotapi.types.request.UserShared
|
||||
import dev.inmo.tgbotapi.types.request.UsersShared
|
||||
import dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChannelPostUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate
|
||||
import dev.inmo.tgbotapi.types.update.CommonChatMemberUpdatedUpdate
|
||||
import dev.inmo.tgbotapi.types.update.EditChannelPostUpdate
|
||||
@@ -1615,6 +1629,69 @@ public inline fun BotAction.customBotActionOrThrow(): CustomBotAction = this as
|
||||
public inline fun <T> BotAction.ifCustomBotAction(block: (CustomBotAction) -> T): T? =
|
||||
customBotActionOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatBoostSource.byUserOrNull(): ChatBoostSource.ByUser? = this as?
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.ByUser
|
||||
|
||||
public inline fun ChatBoostSource.byUserOrThrow(): ChatBoostSource.ByUser = this as
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.ByUser
|
||||
|
||||
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
|
||||
|
||||
public inline fun ChatBoostSource.premiumOrThrow(): ChatBoostSource.Premium = this as
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Premium
|
||||
|
||||
public inline fun <T> ChatBoostSource.ifPremium(block: (ChatBoostSource.Premium) -> T): T? =
|
||||
premiumOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatBoostSource.giveawayOrNull(): ChatBoostSource.Giveaway? = this as?
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway
|
||||
|
||||
public inline fun ChatBoostSource.giveawayOrThrow(): ChatBoostSource.Giveaway = this as
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Giveaway
|
||||
|
||||
public inline fun <T> ChatBoostSource.ifGiveaway(block: (ChatBoostSource.Giveaway) -> T): T? =
|
||||
giveawayOrNull() ?.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
|
||||
|
||||
public inline fun ChatBoostSource.unknownOrThrow(): ChatBoostSource.Unknown = this as
|
||||
dev.inmo.tgbotapi.types.boosts.ChatBoostSource.Unknown
|
||||
|
||||
public inline fun <T> ChatBoostSource.ifUnknown(block: (ChatBoostSource.Unknown) -> T): T? =
|
||||
unknownOrNull() ?.let(block)
|
||||
|
||||
public inline fun InlineKeyboardButton.unknownInlineKeyboardButtonOrNull():
|
||||
UnknownInlineKeyboardButton? = this as?
|
||||
dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.UnknownInlineKeyboardButton
|
||||
@@ -1731,32 +1808,34 @@ public inline fun <T>
|
||||
InlineKeyboardButton.ifWebAppInlineKeyboardButton(block: (WebAppInlineKeyboardButton) -> T): T?
|
||||
= webAppInlineKeyboardButtonOrNull() ?.let(block)
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.anyOrNull(): KeyboardButtonRequestUser.Any? = this as?
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any
|
||||
public inline fun KeyboardButtonRequestUsers.anyOrNull(): KeyboardButtonRequestUsers.Any? = this as?
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.anyOrThrow(): KeyboardButtonRequestUser.Any = this as
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Any
|
||||
|
||||
public inline fun <T> KeyboardButtonRequestUser.ifAny(block: (KeyboardButtonRequestUser.Any) -> T):
|
||||
T? = anyOrNull() ?.let(block)
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.botOrNull(): KeyboardButtonRequestUser.Bot? = this as?
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.botOrThrow(): KeyboardButtonRequestUser.Bot = this as
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Bot
|
||||
|
||||
public inline fun <T> KeyboardButtonRequestUser.ifBot(block: (KeyboardButtonRequestUser.Bot) -> T):
|
||||
T? = botOrNull() ?.let(block)
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.commonOrNull(): KeyboardButtonRequestUser.Common? = this
|
||||
as? dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common
|
||||
|
||||
public inline fun KeyboardButtonRequestUser.commonOrThrow(): KeyboardButtonRequestUser.Common = this
|
||||
as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUser.Common
|
||||
public inline fun KeyboardButtonRequestUsers.anyOrThrow(): KeyboardButtonRequestUsers.Any = this as
|
||||
dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Any
|
||||
|
||||
public inline fun <T>
|
||||
KeyboardButtonRequestUser.ifCommon(block: (KeyboardButtonRequestUser.Common) -> T): 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
|
||||
|
||||
public inline fun KeyboardButtonRequestUsers.commonOrThrow(): KeyboardButtonRequestUsers.Common =
|
||||
this as dev.inmo.tgbotapi.types.buttons.KeyboardButtonRequestUsers.Common
|
||||
|
||||
public inline fun <T>
|
||||
KeyboardButtonRequestUsers.ifCommon(block: (KeyboardButtonRequestUsers.Common) -> T): T? =
|
||||
commonOrNull() ?.let(block)
|
||||
|
||||
public inline fun KeyboardMarkup.inlineKeyboardMarkupOrNull(): InlineKeyboardMarkup? = this as?
|
||||
@@ -1902,6 +1981,24 @@ public inline fun Chat.unknownExtendedChatOrThrow(): UnknownExtendedChat = this
|
||||
public inline fun <T> Chat.ifUnknownExtendedChat(block: (UnknownExtendedChat) -> T): T? =
|
||||
unknownExtendedChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedChatOrNull(): ExtendedChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
|
||||
public inline fun Chat.extendedChatOrThrow(): ExtendedChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
|
||||
public inline fun <T> Chat.ifExtendedChat(block: (ExtendedChat) -> T): T? = extendedChatOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.extendedNonBotChatOrNull(): ExtendedNonBotChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat
|
||||
|
||||
public inline fun Chat.extendedNonBotChatOrThrow(): ExtendedNonBotChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedNonBotChat
|
||||
|
||||
public inline fun <T> Chat.ifExtendedNonBotChat(block: (ExtendedNonBotChat) -> T): T? =
|
||||
extendedNonBotChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedChannelChatOrNull(): ExtendedChannelChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
|
||||
|
||||
@@ -1956,15 +2053,6 @@ public inline fun Chat.extendedForumChatOrThrow(): ExtendedForumChat = this as
|
||||
public inline fun <T> Chat.ifExtendedForumChat(block: (ExtendedForumChat) -> T): T? =
|
||||
extendedForumChatOrNull() ?.let(block)
|
||||
|
||||
public inline fun Chat.extendedChatOrNull(): ExtendedChat? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
|
||||
public inline fun Chat.extendedChatOrThrow(): ExtendedChat = this as
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChat
|
||||
|
||||
public inline fun <T> Chat.ifExtendedChat(block: (ExtendedChat) -> T): T? = extendedChatOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Chat.extendedChatWithUsernameOrNull(): ExtendedChatWithUsername? = this as?
|
||||
dev.inmo.tgbotapi.types.chat.ExtendedChatWithUsername
|
||||
|
||||
@@ -2111,6 +2199,36 @@ 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
|
||||
|
||||
public inline fun ChatMessageReactionUpdated.byUserOrThrow(): ChatMessageReactionUpdated.ByUser =
|
||||
this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.ByUser
|
||||
|
||||
public inline fun <T>
|
||||
ChatMessageReactionUpdated.ifByUser(block: (ChatMessageReactionUpdated.ByUser) -> T): T? =
|
||||
byUserOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatMessageReactionUpdated.unknownOrNull(): ChatMessageReactionUpdated.Unknown? =
|
||||
this as? dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.Unknown
|
||||
|
||||
public inline fun ChatMessageReactionUpdated.unknownOrThrow(): ChatMessageReactionUpdated.Unknown =
|
||||
this as dev.inmo.tgbotapi.types.chat.ChatMessageReactionUpdated.Unknown
|
||||
|
||||
public inline fun <T>
|
||||
ChatMessageReactionUpdated.ifUnknown(block: (ChatMessageReactionUpdated.Unknown) -> T): T? =
|
||||
unknownOrNull() ?.let(block)
|
||||
|
||||
public inline fun DiceAnimationType.cubeDiceAnimationTypeOrNull(): CubeDiceAnimationType? = this as?
|
||||
dev.inmo.tgbotapi.types.dice.CubeDiceAnimationType
|
||||
|
||||
@@ -2611,6 +2729,51 @@ public inline fun TelegramMedia.titledTelegramMediaOrThrow(): TitledTelegramMedi
|
||||
public inline fun <T> TelegramMedia.ifTitledTelegramMedia(block: (TitledTelegramMedia) -> T): T? =
|
||||
titledTelegramMediaOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.giveawayOrNull(): Giveaway? = this as?
|
||||
dev.inmo.tgbotapi.types.giveaway.Giveaway
|
||||
|
||||
public inline fun ChatEvent.giveawayOrThrow(): Giveaway = this as
|
||||
dev.inmo.tgbotapi.types.giveaway.Giveaway
|
||||
|
||||
public inline fun <T> ChatEvent.ifGiveaway(block: (Giveaway) -> T): T? = giveawayOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun ChatEvent.giveawayCreatedOrNull(): GiveawayCreated? = this as?
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
|
||||
|
||||
public inline fun ChatEvent.giveawayCreatedOrThrow(): GiveawayCreated = this as
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayCreated
|
||||
|
||||
public inline fun <T> ChatEvent.ifGiveawayCreated(block: (GiveawayCreated) -> T): T? =
|
||||
giveawayCreatedOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.giveawayPrivateResultsOrNull(): GiveawayPrivateResults? = this as?
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
|
||||
|
||||
public inline fun ChatEvent.giveawayPrivateResultsOrThrow(): GiveawayPrivateResults = this as
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayPrivateResults
|
||||
|
||||
public inline fun <T> ChatEvent.ifGiveawayPrivateResults(block: (GiveawayPrivateResults) -> T): T? =
|
||||
giveawayPrivateResultsOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.giveawayPublicResultsOrNull(): GiveawayPublicResults? = this as?
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
|
||||
public inline fun ChatEvent.giveawayPublicResultsOrThrow(): GiveawayPublicResults = this as
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayPublicResults
|
||||
|
||||
public inline fun <T> ChatEvent.ifGiveawayPublicResults(block: (GiveawayPublicResults) -> T): T? =
|
||||
giveawayPublicResultsOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.giveawayResultsOrNull(): GiveawayResults? = this as?
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayResults
|
||||
|
||||
public inline fun ChatEvent.giveawayResultsOrThrow(): GiveawayResults = this as
|
||||
dev.inmo.tgbotapi.types.giveaway.GiveawayResults
|
||||
|
||||
public inline fun <T> ChatEvent.ifGiveawayResults(block: (GiveawayResults) -> T): T? =
|
||||
giveawayResultsOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.channelChatCreatedOrNull(): ChannelChatCreated? = this as?
|
||||
dev.inmo.tgbotapi.types.message.ChatEvents.ChannelChatCreated
|
||||
|
||||
@@ -2938,13 +3101,13 @@ public inline fun ChatEvent.chatSharedRequestOrThrow(): ChatSharedRequest = this
|
||||
public inline fun <T> ChatEvent.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
||||
chatSharedRequestOrNull() ?.let(block)
|
||||
|
||||
public inline fun ChatEvent.userSharedOrNull(): UserShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.UserShared
|
||||
public inline fun ChatEvent.usersSharedOrNull(): UsersShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.UsersShared
|
||||
|
||||
public inline fun ChatEvent.userSharedOrThrow(): UserShared = this as
|
||||
dev.inmo.tgbotapi.types.request.UserShared
|
||||
public inline fun ChatEvent.usersSharedOrThrow(): UsersShared = this as
|
||||
dev.inmo.tgbotapi.types.request.UsersShared
|
||||
|
||||
public inline fun <T> ChatEvent.ifUserShared(block: (UserShared) -> T): T? = userSharedOrNull()
|
||||
public inline fun <T> ChatEvent.ifUsersShared(block: (UsersShared) -> T): T? = usersSharedOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun ForwardInfo.byAnonymousOrNull(): ForwardInfo.ByAnonymous? = this as?
|
||||
@@ -3645,6 +3808,15 @@ public inline fun ResendableContent.voiceContentOrThrow(): VoiceContent = this a
|
||||
public inline fun <T> ResendableContent.ifVoiceContent(block: (VoiceContent) -> T): T? =
|
||||
voiceContentOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.blockquoteTextSourceOrNull(): BlockquoteTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource
|
||||
|
||||
public inline fun TextSource.blockquoteTextSourceOrThrow(): BlockquoteTextSource = this as
|
||||
dev.inmo.tgbotapi.types.message.textsources.BlockquoteTextSource
|
||||
|
||||
public inline fun <T> TextSource.ifBlockquoteTextSource(block: (BlockquoteTextSource) -> T): T? =
|
||||
blockquoteTextSourceOrNull() ?.let(block)
|
||||
|
||||
public inline fun TextSource.boldTextSourceOrNull(): BoldTextSource? = this as?
|
||||
dev.inmo.tgbotapi.types.message.textsources.BoldTextSource
|
||||
|
||||
@@ -4485,6 +4657,33 @@ 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
|
||||
|
||||
public inline fun Reaction.emojiOrThrow(): Reaction.Emoji = this as
|
||||
dev.inmo.tgbotapi.types.reactions.Reaction.Emoji
|
||||
|
||||
public inline fun <T> Reaction.ifEmoji(block: (Reaction.Emoji) -> T): T? = emojiOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun Reaction.unknownOrNull(): Reaction.Unknown? = this as?
|
||||
dev.inmo.tgbotapi.types.reactions.Reaction.Unknown
|
||||
|
||||
public inline fun Reaction.unknownOrThrow(): Reaction.Unknown = this as
|
||||
dev.inmo.tgbotapi.types.reactions.Reaction.Unknown
|
||||
|
||||
public inline fun <T> Reaction.ifUnknown(block: (Reaction.Unknown) -> T): T? = unknownOrNull()
|
||||
?.let(block)
|
||||
|
||||
public inline fun RequestResponse.chatSharedOrNull(): ChatShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.ChatShared
|
||||
|
||||
@@ -4503,14 +4702,14 @@ public inline fun RequestResponse.chatSharedRequestOrThrow(): ChatSharedRequest
|
||||
public inline fun <T> RequestResponse.ifChatSharedRequest(block: (ChatSharedRequest) -> T): T? =
|
||||
chatSharedRequestOrNull() ?.let(block)
|
||||
|
||||
public inline fun RequestResponse.userSharedOrNull(): UserShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.UserShared
|
||||
public inline fun RequestResponse.usersSharedOrNull(): UsersShared? = this as?
|
||||
dev.inmo.tgbotapi.types.request.UsersShared
|
||||
|
||||
public inline fun RequestResponse.userSharedOrThrow(): UserShared = this as
|
||||
dev.inmo.tgbotapi.types.request.UserShared
|
||||
public inline fun RequestResponse.usersSharedOrThrow(): UsersShared = this as
|
||||
dev.inmo.tgbotapi.types.request.UsersShared
|
||||
|
||||
public inline fun <T> RequestResponse.ifUserShared(block: (UserShared) -> T): T? =
|
||||
userSharedOrNull() ?.let(block)
|
||||
public inline fun <T> RequestResponse.ifUsersShared(block: (UsersShared) -> T): T? =
|
||||
usersSharedOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.callbackQueryUpdateOrNull(): CallbackQueryUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.CallbackQueryUpdate
|
||||
@@ -4530,6 +4729,24 @@ public inline fun Update.channelPostUpdateOrThrow(): ChannelPostUpdate = this as
|
||||
public inline fun <T> Update.ifChannelPostUpdate(block: (ChannelPostUpdate) -> T): T? =
|
||||
channelPostUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chatBoostRemovedUpdateOrNull(): ChatBoostRemovedUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate
|
||||
|
||||
public inline fun Update.chatBoostRemovedUpdateOrThrow(): ChatBoostRemovedUpdate = this as
|
||||
dev.inmo.tgbotapi.types.update.ChatBoostRemovedUpdate
|
||||
|
||||
public inline fun <T> Update.ifChatBoostRemovedUpdate(block: (ChatBoostRemovedUpdate) -> T): T? =
|
||||
chatBoostRemovedUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chatBoostUpdatedUpdateOrNull(): ChatBoostUpdatedUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate
|
||||
|
||||
public inline fun Update.chatBoostUpdatedUpdateOrThrow(): ChatBoostUpdatedUpdate = this as
|
||||
dev.inmo.tgbotapi.types.update.ChatBoostUpdatedUpdate
|
||||
|
||||
public inline fun <T> Update.ifChatBoostUpdatedUpdate(block: (ChatBoostUpdatedUpdate) -> T): T? =
|
||||
chatBoostUpdatedUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chatJoinRequestUpdateOrNull(): ChatJoinRequestUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate
|
||||
|
||||
@@ -4539,6 +4756,28 @@ public inline fun Update.chatJoinRequestUpdateOrThrow(): ChatJoinRequestUpdate =
|
||||
public inline fun <T> Update.ifChatJoinRequestUpdate(block: (ChatJoinRequestUpdate) -> T): T? =
|
||||
chatJoinRequestUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chatMessageReactionUpdatedUpdateOrNull(): ChatMessageReactionUpdatedUpdate?
|
||||
= this as? dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate
|
||||
|
||||
public inline fun Update.chatMessageReactionUpdatedUpdateOrThrow(): ChatMessageReactionUpdatedUpdate
|
||||
= this as dev.inmo.tgbotapi.types.update.ChatMessageReactionUpdatedUpdate
|
||||
|
||||
public inline fun <T>
|
||||
Update.ifChatMessageReactionUpdatedUpdate(block: (ChatMessageReactionUpdatedUpdate) -> T): T? =
|
||||
chatMessageReactionUpdatedUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chatMessageReactionsCountUpdatedUpdateOrNull():
|
||||
ChatMessageReactionsCountUpdatedUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate
|
||||
|
||||
public inline fun Update.chatMessageReactionsCountUpdatedUpdateOrThrow():
|
||||
ChatMessageReactionsCountUpdatedUpdate = this as
|
||||
dev.inmo.tgbotapi.types.update.ChatMessageReactionsCountUpdatedUpdate
|
||||
|
||||
public inline fun <T>
|
||||
Update.ifChatMessageReactionsCountUpdatedUpdate(block: (ChatMessageReactionsCountUpdatedUpdate) -> T):
|
||||
T? = chatMessageReactionsCountUpdatedUpdateOrNull() ?.let(block)
|
||||
|
||||
public inline fun Update.chosenInlineResultUpdateOrNull(): ChosenInlineResultUpdate? = this as?
|
||||
dev.inmo.tgbotapi.types.update.ChosenInlineResultUpdate
|
||||
|
||||
|
||||
@@ -40,6 +40,10 @@ fun Update.sourceChatWithConverters(
|
||||
editChannelPostUpdateConverter: (EditChannelPostUpdate) -> Chat? = { it.data.chat },
|
||||
editMessageUpdateConverter: (EditMessageUpdate) -> Chat? = { it.data.chat },
|
||||
myChatMemberUpdatedUpdateConverter: (MyChatMemberUpdatedUpdate) -> Chat? = { it.data.chat },
|
||||
chatMessageReactionUpdatedUpdateConverter: (ChatMessageReactionUpdatedUpdate) -> Chat? = { it.data.chat },
|
||||
chatMessageReactionsCountUpdatedUpdateConverter: (ChatMessageReactionsCountUpdatedUpdate) -> Chat? = { it.data.chat },
|
||||
chatBoostUpdatedUpdateFlow: (ChatBoostUpdatedUpdate) -> Chat? = { it.data.chat },
|
||||
chatBoostRemovedUpdateFlow: (ChatBoostRemovedUpdate) -> Chat? = { it.data.chat },
|
||||
commonChatMemberUpdatedUpdateConverter: (CommonChatMemberUpdatedUpdate) -> Chat? = { it.data.chat }
|
||||
): Chat? = when (this) {
|
||||
is BaseMessageUpdate -> baseMessageUpdateConverter(this)
|
||||
@@ -57,6 +61,10 @@ fun Update.sourceChatWithConverters(
|
||||
is EditMessageUpdate -> editMessageUpdateConverter(this)
|
||||
is MyChatMemberUpdatedUpdate -> myChatMemberUpdatedUpdateConverter(this)
|
||||
is CommonChatMemberUpdatedUpdate -> commonChatMemberUpdatedUpdateConverter(this)
|
||||
is ChatMessageReactionUpdatedUpdate -> chatMessageReactionUpdatedUpdateConverter(this)
|
||||
is ChatMessageReactionsCountUpdatedUpdate -> chatMessageReactionsCountUpdatedUpdateConverter(this)
|
||||
is ChatBoostUpdatedUpdate -> chatBoostUpdatedUpdateFlow(this)
|
||||
is ChatBoostRemovedUpdate -> chatBoostRemovedUpdateFlow(this)
|
||||
else -> {
|
||||
when (val data = data) {
|
||||
is FromUser -> data.from
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user