mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-18 21:45:06 +00:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b688fa570a | |||
| 0eba0c4e15 | |||
| f8bbfa2b1e | |||
| fec2715dc1 | |||
|
|
941a25b116 | ||
| 741d808db2 | |||
| 69683a4e6a | |||
| e5a48e9684 | |||
| 6722ab5f50 | |||
| 810b2ab5a1 | |||
| 5992fdd456 | |||
| 3c4f8787a6 | |||
| 0c24aa1270 | |||
| 988d9995c5 | |||
| f75df0a425 | |||
| 9f14eb2ca3 | |||
| 6f9f880b79 | |||
| 2d2310daca | |||
| dff04d26ca | |||
| 4390c12180 | |||
| 1b4d13e452 | |||
| afda5e0e7f | |||
| cd354e9456 |
26
CHANGELOG.md
26
CHANGELOG.md
@@ -1,6 +1,30 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
## 6.2.0
|
## 7.0.1
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* New interface `WithChat` which contains `chat` field
|
||||||
|
* `Message` now inherits `WithChat`
|
||||||
|
* `ChatMemberUpdated` now inherits `WithChat`
|
||||||
|
* `Utils`:
|
||||||
|
* Improvements in `same`-notations
|
||||||
|
|
||||||
|
## 7.0.0
|
||||||
|
|
||||||
|
This update contains support of [Telegram Bot API 6.6](https://core.telegram.org/bots/api-changelog#march-9-2023)
|
||||||
|
|
||||||
|
**THIS VERSION CONTAINS BREAKING CHANGES**:
|
||||||
|
|
||||||
|
* All previous deprecations have been removed
|
||||||
|
* Fully reworked mechanism of stickers creating and adding
|
||||||
|
* All separations of stickers types like `Animeted` have been replaces with type `StickerFormat`
|
||||||
|
* New `InputSticker` type (and all subtypes) as replacements for old raw fields in methods
|
||||||
|
* Reworked mechanism of files uploading
|
||||||
|
|
||||||
|
Other changes
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.17.3` -> `0.17.5`
|
||||||
|
|
||||||
## 6.1.0
|
## 6.1.0
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#february-3-2023)
|
# TelegramBotAPI [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [](https://core.telegram.org/bots/api-changelog#march-9-2023)
|
||||||
|
|
||||||
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| Docs | [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
|:---:|:---:|
|
|:---:|:---:|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=6.2.0
|
library_version=7.0.1
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ ktor = "2.2.4"
|
|||||||
ksp = "1.8.10-1.0.9"
|
ksp = "1.8.10-1.0.9"
|
||||||
kotlin-poet = "1.12.0"
|
kotlin-poet = "1.12.0"
|
||||||
|
|
||||||
microutils = "0.17.3"
|
microutils = "0.17.5"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
dokka = "1.8.10"
|
dokka = "1.8.10"
|
||||||
@@ -45,6 +45,7 @@ microutils-coroutines = { module = "dev.inmo:micro_utils.coroutines", version.re
|
|||||||
microutils-serialization-base64 = { module = "dev.inmo:micro_utils.serialization.base64", 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" }
|
microutils-serialization-encapsulator = { module = "dev.inmo:micro_utils.serialization.encapsulator", version.ref = "microutils" }
|
||||||
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
|
microutils-serialization-typedSerializer = { module = "dev.inmo:micro_utils.serialization.typed_serializer", version.ref = "microutils" }
|
||||||
|
microutils-serialization-mapper = { module = "dev.inmo:micro_utils.serialization.mapper", version.ref = "microutils" }
|
||||||
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
microutils-languageCodes = { module = "dev.inmo:micro_utils.language_codes", version.ref = "microutils" }
|
||||||
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
microutils-ktor-common = { module = "dev.inmo:micro_utils.ktor.common", version.ref = "microutils" }
|
||||||
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
microutils-fsm-common = { module = "dev.inmo:micro_utils.fsm.common", version.ref = "microutils" }
|
||||||
|
|||||||
@@ -10,13 +10,6 @@ suspend fun TelegramBot.getStickerSet(
|
|||||||
GetStickerSet(name)
|
GetStickerSet(name)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow"))
|
|
||||||
suspend fun TelegramBot.getStickerSet(
|
|
||||||
sticker: Sticker
|
|
||||||
) = getStickerSet(
|
|
||||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.getStickerSetOrNull(
|
suspend fun TelegramBot.getStickerSetOrNull(
|
||||||
sticker: Sticker
|
sticker: Sticker
|
||||||
) = sticker.stickerSetName ?.let {
|
) = sticker.stickerSetName ?.let {
|
||||||
|
|||||||
@@ -685,20 +685,22 @@ suspend inline fun TelegramBot.reply(
|
|||||||
suspend inline fun TelegramBot.replyWithSticker(
|
suspend inline fun TelegramBot.replyWithSticker(
|
||||||
to: Message,
|
to: Message,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
to: Message,
|
to: Message,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Videos
|
// Videos
|
||||||
|
|||||||
@@ -761,22 +761,24 @@ suspend inline fun TelegramBot.replyWithSticker(
|
|||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
suspend inline fun TelegramBot.reply(
|
suspend inline fun TelegramBot.reply(
|
||||||
toChatId: IdChatIdentifier,
|
toChatId: IdChatIdentifier,
|
||||||
toMessageId: MessageId,
|
toMessageId: MessageId,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = toChatId.threadId,
|
threadId: MessageThreadId? = toChatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(toChatId, sticker, threadId, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(toChatId, sticker, threadId, emoji, disableNotification, protectContent, toMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
// Videos
|
// Videos
|
||||||
|
|||||||
@@ -1111,12 +1111,13 @@ suspend fun TelegramBot.send(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will execute [sendSticker] request
|
* Will execute [sendSticker] request
|
||||||
@@ -1127,12 +1128,13 @@ suspend fun TelegramBot.send(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,13 +19,14 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
SendSticker(chatId, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,12 +37,13 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: InputFile,
|
sticker: InputFile,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat.id, sticker, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -51,12 +53,13 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chatId, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
|
||||||
@@ -66,9 +69,10 @@ suspend fun TelegramBot.sendSticker(
|
|||||||
chat: Chat,
|
chat: Chat,
|
||||||
sticker: Sticker,
|
sticker: Sticker,
|
||||||
threadId: MessageThreadId? = chat.id.threadId,
|
threadId: MessageThreadId? = chat.id.threadId,
|
||||||
|
emoji: String? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = sendSticker(chat, sticker.fileId, threadId, emoji, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddAnimatedStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddAnimatedStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addAnimatedStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addAnimatedStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddStaticStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddStaticStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addStaticStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addStaticStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.AddStickerToSet
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
|
import dev.inmo.tgbotapi.types.StickerType
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSetName: String,
|
||||||
|
inputSticker: InputSticker
|
||||||
|
) = execute(
|
||||||
|
AddStickerToSet(userId, stickerSetName, inputSticker)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputSticker
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet.name,
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
keywords: List<String> = emptyList()
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet,
|
||||||
|
when (stickerSet.stickerType) {
|
||||||
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
keywords
|
||||||
|
)
|
||||||
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
|
sticker,
|
||||||
|
emojis
|
||||||
|
)
|
||||||
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
keywords
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
userId: UserId,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
userId,
|
||||||
|
stickerSet.name,
|
||||||
|
when (stickerSet.stickerType) {
|
||||||
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
maskPosition
|
||||||
|
)
|
||||||
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
|
sticker,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> error("Unable to create sticker to the set with type ${stickerSet.stickerType}")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputSticker
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id,
|
||||||
|
stickerSet.name,
|
||||||
|
sticker
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
keywords: List<String> = emptyList()
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet, sticker, emojis, keywords
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.addStickerToSet(
|
||||||
|
user: CommonUser,
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
sticker: InputFile,
|
||||||
|
emojis: List<String>,
|
||||||
|
maskPosition: MaskPosition? = null
|
||||||
|
) = addStickerToSet(
|
||||||
|
user.id, stickerSet, sticker, emojis, maskPosition
|
||||||
|
)
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.AddVideoStickerToSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
AddVideoStickerToSet(userId, stickerSetName, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSetName, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
userId, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.addVideoStickerToSet(
|
|
||||||
user: CommonUser,
|
|
||||||
stickerSet: StickerSet,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = addVideoStickerToSet(
|
|
||||||
user.id, stickerSet.name, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewAnimatedStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewAnimatedStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskAnimatedStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = execute(
|
|
||||||
CreateNewMaskVideoStickerSet(userId, name, title, sticker, emojis, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewMaskVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
) = createNewMaskVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularAnimatedStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularAnimatedStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularAnimatedStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.*
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = execute(
|
|
||||||
CreateNewRegularVideoStickerSet(userId, name, title, sticker, emojis)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewRegularVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String
|
|
||||||
) = createNewRegularVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis
|
|
||||||
)
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewStaticStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewStaticStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewStaticStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewStaticStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewStaticStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.CreateNewStickerSet
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewStickerSet(
|
||||||
|
userId: UserId,
|
||||||
|
name: String,
|
||||||
|
title: String,
|
||||||
|
stickersFormat: StickerFormat,
|
||||||
|
stickers: List<InputSticker>,
|
||||||
|
needsRepainting: Boolean = false
|
||||||
|
) = execute(
|
||||||
|
CreateNewStickerSet(userId, name, title, stickersFormat, stickers, needsRepainting)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
suspend fun TelegramBot.createNewStickerSet(
|
||||||
|
user: CommonUser,
|
||||||
|
name: String,
|
||||||
|
title: String,
|
||||||
|
stickersFormat: StickerFormat,
|
||||||
|
stickers: List<InputSticker>,
|
||||||
|
needsRepainting: Boolean = false,
|
||||||
|
) = createNewStickerSet(
|
||||||
|
user.id, name, title, stickersFormat, stickers, needsRepainting
|
||||||
|
)
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.CreateNewVideoStickerSet
|
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = execute(
|
|
||||||
CreateNewVideoStickerSet(userId, name, title, sticker, emojis, containsMasks, maskPosition)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: FileId,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
suspend fun TelegramBot.createNewVideoStickerSet(
|
|
||||||
user: CommonUser,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: MultipartFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
) = createNewVideoStickerSet(
|
|
||||||
user.id, name, title, sticker, emojis, containsMasks, maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.thumbs
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetCustomEmojiStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail
|
||||||
|
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||||
|
import dev.inmo.tgbotapi.types.StickerSetName
|
||||||
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.StickerSet
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSetName: StickerSetName,
|
||||||
|
customEmojiId: CustomEmojiId
|
||||||
|
) = execute(
|
||||||
|
SetCustomEmojiStickerSetThumbnail(stickerSetName, customEmojiId)
|
||||||
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSet: StickerSet,
|
||||||
|
customEmojiId: CustomEmojiId
|
||||||
|
) = setCustomEmojiStickerSetThumbnail(
|
||||||
|
stickerSet.name, customEmojiId
|
||||||
|
)
|
||||||
@@ -3,19 +3,22 @@ package dev.inmo.tgbotapi.extensions.api.stickers
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
import dev.inmo.tgbotapi.requests.stickers.UploadStickerFile
|
||||||
|
import dev.inmo.tgbotapi.types.StickerFormat
|
||||||
import dev.inmo.tgbotapi.types.chat.CommonUser
|
import dev.inmo.tgbotapi.types.chat.CommonUser
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(userId, sticker)
|
UploadStickerFile(userId, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend fun TelegramBot.uploadStickerFile(
|
suspend fun TelegramBot.uploadStickerFile(
|
||||||
user: CommonUser,
|
user: CommonUser,
|
||||||
sticker: MultipartFile
|
sticker: MultipartFile,
|
||||||
|
stickerFormat: StickerFormat
|
||||||
) = execute(
|
) = execute(
|
||||||
UploadStickerFile(user.id, sticker)
|
UploadStickerFile(user.id, sticker, stickerFormat)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|||||||
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
import io.ktor.util.cio.use
|
import io.ktor.util.cio.use
|
||||||
import io.ktor.util.cio.writeChannel
|
import io.ktor.util.cio.writeChannel
|
||||||
|
import io.ktor.utils.io.copyAndClose
|
||||||
import io.ktor.utils.io.copyTo
|
import io.ktor.utils.io.copyTo
|
||||||
import kotlinx.coroutines.job
|
import kotlinx.coroutines.job
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -25,7 +26,7 @@ suspend fun TelegramBot.downloadFile(
|
|||||||
doOutsideOfCoroutine { destFile.createNewFile() }
|
doOutsideOfCoroutine { destFile.createNewFile() }
|
||||||
|
|
||||||
destFile.writeChannel(coroutineContext.job).use {
|
destFile.writeChannel(coroutineContext.job).use {
|
||||||
readChannel.copyTo(this)
|
readChannel.copyAndClose(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
return destFile
|
return destFile
|
||||||
|
|||||||
@@ -30,11 +30,17 @@ suspend fun TelegramBot.downloadFileToTemp(
|
|||||||
|
|
||||||
suspend fun TelegramBot.downloadFileToTemp(
|
suspend fun TelegramBot.downloadFileToTemp(
|
||||||
pathedFile: PathedFile
|
pathedFile: PathedFile
|
||||||
) = downloadFileToTemp(
|
): File = downloadFileToTemp(
|
||||||
pathedFile.filePath
|
pathedFile.filePath
|
||||||
).apply {
|
).run {
|
||||||
runCatching {
|
val newFile = File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}")
|
||||||
renameTo(File(parentFile, "$nameWithoutExtension.${pathedFile.fileName.fileExtension}"))
|
val success = runCatching {
|
||||||
|
renameTo(newFile)
|
||||||
|
}.getOrElse { false }
|
||||||
|
if (success) {
|
||||||
|
newFile
|
||||||
|
} else {
|
||||||
|
this@run
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,6 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitContent(
|
|||||||
): Flow<O> = waitContentMessage<O>(initRequest, errorFactory).map { it.content }
|
): Flow<O> = waitContentMessage<O>(initRequest, errorFactory).map { it.content }
|
||||||
|
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
includeMediaGroupsDeprecationMessage,
|
|
||||||
ReplaceWith("waitAnyContent(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContent")
|
|
||||||
)
|
|
||||||
suspend fun BehaviourContext.waitContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MessageContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyContent(
|
suspend fun BehaviourContext.waitAnyContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -69,62 +60,26 @@ suspend fun BehaviourContext.waitVenue(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<VenueContent>(initRequest, errorFactory)
|
) = waitContent<VenueContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
suspend fun BehaviourContext.waitAudioMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitMedia(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMedia(
|
suspend fun BehaviourContext.waitMedia(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<MediaContent>(initRequest, errorFactory)
|
) = waitContent<MediaContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
suspend fun BehaviourContext.waitAnyMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<MediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
suspend fun BehaviourContext.waitVisualMediaGroupContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContent<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<TextedMediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContent(
|
suspend fun BehaviourContext.waitTextedMediaContent(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -133,32 +88,14 @@ suspend fun BehaviourContext.waitAnimation(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<AnimationContent>(initRequest, errorFactory)
|
) = waitContent<AnimationContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudio(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<AudioContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudio(
|
suspend fun BehaviourContext.waitAudio(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<AudioContent>(initRequest, errorFactory)
|
) = waitContent<AudioContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocument(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocument(
|
suspend fun BehaviourContext.waitDocument(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
) = waitContent<DocumentContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<PhotoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitPhoto(
|
suspend fun BehaviourContext.waitPhoto(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -167,12 +104,6 @@ suspend fun BehaviourContext.waitSticker(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContent<StickerContent>(initRequest, errorFactory)
|
) = waitContent<StickerContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVideo(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContent<VideoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVideo(
|
suspend fun BehaviourContext.waitVideo(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
|||||||
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
|
||||||
const val includeMediaGroupsDeprecationMessage = "includeMediaGroups is deprecated and its usage will not lead to any changes"
|
|
||||||
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
typealias CommonMessageToCommonMessageMapper<T> = suspend CommonMessage<T>.() -> CommonMessage<T>?
|
||||||
|
|
||||||
@RiskFeature(lowLevelRiskFeatureMessage)
|
@RiskFeature(lowLevelRiskFeatureMessage)
|
||||||
@@ -47,15 +46,6 @@ internal inline fun <reified T : MessageContent> contentMessageConverter(
|
|||||||
if (content is T) this as CommonMessage<T> else null
|
if (content is T) this as CommonMessage<T> else null
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated(
|
|
||||||
includeMediaGroupsDeprecationMessage,
|
|
||||||
ReplaceWith("waitAnyContentMessage(initRequest, errorFactory)", "dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitAnyContentMessage")
|
|
||||||
)
|
|
||||||
suspend fun BehaviourContext.waitContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MessageContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyContentMessage(
|
suspend fun BehaviourContext.waitAnyContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
errorFactory: NullableRequestBuilder<*> = { null },
|
||||||
@@ -96,62 +86,26 @@ suspend fun BehaviourContext.waitVenueMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<VenueContent>(initRequest, errorFactory)
|
) = waitContentMessage<VenueContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitMediaMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitMediaMessage(
|
suspend fun BehaviourContext.waitMediaMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
) = waitContentMessage<MediaContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<TextedMediaContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
suspend fun BehaviourContext.waitTextedMediaContentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -160,32 +114,14 @@ suspend fun BehaviourContext.waitAnimationMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AnimationContent>(initRequest, errorFactory)
|
) = waitContentMessage<AnimationContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitAudioMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitAudioMessage(
|
suspend fun BehaviourContext.waitAudioMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
) = waitContentMessage<AudioContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitDocumentMessage(
|
suspend fun BehaviourContext.waitDocumentMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
) = waitContentMessage<DocumentContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitPhotoMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<PhotoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitPhotoMessage(
|
suspend fun BehaviourContext.waitPhotoMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
@@ -194,12 +130,6 @@ suspend fun BehaviourContext.waitStickerMessage(
|
|||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitContentMessage<StickerContent>(initRequest, errorFactory)
|
) = waitContentMessage<StickerContent>(initRequest, errorFactory)
|
||||||
@Deprecated(includeMediaGroupsDeprecationMessage)
|
|
||||||
suspend fun BehaviourContext.waitVideoMessage(
|
|
||||||
initRequest: Request<*>? = null,
|
|
||||||
errorFactory: NullableRequestBuilder<*> = { null },
|
|
||||||
includeMediaGroups: Boolean
|
|
||||||
) = waitContentMessage<VideoContent>(initRequest, errorFactory)
|
|
||||||
suspend fun BehaviourContext.waitVideoMessage(
|
suspend fun BehaviourContext.waitVideoMessage(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEvents(
|
|||||||
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
suspend fun BehaviourContext.waitLeftChatMemberEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEvents<LeftChatMember>(initRequest, errorFactory)
|
) = waitEvents<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||||
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
suspend fun BehaviourContext.waitNewChatPhotoEvents(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ suspend fun BehaviourContext.waitGroupChatCreatedEventsMessages(
|
|||||||
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
suspend fun BehaviourContext.waitLeftChatMemberEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitEventsMessages<LeftChatMember>(initRequest, errorFactory)
|
) = waitEventsMessages<LeftChatMemberEvent>(initRequest, errorFactory)
|
||||||
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
suspend fun BehaviourContext.waitNewChatPhotoEventsMessages(
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
|||||||
@@ -346,10 +346,10 @@ suspend fun <BC : BehaviourContext> BC.onGroupChatCreated(
|
|||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
suspend fun <BC : BehaviourContext> BC.onLeftChatMember(
|
suspend fun <BC : BehaviourContext> BC.onLeftChatMember(
|
||||||
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMember>>? = null,
|
initialFilter: SimpleFilter<ChatEventMessage<LeftChatMemberEvent>>? = null,
|
||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMember>, Update>? = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, ChatEventMessage<LeftChatMemberEvent>, Update>? = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMember>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<LeftChatMemberEvent>, Any> = ByChatMessageMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMember>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<LeftChatMemberEvent>>
|
||||||
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = onEvent(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ kotlin {
|
|||||||
api libs.microutils.serialization.base64
|
api libs.microutils.serialization.base64
|
||||||
api libs.microutils.serialization.encapsulator
|
api libs.microutils.serialization.encapsulator
|
||||||
api libs.microutils.serialization.typedSerializer
|
api libs.microutils.serialization.typedSerializer
|
||||||
|
api libs.microutils.serialization.mapper
|
||||||
api libs.microutils.ktor.common
|
api libs.microutils.ktor.common
|
||||||
api libs.microutils.languageCodes
|
api libs.microutils.languageCodes
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package dev.inmo.tgbotapi.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
/**
|
||||||
|
* All inheritors of this interface have [chat] field and related to this [chat]
|
||||||
|
*/
|
||||||
|
interface WithChat {
|
||||||
|
val chat: Chat
|
||||||
|
}
|
||||||
@@ -36,8 +36,10 @@ sealed class InputFile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal const val attachPrefix = "attach://"
|
||||||
|
|
||||||
internal inline val InputFile.attachFileId
|
internal inline val InputFile.attachFileId
|
||||||
get() = "attach://$fileId"
|
get() = "$attachPrefix$fileId"
|
||||||
internal inline val InputFile.fileIdToSend
|
internal inline val InputFile.fileIdToSend
|
||||||
get() = when (this) {
|
get() = when (this) {
|
||||||
is FileId -> fileId
|
is FileId -> fileId
|
||||||
@@ -60,8 +62,8 @@ fun String.toInputFile() = FileId(this)
|
|||||||
@RiskFeature
|
@RiskFeature
|
||||||
object InputFileSerializer : KSerializer<InputFile> {
|
object InputFileSerializer : KSerializer<InputFile> {
|
||||||
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
override val descriptor: SerialDescriptor = PrimitiveSerialDescriptor(FileId::class.toString(), PrimitiveKind.STRING)
|
||||||
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileId)
|
override fun serialize(encoder: Encoder, value: InputFile) = encoder.encodeString(value.fileIdToSend)
|
||||||
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString())
|
override fun deserialize(decoder: Decoder): FileId = FileId(decoder.decodeString().removePrefix(attachPrefix))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:: add checks for files size
|
// TODO:: add checks for files size
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -22,7 +23,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendAnimation(
|
fun SendAnimation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
animation: InputFile,
|
animation: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
@@ -36,15 +37,13 @@ fun SendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AnimationContent>> {
|
): Request<ContentMessage<AnimationContent>> {
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
|
||||||
val animationAsFile = animation as? MultipartFile
|
val animationAsFile = animation as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAnimationData(
|
val data = SendAnimationData(
|
||||||
chatId,
|
chatId,
|
||||||
animationAsFileId,
|
animation,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -63,9 +62,9 @@ fun SendAnimation(
|
|||||||
return if (animationAsFile == null && thumbAsFile == null) {
|
return if (animationAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAnimationFiles(animationAsFile, thumbAsFile)
|
listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +72,7 @@ fun SendAnimation(
|
|||||||
fun SendAnimation(
|
fun SendAnimation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
animation: InputFile,
|
animation: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -86,15 +85,13 @@ fun SendAnimation(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AnimationContent>> {
|
): Request<ContentMessage<AnimationContent>> {
|
||||||
val animationAsFileId = (animation as? FileId) ?.fileId
|
|
||||||
val animationAsFile = animation as? MultipartFile
|
val animationAsFile = animation as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAnimationData(
|
val data = SendAnimationData(
|
||||||
chatId,
|
chatId,
|
||||||
animationAsFileId,
|
animation,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -113,9 +110,9 @@ fun SendAnimation(
|
|||||||
return if (animationAsFile == null && thumbAsFile == null) {
|
return if (animationAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAnimationFiles(animationAsFile, thumbAsFile)
|
listOfNotNull(animationAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -128,7 +125,7 @@ data class SendAnimationData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(animationField)
|
@SerialName(animationField)
|
||||||
val animation: String? = null,
|
val animation: InputFile,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.requests.send.media
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.abstracts.Performerable
|
import dev.inmo.tgbotapi.abstracts.Performerable
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -23,7 +24,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendAudio(
|
fun SendAudio(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
audio: InputFile,
|
audio: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -36,15 +37,13 @@ fun SendAudio(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AudioContent>> {
|
): Request<ContentMessage<AudioContent>> {
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
|
||||||
val audioAsFile = audio as? MultipartFile
|
val audioAsFile = audio as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAudioData(
|
val data = SendAudioData(
|
||||||
chatId,
|
chatId,
|
||||||
audioAsFileId,
|
audio,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -62,9 +61,9 @@ fun SendAudio(
|
|||||||
return if (audioAsFile == null && thumbAsFile == null) {
|
return if (audioAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAudioFiles(audioAsFile, thumbAsFile)
|
listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,7 +71,7 @@ fun SendAudio(
|
|||||||
fun SendAudio(
|
fun SendAudio(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
audio: InputFile,
|
audio: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: List<TextSource>,
|
entities: List<TextSource>,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
performer: String? = null,
|
performer: String? = null,
|
||||||
@@ -84,15 +83,13 @@ fun SendAudio(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<AudioContent>> {
|
): Request<ContentMessage<AudioContent>> {
|
||||||
val audioAsFileId = (audio as? FileId) ?.fileId
|
|
||||||
val audioAsFile = audio as? MultipartFile
|
val audioAsFile = audio as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendAudioData(
|
val data = SendAudioData(
|
||||||
chatId,
|
chatId,
|
||||||
audioAsFileId,
|
audio,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -110,9 +107,9 @@ fun SendAudio(
|
|||||||
return if (audioAsFile == null && thumbAsFile == null) {
|
return if (audioAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendAudioFiles(audioAsFile, thumbAsFile)
|
listOfNotNull(audioAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +122,7 @@ data class SendAudioData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(audioField)
|
@SerialName(audioField)
|
||||||
val audio: String? = null,
|
val audio: InputFile,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -31,7 +32,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendDocument(
|
fun SendDocument(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
document: InputFile,
|
document: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
@@ -42,15 +43,13 @@ fun SendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
): Request<ContentMessage<DocumentContent>> {
|
): Request<ContentMessage<DocumentContent>> {
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
|
||||||
val documentAsFile = document as? MultipartFile
|
val documentAsFile = document as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendDocumentData(
|
val data = SendDocumentData(
|
||||||
chatId,
|
chatId,
|
||||||
documentAsFileId,
|
document,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -66,9 +65,9 @@ fun SendDocument(
|
|||||||
return if (documentAsFile == null && thumbAsFile == null) {
|
return if (documentAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendDocumentFiles(documentAsFile, thumbAsFile)
|
listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ fun SendDocument(
|
|||||||
fun SendDocument(
|
fun SendDocument(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
document: InputFile,
|
document: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -95,15 +94,13 @@ fun SendDocument(
|
|||||||
replyMarkup: KeyboardMarkup? = null,
|
replyMarkup: KeyboardMarkup? = null,
|
||||||
disableContentTypeDetection: Boolean? = null
|
disableContentTypeDetection: Boolean? = null
|
||||||
): Request<ContentMessage<DocumentContent>> {
|
): Request<ContentMessage<DocumentContent>> {
|
||||||
val documentAsFileId = (document as? FileId) ?.fileId
|
|
||||||
val documentAsFile = document as? MultipartFile
|
val documentAsFile = document as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendDocumentData(
|
val data = SendDocumentData(
|
||||||
chatId,
|
chatId,
|
||||||
documentAsFileId,
|
document,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -119,9 +116,9 @@ fun SendDocument(
|
|||||||
return if (documentAsFile == null && thumbAsFile == null) {
|
return if (documentAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendDocumentFiles(documentAsFile, thumbAsFile)
|
listOfNotNull(documentAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +140,7 @@ data class SendDocumentData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(documentField)
|
@SerialName(documentField)
|
||||||
val document: String? = null,
|
val document: InputFile,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package dev.inmo.tgbotapi.requests.send.media
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
import dev.inmo.tgbotapi.requests.abstracts.MultipartFile
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
|
||||||
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
|
||||||
@@ -37,7 +39,7 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
|
|||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageId? = null,
|
replyToMessageId: MessageId? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null
|
allowSendingWithoutReply: Boolean? = null
|
||||||
): Request<PossiblySentViaBotCommonMessage<MediaGroupContent<T>>> {
|
): Request<ContentMessage<MediaGroupContent<T>>> {
|
||||||
if (media.size !in mediaCountInMediaGroup) {
|
if (media.size !in mediaCountInMediaGroup) {
|
||||||
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
|
||||||
}
|
}
|
||||||
@@ -66,11 +68,11 @@ fun <T : MediaGroupPartContent> SendMediaGroup(
|
|||||||
return (if (files.isEmpty()) {
|
return (if (files.isEmpty()) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendMediaGroupFiles(files)
|
files.associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}) as Request<PossiblySentViaBotCommonMessage<MediaGroupContent<T>>>
|
}) as Request<ContentMessage<MediaGroupContent<T>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -33,7 +34,7 @@ fun SendPhoto(
|
|||||||
): Request<ContentMessage<PhotoContent>> {
|
): Request<ContentMessage<PhotoContent>> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId) ?.fileId,
|
photo,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -45,12 +46,14 @@ fun SendPhoto(
|
|||||||
allowSendingWithoutReply,
|
allowSendingWithoutReply,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
return data.photo ?.let {
|
return if (photo is MultipartFile) {
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
listOf(photo).associateBy { it.fileId }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
data
|
data
|
||||||
} ?: MultipartRequestImpl(
|
}
|
||||||
data,
|
|
||||||
SendPhotoFiles(photo as MultipartFile)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SendPhoto(
|
fun SendPhoto(
|
||||||
@@ -67,7 +70,7 @@ fun SendPhoto(
|
|||||||
): Request<ContentMessage<PhotoContent>> {
|
): Request<ContentMessage<PhotoContent>> {
|
||||||
val data = SendPhotoData(
|
val data = SendPhotoData(
|
||||||
chatId,
|
chatId,
|
||||||
(photo as? FileId)?.fileId,
|
photo,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -79,12 +82,15 @@ fun SendPhoto(
|
|||||||
allowSendingWithoutReply,
|
allowSendingWithoutReply,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
)
|
)
|
||||||
return data.photo ?.let {
|
|
||||||
|
return if (photo is MultipartFile) {
|
||||||
|
CommonMultipartFileRequest(
|
||||||
|
data,
|
||||||
|
listOf(photo).associateBy { it.fileId }
|
||||||
|
)
|
||||||
|
} else {
|
||||||
data
|
data
|
||||||
} ?: MultipartRequestImpl(
|
}
|
||||||
data,
|
|
||||||
SendPhotoFiles(photo as MultipartFile)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
private val commonResultDeserializer: DeserializationStrategy<ContentMessage<PhotoContent>>
|
||||||
@@ -95,7 +101,7 @@ data class SendPhotoData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(photoField)
|
@SerialName(photoField)
|
||||||
val photo: String? = null,
|
val photo: InputFile,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -28,7 +29,7 @@ fun SendSticker(
|
|||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
|
||||||
chatId,
|
chatId,
|
||||||
sticker as? FileId,
|
sticker,
|
||||||
threadId,
|
threadId,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
@@ -37,7 +38,10 @@ fun SendSticker(
|
|||||||
replyMarkup
|
replyMarkup
|
||||||
).let {
|
).let {
|
||||||
when (sticker) {
|
when (sticker) {
|
||||||
is MultipartFile -> SendStickerByFile(it, sticker, emoji)
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
|
it,
|
||||||
|
listOf(sticker).associateBy { it.fileId }
|
||||||
|
)
|
||||||
is FileId -> it
|
is FileId -> it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +54,7 @@ data class SendStickerByFileId internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(stickerField)
|
@SerialName(stickerField)
|
||||||
val sticker: FileId? = null,
|
val sticker: InputFile,
|
||||||
@SerialName(messageThreadIdField)
|
@SerialName(messageThreadIdField)
|
||||||
override val threadId: MessageThreadId? = chatId.threadId,
|
override val threadId: MessageThreadId? = chatId.threadId,
|
||||||
@SerialName(disableNotificationField)
|
@SerialName(disableNotificationField)
|
||||||
@@ -70,20 +74,3 @@ data class SendStickerByFileId internal constructor(
|
|||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
}
|
}
|
||||||
|
|
||||||
data class SendStickerByFile internal constructor(
|
|
||||||
@Transient
|
|
||||||
private val sendStickerByFileId: SendStickerByFileId,
|
|
||||||
val sticker: MultipartFile,
|
|
||||||
val emoji: String?
|
|
||||||
) : MultipartRequest<ContentMessage<StickerContent>>, Request<ContentMessage<StickerContent>> by sendStickerByFileId {
|
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
|
||||||
override val paramsJson: JsonObject
|
|
||||||
get() {
|
|
||||||
return JsonObject(
|
|
||||||
mapOfNotNull(
|
|
||||||
emojiField to emoji ?.let { JsonPrimitive(it) }
|
|
||||||
) + sendStickerByFileId.toJsonWithoutNulls(SendStickerByFileId.serializer())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -22,7 +23,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendVideo(
|
fun SendVideo(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
video: InputFile,
|
video: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
@@ -37,15 +38,13 @@ fun SendVideo(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoContent>> {
|
): Request<ContentMessage<VideoContent>> {
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
|
||||||
val videoAsFile = video as? MultipartFile
|
val videoAsFile = video as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoData(
|
val data = SendVideoData(
|
||||||
chatId,
|
chatId,
|
||||||
videoAsFileId,
|
video,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -65,9 +64,9 @@ fun SendVideo(
|
|||||||
return if (videoAsFile == null && thumbAsFile == null) {
|
return if (videoAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoFiles(videoAsFile, thumbAsFile)
|
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,7 +74,7 @@ fun SendVideo(
|
|||||||
fun SendVideo(
|
fun SendVideo(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
video: InputFile,
|
video: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
spoilered: Boolean = false,
|
spoilered: Boolean = false,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
@@ -89,15 +88,13 @@ fun SendVideo(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoContent>> {
|
): Request<ContentMessage<VideoContent>> {
|
||||||
val videoAsFileId = (video as? FileId) ?.fileId
|
|
||||||
val videoAsFile = video as? MultipartFile
|
val videoAsFile = video as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoData(
|
val data = SendVideoData(
|
||||||
chatId,
|
chatId,
|
||||||
videoAsFileId,
|
video,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -117,9 +114,9 @@ fun SendVideo(
|
|||||||
return if (videoAsFile == null && thumbAsFile == null) {
|
return if (videoAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoFiles(videoAsFile, thumbAsFile)
|
listOfNotNull(videoAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,7 +129,7 @@ data class SendVideoData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(videoField)
|
@SerialName(videoField)
|
||||||
val video: String? = null,
|
val video: InputFile,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -14,7 +15,7 @@ import kotlinx.serialization.*
|
|||||||
fun SendVideoNote(
|
fun SendVideoNote(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
videoNote: InputFile,
|
videoNote: InputFile,
|
||||||
thumb: InputFile? = null,
|
thumbnail: InputFile? = null,
|
||||||
duration: Long? = null,
|
duration: Long? = null,
|
||||||
size: Int? = null, // in documentation - length (size of video side)
|
size: Int? = null, // in documentation - length (size of video side)
|
||||||
threadId: MessageThreadId? = chatId.threadId,
|
threadId: MessageThreadId? = chatId.threadId,
|
||||||
@@ -24,15 +25,13 @@ fun SendVideoNote(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VideoNoteContent>> {
|
): Request<ContentMessage<VideoNoteContent>> {
|
||||||
val videoNoteAsFileId = (videoNote as? FileId) ?.fileId
|
|
||||||
val videoNoteAsFile = videoNote as? MultipartFile
|
val videoNoteAsFile = videoNote as? MultipartFile
|
||||||
val thumbAsFileId = (thumb as? FileId) ?.fileId
|
val thumbAsFile = thumbnail as? MultipartFile
|
||||||
val thumbAsFile = thumb as? MultipartFile
|
|
||||||
|
|
||||||
val data = SendVideoNoteData(
|
val data = SendVideoNoteData(
|
||||||
chatId,
|
chatId,
|
||||||
videoNoteAsFileId,
|
videoNote,
|
||||||
thumbAsFileId,
|
thumbnail ?.fileId,
|
||||||
duration,
|
duration,
|
||||||
size,
|
size,
|
||||||
threadId,
|
threadId,
|
||||||
@@ -46,9 +45,9 @@ fun SendVideoNote(
|
|||||||
return if (videoNoteAsFile == null && thumbAsFile == null) {
|
return if (videoNoteAsFile == null && thumbAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVideoNoteFiles(videoNoteAsFile, thumbAsFile)
|
listOfNotNull(videoNoteAsFile, thumbAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +60,7 @@ data class SendVideoNoteData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(videoNoteField)
|
@SerialName(videoNoteField)
|
||||||
val videoNote: String? = null,
|
val videoNote: InputFile,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: String? = null,
|
override val thumbnail: String? = null,
|
||||||
@SerialName(durationField)
|
@SerialName(durationField)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.requests.send.media
|
package dev.inmo.tgbotapi.requests.send.media
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
import dev.inmo.tgbotapi.requests.send.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.send.media.base.*
|
import dev.inmo.tgbotapi.requests.send.media.base.*
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
@@ -32,12 +33,11 @@ fun SendVoice(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VoiceContent>> {
|
): Request<ContentMessage<VoiceContent>> {
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
|
||||||
val voiceAsFile = voice as? MultipartFile
|
val voiceAsFile = voice as? MultipartFile
|
||||||
|
|
||||||
val data = SendVoiceData(
|
val data = SendVoiceData(
|
||||||
chatId,
|
chatId,
|
||||||
voiceAsFileId,
|
voice,
|
||||||
text,
|
text,
|
||||||
parseMode,
|
parseMode,
|
||||||
null,
|
null,
|
||||||
@@ -53,9 +53,9 @@ fun SendVoice(
|
|||||||
return if (voiceAsFile == null) {
|
return if (voiceAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVoiceFiles(voiceAsFile)
|
listOfNotNull(voiceAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,12 +72,11 @@ fun SendVoice(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
): Request<ContentMessage<VoiceContent>> {
|
): Request<ContentMessage<VoiceContent>> {
|
||||||
val voiceAsFileId = (voice as? FileId) ?.fileId
|
|
||||||
val voiceAsFile = voice as? MultipartFile
|
val voiceAsFile = voice as? MultipartFile
|
||||||
|
|
||||||
val data = SendVoiceData(
|
val data = SendVoiceData(
|
||||||
chatId,
|
chatId,
|
||||||
voiceAsFileId,
|
voice,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
entities.toRawMessageEntities(),
|
entities.toRawMessageEntities(),
|
||||||
@@ -93,9 +92,9 @@ fun SendVoice(
|
|||||||
return if (voiceAsFile == null) {
|
return if (voiceAsFile == null) {
|
||||||
data
|
data
|
||||||
} else {
|
} else {
|
||||||
MultipartRequestImpl(
|
CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
SendVoiceFiles(voiceAsFile)
|
listOfNotNull(voiceAsFile).associateBy { it.fileId }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,7 +107,7 @@ data class SendVoiceData internal constructor(
|
|||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
@SerialName(voiceField)
|
@SerialName(voiceField)
|
||||||
val voice: String? = null,
|
val voice: InputFile,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
override val text: String? = null,
|
override val text: String? = null,
|
||||||
@SerialName(parseModeField)
|
@SerialName(parseModeField)
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun AddAnimatedStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = AddAnimatedStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(tgsStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AddAnimatedStickerToSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(tgsStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "addStickerToSet"
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
fun AddStaticStickerToSet(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
|
||||||
val data = AddStaticStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
|
||||||
return when (sticker) {
|
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
|
||||||
data,
|
|
||||||
mapOf(pngStickerField to sticker)
|
|
||||||
)
|
|
||||||
is FileId -> data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class AddStaticStickerToSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(pngStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "addStickerToSet"
|
|
||||||
}
|
|
||||||
@@ -4,45 +4,32 @@ import dev.inmo.tgbotapi.requests.abstracts.*
|
|||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
fun AddVideoStickerToSet(
|
fun AddStickerToSet(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
stickerSetName: String,
|
stickerSetName: String,
|
||||||
sticker: InputFile,
|
inputSticker: InputSticker
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
): Request<Boolean> {
|
||||||
val data = AddVideoStickerToSet(userId, stickerSetName, emojis, sticker as? FileId, maskPosition)
|
val data = AddStickerToSetData(userId, stickerSetName, inputSticker)
|
||||||
return when (sticker) {
|
return when (val sticker = inputSticker.sticker) {
|
||||||
is MultipartFile -> CommonMultipartFileRequest(
|
is MultipartFile -> CommonMultipartFileRequest(
|
||||||
data,
|
data,
|
||||||
mapOf(webmStickerField to sticker)
|
mapOf(sticker.fileId to sticker)
|
||||||
)
|
)
|
||||||
is FileId -> data
|
is FileId -> data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class AddVideoStickerToSet internal constructor(
|
data class AddStickerToSetData internal constructor(
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
override val userId: UserId,
|
override val userId: UserId,
|
||||||
@SerialName(nameField)
|
@SerialName(nameField)
|
||||||
override val name: String,
|
override val name: String,
|
||||||
@SerialName(emojisField)
|
@SerialName(stickerField)
|
||||||
override val emojis: String,
|
override val inputSticker: InputSticker
|
||||||
@SerialName(webmStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : StandardStickerSetAction {
|
) : StandardStickerSetAction {
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
@Deprecated("Use CreateNewStickerSet class instead")
|
|
||||||
data class CreateNewAnimatedStickerSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(tgsStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(containsMasksField)
|
|
||||||
@Deprecated("Will be removed soon due to its redundancy")
|
|
||||||
val containsMasks: Boolean? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : CreateStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
@Deprecated("Use CreateNewStickerSet class instead")
|
|
||||||
data class CreateNewStaticStickerSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(pngStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(containsMasksField)
|
|
||||||
@Deprecated("Will be removed soon due to its redundancy")
|
|
||||||
val containsMasks: Boolean? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : CreateStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
|
||||||
}
|
|
||||||
@@ -1,77 +1,186 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
package dev.inmo.tgbotapi.requests.stickers
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
import kotlinx.serialization.descriptors.SerialDescriptor
|
||||||
|
import kotlinx.serialization.encoding.Decoder
|
||||||
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
internal fun CreateNewStickerSet(
|
/**
|
||||||
|
* Will create one of [CreateNewStickerSet] types based on the first element of [stickers]
|
||||||
|
*
|
||||||
|
* @param needsRepainting Will be used only if you are creating custom emojis sticker pack (by passing [stickers] with
|
||||||
|
* type [InputSticker.WithKeywords.CustomEmoji])
|
||||||
|
*/
|
||||||
|
fun CreateNewStickerSet(
|
||||||
userId: UserId,
|
userId: UserId,
|
||||||
name: String,
|
name: String,
|
||||||
title: String,
|
title: String,
|
||||||
emojis: String,
|
stickersFormat: StickerFormat,
|
||||||
stickerType: StickerType = StickerType.Regular,
|
stickers: List<InputSticker>,
|
||||||
pngSticker: InputFile? = null,
|
needsRepainting: Boolean? = null
|
||||||
tgsSticker: InputFile? = null,
|
|
||||||
webmSticker: InputFile? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> {
|
): Request<Boolean> {
|
||||||
val data = CreateNewStickerSet(
|
val data = when(stickers.first()) {
|
||||||
userId,
|
is InputSticker.Mask -> CreateNewStickerSet.Mask(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.Mask>())
|
||||||
name,
|
is InputSticker.WithKeywords.CustomEmoji -> CreateNewStickerSet.CustomEmoji(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(), needsRepainting)
|
||||||
title,
|
is InputSticker.WithKeywords.Regular -> CreateNewStickerSet.Regular(userId, name, title, stickersFormat, stickers.filterIsInstance<InputSticker.WithKeywords.Regular>())
|
||||||
emojis,
|
}
|
||||||
stickerType,
|
val multipartParts = stickers.mapNotNull {
|
||||||
pngSticker as? FileId,
|
(it.sticker as? MultipartFile)
|
||||||
tgsSticker as? FileId,
|
}
|
||||||
webmSticker as? FileId,
|
return if (multipartParts.isNotEmpty()) {
|
||||||
maskPosition
|
when (data) { // cratch for exact determining of common multipart data type
|
||||||
)
|
is CreateNewStickerSet.CustomEmoji -> CommonMultipartFileRequest(
|
||||||
return if (pngSticker is MultipartFile || tgsSticker is MultipartFile || webmSticker is MultipartFile) {
|
data,
|
||||||
CommonMultipartFileRequest(
|
multipartParts.associateBy { it.fileId }
|
||||||
data,
|
)
|
||||||
listOfNotNull(
|
is CreateNewStickerSet.Mask -> CommonMultipartFileRequest(
|
||||||
(pngSticker as? MultipartFile) ?.let { pngStickerField to it },
|
data,
|
||||||
(tgsSticker as? MultipartFile) ?.let { tgsStickerField to it },
|
multipartParts.associateBy { it.fileId }
|
||||||
(webmSticker as? MultipartFile) ?.let { webmStickerField to it },
|
)
|
||||||
).toMap()
|
is CreateNewStickerSet.Regular -> CommonMultipartFileRequest(
|
||||||
)
|
data,
|
||||||
|
multipartParts.associateBy { it.fileId }
|
||||||
|
)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable(CreateNewStickerSetSerializer::class)
|
||||||
data class CreateNewStickerSet internal constructor(
|
sealed interface CreateNewStickerSet : CreateStickerSetAction {
|
||||||
@SerialName(userIdField)
|
val stickerType: StickerType
|
||||||
override val userId: UserId,
|
val stickers: List<InputSticker>
|
||||||
@SerialName(nameField)
|
val stickersFormat: StickerFormat
|
||||||
override val name: String,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(stickerTypeField)
|
|
||||||
val stickerType: StickerType = StickerType.Regular,
|
|
||||||
@SerialName(pngStickerField)
|
|
||||||
val pngSticker: FileId? = null,
|
|
||||||
@SerialName(tgsStickerField)
|
|
||||||
val tgsSticker: FileId? = null,
|
|
||||||
@SerialName(webmStickerField)
|
|
||||||
val webmSticker: FileId? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : CreateStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
get() = serializer()
|
get() = serializer()
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
override fun method(): String = "createNewStickerSet"
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Regular(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(titleField)
|
||||||
|
override val title: String,
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
override val stickersFormat: StickerFormat,
|
||||||
|
@SerialName(stickersField)
|
||||||
|
override val stickers: List<InputSticker.WithKeywords.Regular>
|
||||||
|
) : CreateNewStickerSet {
|
||||||
|
@SerialName(stickerTypeField)
|
||||||
|
override val stickerType: StickerType
|
||||||
|
get() = StickerType.Regular
|
||||||
|
}
|
||||||
|
@Serializable
|
||||||
|
data class Mask(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(titleField)
|
||||||
|
override val title: String,
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
override val stickersFormat: StickerFormat,
|
||||||
|
@SerialName(stickersField)
|
||||||
|
override val stickers: List<InputSticker.Mask>
|
||||||
|
) : CreateNewStickerSet {
|
||||||
|
@SerialName(stickerTypeField)
|
||||||
|
override val stickerType: StickerType
|
||||||
|
get() = StickerType.Mask
|
||||||
|
}
|
||||||
|
@Serializable
|
||||||
|
data class CustomEmoji(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(titleField)
|
||||||
|
override val title: String,
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
override val stickersFormat: StickerFormat,
|
||||||
|
@SerialName(stickersField)
|
||||||
|
override val stickers: List<InputSticker.WithKeywords.CustomEmoji>,
|
||||||
|
@SerialName(needsRepaintingField)
|
||||||
|
val needsRepainting: Boolean? = null
|
||||||
|
) : CreateNewStickerSet {
|
||||||
|
@SerialName(stickerTypeField)
|
||||||
|
override val stickerType: StickerType
|
||||||
|
get() = StickerType.CustomEmoji
|
||||||
|
}
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SurrogateCreateNewSticker internal constructor(
|
||||||
|
@SerialName(userIdField)
|
||||||
|
override val userId: UserId,
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: String,
|
||||||
|
@SerialName(titleField)
|
||||||
|
override val title: String,
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
val stickersFormat: StickerFormat,
|
||||||
|
@SerialName(stickersField)
|
||||||
|
val stickers: List<InputSticker>,
|
||||||
|
@SerialName(stickerTypeField)
|
||||||
|
val stickerType: StickerType,
|
||||||
|
@SerialName(needsRepaintingField)
|
||||||
|
val needsRepainting: Boolean? = null
|
||||||
|
) : CreateStickerSetAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = CreateNewStickerSet.serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "createNewStickerSet"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object CreateNewStickerSetSerializer : KSerializer<CreateNewStickerSet>,
|
||||||
|
MapperSerializer<CreateNewStickerSet.SurrogateCreateNewSticker, CreateNewStickerSet>(
|
||||||
|
CreateNewStickerSet.SurrogateCreateNewSticker.serializer(),
|
||||||
|
{
|
||||||
|
CreateNewStickerSet.SurrogateCreateNewSticker(
|
||||||
|
it.userId,
|
||||||
|
it.name,
|
||||||
|
it.title,
|
||||||
|
it.stickersFormat,
|
||||||
|
it.stickers,
|
||||||
|
it.stickerType,
|
||||||
|
(it as? CreateNewStickerSet.CustomEmoji)?.needsRepainting
|
||||||
|
)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
when (it.stickerType) {
|
||||||
|
StickerType.CustomEmoji -> CreateNewStickerSet.CustomEmoji(
|
||||||
|
it.userId,
|
||||||
|
it.name,
|
||||||
|
it.title,
|
||||||
|
it.stickersFormat,
|
||||||
|
it.stickers.filterIsInstance<InputSticker.WithKeywords.CustomEmoji>(),
|
||||||
|
it.needsRepainting
|
||||||
|
)
|
||||||
|
StickerType.Mask -> CreateNewStickerSet.Mask(
|
||||||
|
it.userId,
|
||||||
|
it.name,
|
||||||
|
it.title,
|
||||||
|
it.stickersFormat,
|
||||||
|
it.stickers.filterIsInstance<InputSticker.Mask>(),
|
||||||
|
)
|
||||||
|
StickerType.Regular -> CreateNewStickerSet.Regular(
|
||||||
|
it.userId,
|
||||||
|
it.name,
|
||||||
|
it.title,
|
||||||
|
it.stickersFormat,
|
||||||
|
it.stickers.filterIsInstance<InputSticker.WithKeywords.Regular>(),
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> error("Unable to create new sticker set due to error in type format: ${it.stickerType}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.*
|
|
||||||
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.CreateStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.requests.stickers.abstracts.StandardStickerSetAction
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
import kotlinx.serialization.*
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
@Deprecated("Use CreateNewStickerSet class instead")
|
|
||||||
data class CreateNewVideoStickerSet internal constructor(
|
|
||||||
@SerialName(userIdField)
|
|
||||||
override val userId: UserId,
|
|
||||||
@SerialName(nameField)
|
|
||||||
override val name: String,
|
|
||||||
@SerialName(titleField)
|
|
||||||
override val title: String,
|
|
||||||
@SerialName(emojisField)
|
|
||||||
override val emojis: String,
|
|
||||||
@SerialName(webmStickerField)
|
|
||||||
val sticker: FileId? = null,
|
|
||||||
@SerialName(containsMasksField)
|
|
||||||
@Deprecated("Will be removed soon due to its redundancy")
|
|
||||||
val containsMasks: Boolean? = null,
|
|
||||||
@SerialName(maskPositionField)
|
|
||||||
override val maskPosition: MaskPosition? = null
|
|
||||||
) : CreateStickerSetAction {
|
|
||||||
init {
|
|
||||||
if(emojis.isEmpty()) {
|
|
||||||
throw IllegalArgumentException("Emojis must not be empty")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override val requestSerializer: SerializationStrategy<*>
|
|
||||||
get() = serializer()
|
|
||||||
|
|
||||||
override fun method(): String = "createNewStickerSet"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.stickers
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
|
import dev.inmo.tgbotapi.types.StickerType
|
||||||
|
import dev.inmo.tgbotapi.types.emojiListField
|
||||||
|
import dev.inmo.tgbotapi.types.keywordsField
|
||||||
|
import dev.inmo.tgbotapi.types.maskPositionField
|
||||||
|
import dev.inmo.tgbotapi.types.stickerField
|
||||||
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
|
import kotlinx.serialization.KSerializer
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@ClassCastsIncluded
|
||||||
|
@Serializable(InputStickerSerializer::class)
|
||||||
|
sealed interface InputSticker {
|
||||||
|
val sticker: InputFile
|
||||||
|
val emojisList: List<String>
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Mask(
|
||||||
|
@SerialName(stickerField)
|
||||||
|
override val sticker: InputFile,
|
||||||
|
@SerialName(emojiListField)
|
||||||
|
override val emojisList: List<String>,
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
val maskPosition: MaskPosition? = null
|
||||||
|
) : InputSticker
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
sealed interface WithKeywords : InputSticker {
|
||||||
|
val keywords: List<String>
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class Regular(
|
||||||
|
@SerialName(stickerField)
|
||||||
|
override val sticker: InputFile,
|
||||||
|
@SerialName(emojiListField)
|
||||||
|
override val emojisList: List<String>,
|
||||||
|
@SerialName(keywordsField)
|
||||||
|
override val keywords: List<String>
|
||||||
|
) : WithKeywords
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class CustomEmoji(
|
||||||
|
@SerialName(stickerField)
|
||||||
|
override val sticker: InputFile,
|
||||||
|
@SerialName(emojiListField)
|
||||||
|
override val emojisList: List<String>,
|
||||||
|
@SerialName(keywordsField)
|
||||||
|
override val keywords: List<String>
|
||||||
|
) : WithKeywords
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object InputStickerSerializer : KSerializer<InputSticker>, MapperSerializer<InputStickerSerializer.SurrogateInputSticker, InputSticker>(
|
||||||
|
SurrogateInputSticker.serializer(),
|
||||||
|
{
|
||||||
|
when (it) {
|
||||||
|
is InputSticker.Mask -> SurrogateInputSticker(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
emptyList(),
|
||||||
|
it.maskPosition,
|
||||||
|
StickerType.Mask
|
||||||
|
)
|
||||||
|
is InputSticker.WithKeywords.CustomEmoji -> SurrogateInputSticker(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.keywords,
|
||||||
|
null,
|
||||||
|
StickerType.CustomEmoji
|
||||||
|
)
|
||||||
|
is InputSticker.WithKeywords.Regular -> SurrogateInputSticker(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.keywords,
|
||||||
|
null,
|
||||||
|
StickerType.Regular
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
when (it.internalType) {
|
||||||
|
StickerType.CustomEmoji -> InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.keywords
|
||||||
|
)
|
||||||
|
StickerType.Mask -> InputSticker.Mask(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.maskPosition
|
||||||
|
)
|
||||||
|
StickerType.Regular -> InputSticker.WithKeywords.Regular(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.keywords
|
||||||
|
)
|
||||||
|
is StickerType.Unknown -> InputSticker.WithKeywords.Regular(
|
||||||
|
it.sticker,
|
||||||
|
it.emojisList,
|
||||||
|
it.keywords
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
@Serializable
|
||||||
|
data class SurrogateInputSticker internal constructor(
|
||||||
|
@SerialName(stickerField)
|
||||||
|
val sticker: InputFile,
|
||||||
|
@SerialName(emojiListField)
|
||||||
|
val emojisList: List<String>,
|
||||||
|
@SerialName(keywordsField)
|
||||||
|
val keywords: List<String> = emptyList(),
|
||||||
|
@SerialName(maskPositionField)
|
||||||
|
val maskPosition: MaskPosition? = null,
|
||||||
|
internal val internalType: StickerType = StickerType.Unknown()
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.StickerType
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
|
|
||||||
fun CreateNewRegularStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Regular,
|
|
||||||
pngSticker = sticker
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewRegularVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Regular,
|
|
||||||
webmSticker = sticker
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewRegularAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Regular,
|
|
||||||
tgsSticker = sticker
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
fun CreateNewMaskStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Mask,
|
|
||||||
pngSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewMaskVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Mask,
|
|
||||||
webmSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewMaskAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
maskPosition: MaskPosition
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
StickerType.Mask,
|
|
||||||
tgsSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
@@ -1,80 +0,0 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers
|
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
|
||||||
import dev.inmo.tgbotapi.types.StickerType
|
|
||||||
import dev.inmo.tgbotapi.types.UserId
|
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
|
||||||
|
|
||||||
|
|
||||||
fun CreateNewVideoStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
linkName: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
linkName,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
|
|
||||||
webmSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewStaticStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
|
|
||||||
pngSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
|
|
||||||
pngSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
|
|
||||||
fun CreateNewAnimatedStickerSet(
|
|
||||||
userId: UserId,
|
|
||||||
name: String,
|
|
||||||
title: String,
|
|
||||||
sticker: InputFile,
|
|
||||||
emojis: String,
|
|
||||||
containsMasks: Boolean? = null,
|
|
||||||
maskPosition: MaskPosition? = null
|
|
||||||
): Request<Boolean> = CreateNewStickerSet(
|
|
||||||
userId,
|
|
||||||
name,
|
|
||||||
title,
|
|
||||||
emojis,
|
|
||||||
if (containsMasks == true) StickerType.Mask else StickerType.Regular,
|
|
||||||
tgsSticker = sticker,
|
|
||||||
maskPosition = maskPosition
|
|
||||||
)
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package dev.inmo.tgbotapi.requests.stickers
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.requests.common.CommonMultipartFileRequest
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.OwnerStickerSetAction
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.abstracts.StickerSetAction
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class SetCustomEmojiStickerSetThumbnail (
|
||||||
|
@SerialName(nameField)
|
||||||
|
override val name: StickerSetName,
|
||||||
|
@SerialName(customEmojiIdField)
|
||||||
|
val customEmojiId: CustomEmojiId
|
||||||
|
) : StickerSetAction {
|
||||||
|
override val requestSerializer: SerializationStrategy<*>
|
||||||
|
get() = serializer()
|
||||||
|
|
||||||
|
override fun method(): String = "setCustomEmojiStickerSetThumbnail"
|
||||||
|
}
|
||||||
@@ -17,13 +17,6 @@ fun SetStickerSetThumbnail(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, stickerSetName, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail"))
|
|
||||||
fun SetStickerSetThumb(
|
|
||||||
userId: UserId,
|
|
||||||
stickerSetName: String,
|
|
||||||
thumbnail: MultipartFile
|
|
||||||
): Request<Boolean> = SetStickerSetThumbnail(userId, stickerSetName, thumbnail)
|
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class SetStickerSetThumbnail (
|
data class SetStickerSetThumbnail (
|
||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
@@ -38,10 +31,3 @@ data class SetStickerSetThumbnail (
|
|||||||
|
|
||||||
override fun method(): String = "setStickerSetThumbnail"
|
override fun method(): String = "setStickerSetThumbnail"
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("SetStickerSetThumbnail(userId, name, thumbnail)", "dev.inmo.tgbotapi.requests.stickers.SetStickerSetThumbnail"))
|
|
||||||
fun SetStickerSetThumb(
|
|
||||||
userId: UserId,
|
|
||||||
name: StickerSetName,
|
|
||||||
thumbnail: FileId? = null
|
|
||||||
) = SetStickerSetThumbnail(userId, name, thumbnail)
|
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ data class UploadStickerFile(
|
|||||||
@SerialName(userIdField)
|
@SerialName(userIdField)
|
||||||
val userId: UserId,
|
val userId: UserId,
|
||||||
@Transient
|
@Transient
|
||||||
val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized")
|
val sticker: MultipartFile = throw IllegalStateException("Detected autocreating try: this class can't be deserialized"),
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
val stickerFormat: StickerFormat
|
||||||
): MultipartRequest<File> {
|
): MultipartRequest<File> {
|
||||||
init {
|
init {
|
||||||
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
// TODO:: add check of width/height of image and type of file - it must be png with max side length is 512px
|
||||||
@@ -21,7 +23,7 @@ data class UploadStickerFile(
|
|||||||
|
|
||||||
override fun method(): String = "uploadStickerFile"
|
override fun method(): String = "uploadStickerFile"
|
||||||
@Transient
|
@Transient
|
||||||
override val mediaMap: Map<String, MultipartFile> = mapOf(pngStickerField to sticker)
|
override val mediaMap: Map<String, MultipartFile> = mapOf(stickerField to sticker)
|
||||||
@Transient
|
@Transient
|
||||||
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
override val paramsJson: JsonObject = toJsonWithoutNulls(serializer())
|
||||||
override val resultDeserializer: DeserializationStrategy<File>
|
override val resultDeserializer: DeserializationStrategy<File>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers.abstracts
|
package dev.inmo.tgbotapi.requests.stickers.abstracts
|
||||||
|
|
||||||
interface CreateStickerSetAction : StandardStickerSetAction {
|
interface CreateStickerSetAction : OwnerStickerSetAction {
|
||||||
val title: String
|
val title: String
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.requests.stickers.abstracts
|
package dev.inmo.tgbotapi.requests.stickers.abstracts
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
|
|
||||||
interface StandardStickerSetAction : OwnerStickerSetAction {
|
interface StandardStickerSetAction : OwnerStickerSetAction {
|
||||||
val emojis: String // must be more than one
|
val inputSticker: InputSticker
|
||||||
val maskPosition: MaskPosition?
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,6 +83,38 @@ sealed interface StickerType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Serializable(StickerFormat.Serializer::class)
|
||||||
|
sealed interface StickerFormat {
|
||||||
|
val type: String
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
object Static : StickerFormat { override val type: String = "static" }
|
||||||
|
@Serializable
|
||||||
|
object Animated : StickerFormat { override val type: String = "animated" }
|
||||||
|
@Serializable
|
||||||
|
object Video : StickerFormat { override val type: String = "video" }
|
||||||
|
@Serializable
|
||||||
|
data class Unknown(override val type: String = "custom_emoji") : StickerFormat
|
||||||
|
|
||||||
|
object Serializer : KSerializer<StickerFormat> {
|
||||||
|
override val descriptor: SerialDescriptor = String.serializer().descriptor
|
||||||
|
|
||||||
|
override fun deserialize(decoder: Decoder): StickerFormat {
|
||||||
|
return when (val type = decoder.decodeString()) {
|
||||||
|
Static.type -> Static
|
||||||
|
Animated.type -> Animated
|
||||||
|
Video.type -> Video
|
||||||
|
else -> Unknown(type)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(encoder: Encoder, value: StickerFormat) {
|
||||||
|
encoder.encodeString(value.type)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val usernameRegex = Regex("@[\\w\\d_]+")
|
val usernameRegex = Regex("@[\\w\\d_]+")
|
||||||
|
|
||||||
val degreesLimit = 1 .. 360
|
val degreesLimit = 1 .. 360
|
||||||
@@ -388,6 +420,8 @@ const val webmStickerField = "webm_sticker"
|
|||||||
const val oldChatMemberField = "old_chat_member"
|
const val oldChatMemberField = "old_chat_member"
|
||||||
const val newChatMemberField = "new_chat_member"
|
const val newChatMemberField = "new_chat_member"
|
||||||
const val stickerTypeField = "sticker_type"
|
const val stickerTypeField = "sticker_type"
|
||||||
|
const val stickerFormatField = "sticker_format"
|
||||||
|
const val needsRepaintingField = "needs_repainting"
|
||||||
|
|
||||||
const val okField = "ok"
|
const val okField = "ok"
|
||||||
const val captionField = "caption"
|
const val captionField = "caption"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.chat.member
|
package dev.inmo.tgbotapi.types.chat.member
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.WithChat
|
||||||
|
import dev.inmo.tgbotapi.abstracts.WithUser
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
@@ -9,9 +11,9 @@ import kotlinx.serialization.Serializable
|
|||||||
@Serializable
|
@Serializable
|
||||||
data class ChatMemberUpdated(
|
data class ChatMemberUpdated(
|
||||||
@SerialName(chatField)
|
@SerialName(chatField)
|
||||||
val chat: Chat,
|
override val chat: Chat,
|
||||||
@SerialName(fromField)
|
@SerialName(fromField)
|
||||||
val user: User,
|
override val user: User,
|
||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
val date: TelegramDate,
|
val date: TelegramDate,
|
||||||
@SerialName(oldChatMemberField)
|
@SerialName(oldChatMemberField)
|
||||||
@@ -20,4 +22,4 @@ data class ChatMemberUpdated(
|
|||||||
val newChatMemberState: ChatMember,
|
val newChatMemberState: ChatMember,
|
||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
val inviteLink: ChatInviteLink? = null
|
val inviteLink: ChatInviteLink? = null
|
||||||
)
|
) : WithChat, WithUser
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.files
|
package dev.inmo.tgbotapi.types.files
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
import dev.inmo.tgbotapi.types.stickers.MaskPosition
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
@@ -27,7 +28,8 @@ data class StickerSurrogate(
|
|||||||
val premium_animation: File? = null,
|
val premium_animation: File? = null,
|
||||||
val mask_position: MaskPosition? = null,
|
val mask_position: MaskPosition? = null,
|
||||||
val custom_emoji_id: CustomEmojiId? = null,
|
val custom_emoji_id: CustomEmojiId? = null,
|
||||||
val file_size: Long? = null
|
val file_size: Long? = null,
|
||||||
|
val needs_repainting: Boolean = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO:: Serializer
|
// TODO:: Serializer
|
||||||
@@ -35,11 +37,14 @@ data class StickerSurrogate(
|
|||||||
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
sealed interface Sticker : TelegramMediaFile, SizedMediaFile, ThumbedMediaFile {
|
||||||
val emoji: String?
|
val emoji: String?
|
||||||
val stickerSetName: StickerSetName?
|
val stickerSetName: StickerSetName?
|
||||||
|
val stickerFormat: StickerFormat
|
||||||
|
|
||||||
val isAnimated
|
val isAnimated
|
||||||
get() = false
|
get() = false
|
||||||
val isVideo
|
val isVideo
|
||||||
get() = false
|
get() = false
|
||||||
|
|
||||||
|
fun asInputSticker(emojis: List<String> = emoji ?.let { listOf(it) } ?: error("Unable to create input sticker without emojis")): InputSticker
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(RiskFeature::class)
|
@OptIn(RiskFeature::class)
|
||||||
@@ -92,7 +97,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.mask_position,
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
@@ -103,7 +108,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.mask_position,
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
@@ -114,7 +119,7 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.mask_position ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.mask_position,
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
@@ -127,33 +132,36 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
surrogate.file_size
|
surrogate.file_size,
|
||||||
|
surrogate.needs_repainting
|
||||||
)
|
)
|
||||||
surrogate.is_video == true -> CustomEmojiVideoSticker(
|
surrogate.is_video == true -> CustomEmojiVideoSticker(
|
||||||
surrogate.file_id,
|
surrogate.file_id,
|
||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
surrogate.file_size
|
surrogate.file_size,
|
||||||
|
surrogate.needs_repainting
|
||||||
)
|
)
|
||||||
else -> CustomEmojiSimpleSticker(
|
else -> CustomEmojiSimpleSticker(
|
||||||
surrogate.file_id,
|
surrogate.file_id,
|
||||||
surrogate.file_unique_id,
|
surrogate.file_unique_id,
|
||||||
surrogate.width,
|
surrogate.width,
|
||||||
surrogate.height,
|
surrogate.height,
|
||||||
surrogate.custom_emoji_id ?: error("For mask stickers field mask_position should be presented"),
|
surrogate.custom_emoji_id ?: error("For custom emoji stickers field custom_emoji_id should be presented"),
|
||||||
surrogate.thumb,
|
surrogate.thumb,
|
||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
surrogate.file_size
|
surrogate.file_size,
|
||||||
|
surrogate.needs_repainting
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is StickerType.Unknown -> UnknownSticker(
|
is StickerType.Unknown -> UnknownSticker(
|
||||||
@@ -165,6 +173,11 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
surrogate.emoji,
|
surrogate.emoji,
|
||||||
surrogate.set_name,
|
surrogate.set_name,
|
||||||
surrogate.file_size,
|
surrogate.file_size,
|
||||||
|
when {
|
||||||
|
surrogate.is_animated == true -> StickerFormat.Animated
|
||||||
|
surrogate.is_video == true -> StickerFormat.Video
|
||||||
|
else -> StickerFormat.Static
|
||||||
|
},
|
||||||
json
|
json
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -180,16 +193,28 @@ object StickerSerializer : KSerializer<Sticker> {
|
|||||||
sealed interface VideoSticker : Sticker {
|
sealed interface VideoSticker : Sticker {
|
||||||
override val isVideo: Boolean
|
override val isVideo: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
|
override val stickerFormat: StickerFormat
|
||||||
|
get() = StickerFormat.Video
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface AnimatedSticker : Sticker {
|
sealed interface AnimatedSticker : Sticker {
|
||||||
override val isAnimated: Boolean
|
override val isAnimated: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
|
override val stickerFormat: StickerFormat
|
||||||
|
get() = StickerFormat.Animated
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface RegularSticker : Sticker {
|
sealed interface RegularSticker : Sticker {
|
||||||
val premiumAnimationFile: File?
|
val premiumAnimationFile: File?
|
||||||
|
|
||||||
|
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.Regular(
|
||||||
|
fileId,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -209,12 +234,15 @@ data class RegularSimpleSticker(
|
|||||||
@SerialName(stickerSetNameField)
|
@SerialName(stickerSetNameField)
|
||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(premiumAnimationField)
|
@SerialName(premiumAnimationField)
|
||||||
override val premiumAnimationFile: File?,
|
override val premiumAnimationFile: File? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
) : RegularSticker
|
) : RegularSticker {
|
||||||
@Deprecated("Renamed", ReplaceWith("SimpleRegularSticker", "dev.inmo.tgbotapi.types.files.SimpleRegularSticker"))
|
@SerialName(stickerFormatField)
|
||||||
typealias SimpleSticker = RegularSimpleSticker
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class RegularAnimatedSticker(
|
data class RegularAnimatedSticker(
|
||||||
@SerialName(fileIdField)
|
@SerialName(fileIdField)
|
||||||
@@ -232,7 +260,7 @@ data class RegularAnimatedSticker(
|
|||||||
@SerialName(stickerSetNameField)
|
@SerialName(stickerSetNameField)
|
||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(premiumAnimationField)
|
@SerialName(premiumAnimationField)
|
||||||
override val premiumAnimationFile: File?,
|
override val premiumAnimationFile: File? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
) : RegularSticker, AnimatedSticker
|
) : RegularSticker, AnimatedSticker
|
||||||
@@ -253,7 +281,7 @@ data class RegularVideoSticker(
|
|||||||
@SerialName(stickerSetNameField)
|
@SerialName(stickerSetNameField)
|
||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(premiumAnimationField)
|
@SerialName(premiumAnimationField)
|
||||||
override val premiumAnimationFile: File?,
|
override val premiumAnimationFile: File? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
) : RegularSticker, VideoSticker
|
) : RegularSticker, VideoSticker
|
||||||
@@ -261,7 +289,13 @@ data class RegularVideoSticker(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface MaskSticker : Sticker {
|
sealed interface MaskSticker : Sticker {
|
||||||
val maskPosition: MaskPosition
|
val maskPosition: MaskPosition?
|
||||||
|
|
||||||
|
override fun asInputSticker(emojis: List<String>) = InputSticker.Mask(
|
||||||
|
fileId,
|
||||||
|
emojis,
|
||||||
|
maskPosition
|
||||||
|
)
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MaskSimpleSticker(
|
data class MaskSimpleSticker(
|
||||||
@@ -274,7 +308,7 @@ data class MaskSimpleSticker(
|
|||||||
@SerialName(heightField)
|
@SerialName(heightField)
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition,
|
override val maskPosition: MaskPosition? = null,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null,
|
override val thumbnail: PhotoSize? = null,
|
||||||
@SerialName(emojiField)
|
@SerialName(emojiField)
|
||||||
@@ -283,7 +317,11 @@ data class MaskSimpleSticker(
|
|||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
) : MaskSticker
|
) : MaskSticker {
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
data class MaskAnimatedSticker(
|
data class MaskAnimatedSticker(
|
||||||
@SerialName(fileIdField)
|
@SerialName(fileIdField)
|
||||||
@@ -295,7 +333,7 @@ data class MaskAnimatedSticker(
|
|||||||
@SerialName(heightField)
|
@SerialName(heightField)
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition,
|
override val maskPosition: MaskPosition? = null,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null,
|
override val thumbnail: PhotoSize? = null,
|
||||||
@SerialName(emojiField)
|
@SerialName(emojiField)
|
||||||
@@ -316,7 +354,7 @@ data class MaskVideoSticker(
|
|||||||
@SerialName(heightField)
|
@SerialName(heightField)
|
||||||
override val height: Int,
|
override val height: Int,
|
||||||
@SerialName(maskPositionField)
|
@SerialName(maskPositionField)
|
||||||
override val maskPosition: MaskPosition,
|
override val maskPosition: MaskPosition? = null,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumbnail: PhotoSize? = null,
|
override val thumbnail: PhotoSize? = null,
|
||||||
@SerialName(emojiField)
|
@SerialName(emojiField)
|
||||||
@@ -330,6 +368,13 @@ data class MaskVideoSticker(
|
|||||||
@Serializable
|
@Serializable
|
||||||
sealed interface CustomEmojiSticker : Sticker {
|
sealed interface CustomEmojiSticker : Sticker {
|
||||||
val customEmojiId: CustomEmojiId
|
val customEmojiId: CustomEmojiId
|
||||||
|
val needsRepainting: Boolean
|
||||||
|
|
||||||
|
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.CustomEmoji(
|
||||||
|
fileId,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -352,7 +397,13 @@ data class CustomEmojiSimpleSticker(
|
|||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
) : CustomEmojiSticker
|
@SerialName(needsRepaintingField)
|
||||||
|
override val needsRepainting: Boolean = false
|
||||||
|
) : CustomEmojiSticker {
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CustomEmojiAnimatedSticker(
|
data class CustomEmojiAnimatedSticker(
|
||||||
@SerialName(fileIdField)
|
@SerialName(fileIdField)
|
||||||
@@ -373,6 +424,8 @@ data class CustomEmojiAnimatedSticker(
|
|||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
|
@SerialName(needsRepaintingField)
|
||||||
|
override val needsRepainting: Boolean = false,
|
||||||
) : CustomEmojiSticker, AnimatedSticker
|
) : CustomEmojiSticker, AnimatedSticker
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CustomEmojiVideoSticker(
|
data class CustomEmojiVideoSticker(
|
||||||
@@ -394,6 +447,8 @@ data class CustomEmojiVideoSticker(
|
|||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
|
@SerialName(needsRepaintingField)
|
||||||
|
override val needsRepainting: Boolean = false,
|
||||||
) : CustomEmojiSticker, VideoSticker
|
) : CustomEmojiSticker, VideoSticker
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -414,5 +469,13 @@ data class UnknownSticker(
|
|||||||
override val stickerSetName: StickerSetName? = null,
|
override val stickerSetName: StickerSetName? = null,
|
||||||
@SerialName(fileSizeField)
|
@SerialName(fileSizeField)
|
||||||
override val fileSize: Long? = null,
|
override val fileSize: Long? = null,
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static,
|
||||||
val raw: JsonElement
|
val raw: JsonElement
|
||||||
) : Sticker
|
) : Sticker {
|
||||||
|
override fun asInputSticker(emojis: List<String>) = InputSticker.WithKeywords.Regular(
|
||||||
|
fileId,
|
||||||
|
emojis,
|
||||||
|
emptyList()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,3 @@ import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.PublicChatEvent
|
|||||||
data class LeftChatMemberEvent(
|
data class LeftChatMemberEvent(
|
||||||
override val user: User
|
override val user: User
|
||||||
) : PublicChatEvent, WithUser
|
) : PublicChatEvent, WithUser
|
||||||
|
|
||||||
@Deprecated("Renamed", ReplaceWith("dev.inmo.tgbotapi.types.message.ChatEvents", "LeftChatMemberEvent"))
|
|
||||||
typealias LeftChatMember = LeftChatMemberEvent
|
|
||||||
|
|||||||
@@ -57,18 +57,3 @@ sealed interface ForwardInfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByAnonymous", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
|
||||||
typealias AnonymousForwardInfo = ForwardInfo.ByAnonymous
|
|
||||||
|
|
||||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.ByUser", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
|
||||||
typealias UserForwardInfo = ForwardInfo.ByUser
|
|
||||||
|
|
||||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
|
||||||
typealias ForwardFromPublicChatInfo = ForwardInfo.PublicChat
|
|
||||||
|
|
||||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromChannel", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
|
||||||
typealias ForwardFromChannelInfo = ForwardInfo.PublicChat.FromChannel
|
|
||||||
|
|
||||||
@Deprecated("Replaced", ReplaceWith("ForwardInfo.PublicChat.FromSupergroup", "dev.inmo.tgbotapi.types.message.ForwardInfo"))
|
|
||||||
typealias ForwardFromSupergroupInfo = ForwardInfo.PublicChat.FromSupergroup
|
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ internal data class RawMessage(
|
|||||||
private val chatEvent: ChatEvent? by lazy {
|
private val chatEvent: ChatEvent? by lazy {
|
||||||
when {
|
when {
|
||||||
new_chat_members != null -> NewChatMembers(new_chat_members.toList())
|
new_chat_members != null -> NewChatMembers(new_chat_members.toList())
|
||||||
left_chat_member != null -> LeftChatMember(left_chat_member)
|
left_chat_member != null -> LeftChatMemberEvent(left_chat_member)
|
||||||
new_chat_title != null -> NewChatTitle(new_chat_title)
|
new_chat_title != null -> NewChatTitle(new_chat_title)
|
||||||
new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList())
|
new_chat_photo != null -> NewChatPhoto(new_chat_photo.toList())
|
||||||
video_chat_started != null -> video_chat_started
|
video_chat_started != null -> video_chat_started
|
||||||
@@ -242,12 +242,15 @@ internal data class RawMessage(
|
|||||||
group_chat_created -> GroupChatCreated(
|
group_chat_created -> GroupChatCreated(
|
||||||
migrate_to_chat_id
|
migrate_to_chat_id
|
||||||
)
|
)
|
||||||
|
|
||||||
supergroup_chat_created -> SupergroupChatCreated(
|
supergroup_chat_created -> SupergroupChatCreated(
|
||||||
migrate_from_chat_id
|
migrate_from_chat_id
|
||||||
)
|
)
|
||||||
|
|
||||||
migrate_from_chat_id != null -> MigratedToSupergroup(
|
migrate_from_chat_id != null -> MigratedToSupergroup(
|
||||||
migrate_from_chat_id
|
migrate_from_chat_id
|
||||||
)
|
)
|
||||||
|
|
||||||
channel_chat_created -> ChannelChatCreated()
|
channel_chat_created -> ChannelChatCreated()
|
||||||
pinned_message != null -> PinnedMessage(pinned_message.asMessage)
|
pinned_message != null -> PinnedMessage(pinned_message.asMessage)
|
||||||
proximity_alert_triggered != null -> proximity_alert_triggered
|
proximity_alert_triggered != null -> proximity_alert_triggered
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.types.message.abstracts
|
package dev.inmo.tgbotapi.types.message.abstracts
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.tgbotapi.abstracts.WithChat
|
||||||
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
|
||||||
import dev.inmo.tgbotapi.types.MessageId
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
@@ -11,9 +12,8 @@ import kotlinx.serialization.encoding.Decoder
|
|||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
@ClassCastsIncluded
|
@ClassCastsIncluded
|
||||||
interface Message {
|
interface Message : WithChat {
|
||||||
val messageId: MessageId
|
val messageId: MessageId
|
||||||
val chat: Chat
|
|
||||||
val date: DateTime
|
val date: DateTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,18 @@ sealed interface MediaCollectionContent<T: TelegramMediaFile>: MessageContent, M
|
|||||||
sealed interface MediaContent: MessageContent {
|
sealed interface MediaContent: MessageContent {
|
||||||
val media: TelegramMediaFile
|
val media: TelegramMediaFile
|
||||||
fun asTelegramMedia(): TelegramMedia
|
fun asTelegramMedia(): TelegramMedia
|
||||||
|
|
||||||
|
override fun createResend(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageThreadId: MessageThreadId?,
|
||||||
|
disableNotification: Boolean,
|
||||||
|
protectContent: Boolean,
|
||||||
|
replyToMessageId: MessageId?,
|
||||||
|
allowSendingWithoutReply: Boolean?,
|
||||||
|
replyMarkup: KeyboardMarkup?
|
||||||
|
): Request<out ContentMessage<MediaContent>> {
|
||||||
|
TODO("Not yet implemented")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData
|
sealed interface SpoilerableMediaContent : MediaContent, SpoilerableData
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import dev.inmo.tgbotapi.types.MessageThreadId
|
|||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
import dev.inmo.tgbotapi.types.media.TelegramMedia
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
@@ -38,7 +39,7 @@ data class MediaGroupContent<T : MediaGroupPartContent>(
|
|||||||
replyToMessageId: MessageId?,
|
replyToMessageId: MessageId?,
|
||||||
allowSendingWithoutReply: Boolean?,
|
allowSendingWithoutReply: Boolean?,
|
||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<out Message> = SendMediaGroup<MediaGroupPartContent>(
|
): Request<ContentMessage<MediaGroupContent<MediaGroupPartContent>>> = SendMediaGroup<MediaGroupPartContent>(
|
||||||
chatId,
|
chatId,
|
||||||
group.map { it.content.toMediaGroupMemberTelegramMedia() },
|
group.map { it.content.toMediaGroupMemberTelegramMedia() },
|
||||||
threadId,
|
threadId,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ data class StickerContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
messageThreadId,
|
messageThreadId,
|
||||||
|
media.emoji,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
protectContent,
|
protectContent,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
|
|||||||
@@ -25,15 +25,16 @@ sealed interface StickerSet {
|
|||||||
val name: String
|
val name: String
|
||||||
val title: String
|
val title: String
|
||||||
val stickerType: StickerType
|
val stickerType: StickerType
|
||||||
|
val stickerFormat: StickerFormat
|
||||||
val stickers: List<Sticker>
|
val stickers: List<Sticker>
|
||||||
val isAnimated: Boolean
|
val isAnimated: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
val isVideo: Boolean
|
val isVideo: Boolean
|
||||||
get() = false
|
get() = false
|
||||||
|
val thumbnail: PhotoSize?
|
||||||
|
@Deprecated("Renamed in telegram bot api")
|
||||||
val thumb: PhotoSize?
|
val thumb: PhotoSize?
|
||||||
@Deprecated("Will be removed soon due to its redundancy")
|
get() = thumbnail
|
||||||
val containsMasks: Boolean
|
|
||||||
get() = this is MaskStickerSet
|
|
||||||
|
|
||||||
object Serializer : KSerializer<StickerSet> {
|
object Serializer : KSerializer<StickerSet> {
|
||||||
override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor
|
override val descriptor: SerialDescriptor = JsonElement.serializer().descriptor
|
||||||
@@ -124,11 +125,19 @@ sealed interface StickerSet {
|
|||||||
sealed interface AnimatedStickerSet : StickerSet {
|
sealed interface AnimatedStickerSet : StickerSet {
|
||||||
override val isAnimated: Boolean
|
override val isAnimated: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat
|
||||||
|
get() = StickerFormat.Animated
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface VideoStickerSet : StickerSet {
|
sealed interface VideoStickerSet : StickerSet {
|
||||||
override val isVideo: Boolean
|
override val isVideo: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat
|
||||||
|
get() = StickerFormat.Video
|
||||||
}
|
}
|
||||||
@Serializable
|
@Serializable
|
||||||
sealed interface RegularStickerSet : StickerSet
|
sealed interface RegularStickerSet : StickerSet
|
||||||
@@ -146,11 +155,14 @@ data class RegularSimpleStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<RegularSimpleSticker>,
|
override val stickers: List<RegularSimpleSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : RegularStickerSet {
|
) : RegularStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.Regular
|
override val stickerType: StickerType = StickerType.Regular
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -162,7 +174,7 @@ data class RegularAnimatedStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<RegularAnimatedSticker>,
|
override val stickers: List<RegularAnimatedSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : RegularStickerSet, AnimatedStickerSet {
|
) : RegularStickerSet, AnimatedStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -178,7 +190,7 @@ data class RegularVideoStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<RegularVideoSticker>,
|
override val stickers: List<RegularVideoSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : RegularStickerSet, VideoStickerSet {
|
) : RegularStickerSet, VideoStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -194,11 +206,15 @@ data class MaskSimpleStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<MaskSimpleSticker>,
|
override val stickers: List<MaskSimpleSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : MaskStickerSet {
|
) : MaskStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.Mask
|
override val stickerType: StickerType = StickerType.Mask
|
||||||
|
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -210,7 +226,7 @@ data class MaskAnimatedStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<MaskAnimatedSticker>,
|
override val stickers: List<MaskAnimatedSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : MaskStickerSet, AnimatedStickerSet {
|
) : MaskStickerSet, AnimatedStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -226,7 +242,7 @@ data class MaskVideoStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<MaskVideoSticker>,
|
override val stickers: List<MaskVideoSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : MaskStickerSet, VideoStickerSet {
|
) : MaskStickerSet, VideoStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -242,11 +258,15 @@ data class CustomEmojiSimpleStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<CustomEmojiSimpleSticker>,
|
override val stickers: List<CustomEmojiSimpleSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : CustomEmojiStickerSet {
|
) : CustomEmojiStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
override val stickerType: StickerType = StickerType.CustomEmoji
|
override val stickerType: StickerType = StickerType.CustomEmoji
|
||||||
|
|
||||||
|
@SerialName(stickerFormatField)
|
||||||
|
@EncodeDefault
|
||||||
|
override val stickerFormat: StickerFormat = StickerFormat.Static
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -258,7 +278,7 @@ data class CustomEmojiAnimatedStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<CustomEmojiAnimatedSticker>,
|
override val stickers: List<CustomEmojiAnimatedSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : CustomEmojiStickerSet, AnimatedStickerSet {
|
) : CustomEmojiStickerSet, AnimatedStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -274,7 +294,7 @@ data class CustomEmojiVideoStickerSet(
|
|||||||
@SerialName(stickersField)
|
@SerialName(stickersField)
|
||||||
override val stickers: List<CustomEmojiVideoSticker>,
|
override val stickers: List<CustomEmojiVideoSticker>,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null
|
override val thumbnail: PhotoSize? = null
|
||||||
) : CustomEmojiStickerSet, VideoStickerSet {
|
) : CustomEmojiStickerSet, VideoStickerSet {
|
||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
@EncodeDefault
|
@EncodeDefault
|
||||||
@@ -292,6 +312,6 @@ data class UnknownStickerSet(
|
|||||||
@SerialName(stickerTypeField)
|
@SerialName(stickerTypeField)
|
||||||
override val stickerType: StickerType,
|
override val stickerType: StickerType,
|
||||||
@SerialName(thumbnailField)
|
@SerialName(thumbnailField)
|
||||||
override val thumb: PhotoSize? = null,
|
override val thumbnail: PhotoSize? = null,
|
||||||
val raw: JsonElement
|
val raw: JsonElement
|
||||||
) : CustomEmojiStickerSet, VideoStickerSet
|
) : CustomEmojiStickerSet, VideoStickerSet
|
||||||
|
|||||||
@@ -14,9 +14,6 @@ interface FlowsUpdatesFilter : UpdatesFilter {
|
|||||||
override val allowedUpdates: List<String>
|
override val allowedUpdates: List<String>
|
||||||
get() = ALL_UPDATES_LIST
|
get() = ALL_UPDATES_LIST
|
||||||
val allUpdatesFlow: Flow<Update>
|
val allUpdatesFlow: Flow<Update>
|
||||||
@Deprecated("Since 4.0.0 is not actual", ReplaceWith("allUpdatesFlow"))
|
|
||||||
val allUpdatesWithoutMediaGroupsGroupingFlow: Flow<Update>
|
|
||||||
get() = allUpdatesFlow
|
|
||||||
|
|
||||||
val messagesFlow: Flow<MessageUpdate>
|
val messagesFlow: Flow<MessageUpdate>
|
||||||
val messageMediaGroupsFlow: Flow<MessageUpdate>
|
val messageMediaGroupsFlow: Flow<MessageUpdate>
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ import dev.inmo.tgbotapi.types.location.*
|
|||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
import dev.inmo.tgbotapi.types.message.*
|
import dev.inmo.tgbotapi.types.message.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.LeftChatMember
|
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||||
@@ -1943,13 +1942,13 @@ inline fun ChatMember.asKickedChatMember(): KickedChatMember? = this as? KickedC
|
|||||||
inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember
|
inline fun ChatMember.requireKickedChatMember(): KickedChatMember = this as KickedChatMember
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ChatMember.whenLeftChatMember(block: (LeftChatMember) -> T) = asLeftChatMember()?.let(block)
|
inline fun <T> ChatMember.whenLeftChatMember(block: (LeftChatMemberEvent) -> T) = asLeftChatMember()?.let(block)
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ChatMember.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember
|
inline fun ChatMember.asLeftChatMember(): LeftChatMemberEvent? = this as? LeftChatMemberEvent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ChatMember.requireLeftChatMember(): LeftChatMember = this as LeftChatMember
|
inline fun ChatMember.requireLeftChatMember(): LeftChatMemberEvent = this as LeftChatMemberEvent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ChatMember.whenMemberChatMember(block: (MemberChatMember) -> T) = asMemberChatMember()?.let(block)
|
inline fun <T> ChatMember.whenMemberChatMember(block: (MemberChatMember) -> T) = asMemberChatMember()?.let(block)
|
||||||
@@ -2382,15 +2381,6 @@ inline fun TelegramMediaFile.asSticker(): Sticker? = this as? Sticker
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker
|
inline fun TelegramMediaFile.requireSticker(): Sticker = this as Sticker
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun <T> TelegramMediaFile.whenSimpleSticker(block: (SimpleSticker) -> T) = asSimpleSticker()?.let(block)
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun TelegramMediaFile.asSimpleSticker(): SimpleSticker? = this as? SimpleSticker
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun TelegramMediaFile.requireSimpleSticker(): SimpleSticker = this as SimpleSticker
|
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> TelegramMediaFile.whenAnimatedSticker(block: (AnimatedSticker) -> T) = asAnimatedSticker()?.let(block)
|
inline fun <T> TelegramMediaFile.whenAnimatedSticker(block: (AnimatedSticker) -> T) = asAnimatedSticker()?.let(block)
|
||||||
|
|
||||||
@@ -2741,10 +2731,12 @@ inline fun <T> ResendableContent.whenAudioMediaGroupContent(block: (AudioMediaGr
|
|||||||
asAudioMediaGroupContent()?.let(block)
|
asAudioMediaGroupContent()?.let(block)
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupPartContent? = this as? AudioMediaGroupPartContent
|
inline fun ResendableContent.asAudioMediaGroupContent(): AudioMediaGroupPartContent? =
|
||||||
|
this as? AudioMediaGroupPartContent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupPartContent = this as AudioMediaGroupPartContent
|
inline fun ResendableContent.requireAudioMediaGroupContent(): AudioMediaGroupPartContent =
|
||||||
|
this as AudioMediaGroupPartContent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ResendableContent.whenDocumentMediaGroupContent(block: (DocumentMediaGroupPartContent) -> T) =
|
inline fun <T> ResendableContent.whenDocumentMediaGroupContent(block: (DocumentMediaGroupPartContent) -> T) =
|
||||||
@@ -2815,10 +2807,12 @@ inline fun <T> ResendableContent.whenVisualMediaGroupContent(block: (VisualMedia
|
|||||||
asVisualMediaGroupContent()?.let(block)
|
asVisualMediaGroupContent()?.let(block)
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupPartContent? = this as? VisualMediaGroupPartContent
|
inline fun ResendableContent.asVisualMediaGroupContent(): VisualMediaGroupPartContent? =
|
||||||
|
this as? VisualMediaGroupPartContent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupPartContent = this as VisualMediaGroupPartContent
|
inline fun ResendableContent.requireVisualMediaGroupContent(): VisualMediaGroupPartContent =
|
||||||
|
this as VisualMediaGroupPartContent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ResendableContent.whenAnimationContent(block: (AnimationContent) -> T) = asAnimationContent()?.let(block)
|
inline fun <T> ResendableContent.whenAnimationContent(block: (AnimationContent) -> T) = asAnimationContent()?.let(block)
|
||||||
@@ -3165,13 +3159,13 @@ inline fun ChatEvent.asGroupChatCreated(): GroupChatCreated? = this as? GroupCha
|
|||||||
inline fun ChatEvent.requireGroupChatCreated(): GroupChatCreated = this as GroupChatCreated
|
inline fun ChatEvent.requireGroupChatCreated(): GroupChatCreated = this as GroupChatCreated
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ChatEvent.whenLeftChatMember(block: (LeftChatMember) -> T) = asLeftChatMember()?.let(block)
|
inline fun <T> ChatEvent.whenLeftChatMember(block: (LeftChatMemberEvent) -> T) = asLeftChatMember()?.let(block)
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ChatEvent.asLeftChatMember(): LeftChatMember? = this as? LeftChatMember
|
inline fun ChatEvent.asLeftChatMember(): LeftChatMemberEvent? = this as? LeftChatMemberEvent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ChatEvent.requireLeftChatMember(): LeftChatMember = this as LeftChatMember
|
inline fun ChatEvent.requireLeftChatMember(): LeftChatMemberEvent = this as LeftChatMemberEvent
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ChatEvent.whenMessageAutoDeleteTimerChanged(block: (MessageAutoDeleteTimerChanged) -> T) =
|
inline fun <T> ChatEvent.whenMessageAutoDeleteTimerChanged(block: (MessageAutoDeleteTimerChanged) -> T) =
|
||||||
@@ -3522,26 +3516,6 @@ inline fun ForwardInfo.asForwardFromPublicChatInfo(): ForwardInfo.PublicChat? =
|
|||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun ForwardInfo.requireForwardFromPublicChatInfo(): ForwardInfo.PublicChat = this as ForwardInfo.PublicChat
|
inline fun ForwardInfo.requireForwardFromPublicChatInfo(): ForwardInfo.PublicChat = this as ForwardInfo.PublicChat
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun <T> ForwardInfo.whenForwardFromChannelInfo(block: (ForwardFromChannelInfo) -> T) =
|
|
||||||
asForwardFromChannelInfo()?.let(block)
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun ForwardInfo.asForwardFromChannelInfo(): ForwardFromChannelInfo? = this as? ForwardFromChannelInfo
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun ForwardInfo.requireForwardFromChannelInfo(): ForwardFromChannelInfo = this as ForwardFromChannelInfo
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun <T> ForwardInfo.whenForwardFromSupergroupInfo(block: (ForwardFromSupergroupInfo) -> T) =
|
|
||||||
asForwardFromSupergroupInfo()?.let(block)
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun ForwardInfo.asForwardFromSupergroupInfo(): ForwardFromSupergroupInfo? = this as? ForwardFromSupergroupInfo
|
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
inline fun ForwardInfo.requireForwardFromSupergroupInfo(): ForwardFromSupergroupInfo = this as ForwardFromSupergroupInfo
|
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> MessageContent.whenTextedInput(block: (TextedInput) -> T) = asTextedInput()?.let(block)
|
inline fun <T> MessageContent.whenTextedInput(block: (TextedInput) -> T) = asTextedInput()?.let(block)
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import dev.inmo.tgbotapi.abstracts.FromUser
|
|||||||
import dev.inmo.tgbotapi.abstracts.WithUser
|
import dev.inmo.tgbotapi.abstracts.WithUser
|
||||||
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
|
import dev.inmo.tgbotapi.requests.send.payments.CreateInvoiceLink
|
||||||
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
import dev.inmo.tgbotapi.requests.send.payments.SendInvoice
|
||||||
|
import dev.inmo.tgbotapi.requests.stickers.InputSticker
|
||||||
import dev.inmo.tgbotapi.types.ChatId
|
import dev.inmo.tgbotapi.types.ChatId
|
||||||
import dev.inmo.tgbotapi.types.ChatIdWithThreadId
|
import dev.inmo.tgbotapi.types.ChatIdWithThreadId
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
@@ -1002,6 +1003,43 @@ public inline fun <T>
|
|||||||
WithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T):
|
WithUser.ifMessageGameShortNameCallbackQuery(block: (MessageGameShortNameCallbackQuery) -> T):
|
||||||
T? = messageGameShortNameCallbackQueryOrNull() ?.let(block)
|
T? = messageGameShortNameCallbackQueryOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun InputSticker.maskOrNull(): InputSticker.Mask? = this as?
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask
|
||||||
|
|
||||||
|
public inline fun InputSticker.maskOrThrow(): InputSticker.Mask = this as
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.Mask
|
||||||
|
|
||||||
|
public inline fun <T> InputSticker.ifMask(block: (InputSticker.Mask) -> T): T? = maskOrNull()
|
||||||
|
?.let(block)
|
||||||
|
|
||||||
|
public inline fun InputSticker.withKeywordsOrNull(): InputSticker.WithKeywords? = this as?
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords
|
||||||
|
|
||||||
|
public inline fun InputSticker.withKeywordsOrThrow(): InputSticker.WithKeywords = this as
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords
|
||||||
|
|
||||||
|
public inline fun <T> InputSticker.ifWithKeywords(block: (InputSticker.WithKeywords) -> T): T? =
|
||||||
|
withKeywordsOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun InputSticker.customEmojiOrNull(): InputSticker.WithKeywords.CustomEmoji? = this
|
||||||
|
as? dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji
|
||||||
|
|
||||||
|
public inline fun InputSticker.customEmojiOrThrow(): InputSticker.WithKeywords.CustomEmoji = this as
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.CustomEmoji
|
||||||
|
|
||||||
|
public inline fun <T>
|
||||||
|
InputSticker.ifCustomEmoji(block: (InputSticker.WithKeywords.CustomEmoji) -> T): T? =
|
||||||
|
customEmojiOrNull() ?.let(block)
|
||||||
|
|
||||||
|
public inline fun InputSticker.regularOrNull(): InputSticker.WithKeywords.Regular? = this as?
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
|
||||||
|
|
||||||
|
public inline fun InputSticker.regularOrThrow(): InputSticker.WithKeywords.Regular = this as
|
||||||
|
dev.inmo.tgbotapi.requests.stickers.InputSticker.WithKeywords.Regular
|
||||||
|
|
||||||
|
public inline fun <T> InputSticker.ifRegular(block: (InputSticker.WithKeywords.Regular) -> T): T? =
|
||||||
|
regularOrNull() ?.let(block)
|
||||||
|
|
||||||
public inline fun ChatIdentifier.idChatIdentifierOrNull(): IdChatIdentifier? = this as?
|
public inline fun ChatIdentifier.idChatIdentifierOrNull(): IdChatIdentifier? = this as?
|
||||||
dev.inmo.tgbotapi.types.IdChatIdentifier
|
dev.inmo.tgbotapi.types.IdChatIdentifier
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.FromUser
|
||||||
|
import dev.inmo.tgbotapi.abstracts.WithChat
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.UserId
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.chat.User
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.filter
|
||||||
|
import kotlinx.coroutines.flow.transform
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will pass only those [T] which have [sameChat] as [chatId]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun <T : WithChat> Flow<T>.fromChat(chatId: ChatIdentifier): Flow<T> = filter { it.sameChat(chatId) }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Will pass only those [T] which have [sameChat] as [chatId]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun <T : WithChat> Flow<T>.fromChat(chat: Chat): Flow<T> = fromChat(chat.id)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return [Flow] with the [FromUser.user] field [User.id] the same as [userId]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun <T : FromUser> Flow<T>.fromUser(userId: UserId): Flow<T> = filter { it.user.id == userId }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return [Flow] with the [FromUser.user] field [User.id] the same as [user] [User.id]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun <T : FromUser> Flow<T>.fromUser(user: User): Flow<T> = fromUser(user.id)
|
||||||
|
|
||||||
@@ -1,20 +1,120 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.utils.extensions
|
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.abstracts.WithChat
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.usernameChatOrNull
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.whenUsernameChat
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageId
|
||||||
|
import dev.inmo.tgbotapi.types.MessageThreadId
|
||||||
|
import dev.inmo.tgbotapi.types.Username
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
import dev.inmo.tgbotapi.types.threadId
|
||||||
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is placed in the chat with id == [chatId]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun WithChat.sameChat(chatId: ChatIdentifier) = chat.id == chatId || (chatId is Username && chat.whenUsernameChat {
|
||||||
|
it.username == chatId
|
||||||
|
} ?: false)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is placed in the [chat]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun WithChat.sameChat(chat: Chat) = sameChat(chat.id) || chat.usernameChatOrNull() ?.username ?.let { sameChat(it) } ?: false
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true in case if [this] message is placed in the same chat that [other]
|
* @return true in case if [this] message is placed in the same chat that [other]
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun Message.sameChat(other: Message) = chat.id == other.chat.id
|
inline fun WithChat.sameChat(other: Message) = sameChat(other.chat)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [Message.messageId]
|
||||||
|
* equal [messageId] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameMessage(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageId
|
||||||
|
) = sameChat(chatId) && this.messageId == messageId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is from the same [chat] and [this] [Message.messageId] equal [messageId]
|
||||||
|
* identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameMessage(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageId
|
||||||
|
) = sameChat(chat) && this.messageId == messageId
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat
|
* @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat
|
||||||
* and have equal [Message.messageId] identifier
|
* and have equal [Message.messageId] identifier
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun Message.sameMessage(other: Message) = sameChat(other) && messageId == other.messageId
|
inline fun Message.sameMessage(other: Message) = sameMessage(other.chat, other.messageId)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread is the same thing that topic
|
||||||
|
*
|
||||||
|
* @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these
|
||||||
|
* messages from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameTopic(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sameChat(chatId) && threadIdOrNull == threadId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread is the same thing that topic
|
||||||
|
*
|
||||||
|
* @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these
|
||||||
|
* messages from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameThread(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
threadId: MessageThreadId? = chatId.threadId
|
||||||
|
) = sameTopic(chatId, threadId)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread is the same thing that topic
|
||||||
|
*
|
||||||
|
* @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these
|
||||||
|
* messages from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameTopic(
|
||||||
|
chat: Chat,
|
||||||
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sameTopic(chat.id, threadId)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread is the same thing that topic
|
||||||
|
*
|
||||||
|
* @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these
|
||||||
|
* messages from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameThread(
|
||||||
|
chat: Chat,
|
||||||
|
threadId: MessageThreadId? = chat.id.threadId
|
||||||
|
) = sameThread(chat.id, threadId)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Thread is the same thing that topic
|
||||||
|
*
|
||||||
|
* @return true in case if [this] message is from the same chat and topic as [other]. The same here means that these
|
||||||
|
* messages from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameTopic(other: Message) = sameTopic(other.chat, other.threadIdOrNull)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thread is the same thing that topic
|
* Thread is the same thing that topic
|
||||||
@@ -23,13 +123,4 @@ inline fun Message.sameMessage(other: Message) = sameChat(other) && messageId ==
|
|||||||
* from one chat and have equal [Message.threadIdOrNull] identifier
|
* from one chat and have equal [Message.threadIdOrNull] identifier
|
||||||
*/
|
*/
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun Message.sameTopic(other: Message) = sameChat(other) && threadIdOrNull == other.threadIdOrNull
|
inline fun Message.sameThread(other: Message) = sameTopic(other)
|
||||||
|
|
||||||
/**
|
|
||||||
* Thread is the same thing that topic
|
|
||||||
*
|
|
||||||
* @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages
|
|
||||||
* from one chat and have equal [Message.threadIdOrNull] identifier
|
|
||||||
*/
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
|
||||||
inline fun Message.sameThread(other: Message) = sameChat(other) && threadIdOrNull == other.threadIdOrNull
|
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ inline val Message.forward_from_chat: Chat?
|
|||||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat
|
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
inline val Message.forward_from_message_id: MessageId?
|
inline val Message.forward_from_message_id: MessageId?
|
||||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromChannelInfo() ?.messageId
|
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
inline val Message.forward_signature: ForwardSignature?
|
inline val Message.forward_signature: ForwardSignature?
|
||||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromChannelInfo() ?.signature
|
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
inline val Message.forward_sender_name: ForwardSenderName?
|
inline val Message.forward_sender_name: ForwardSenderName?
|
||||||
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName
|
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName
|
||||||
|
|||||||
@@ -1,639 +0,0 @@
|
|||||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
|
||||||
|
|
||||||
package dev.inmo.tgbotapi.extensions.utils.formatting
|
|
||||||
|
|
||||||
import dev.inmo.micro_utils.common.joinTo
|
|
||||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.*
|
|
||||||
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
|
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
|
|
||||||
private const val ReplacedInCoreModuleReason = "Replaced in core module"
|
|
||||||
private const val CoreModulePackage = "dev.inmo.tgbotapi.utils"
|
|
||||||
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilderBody", "$CoreModulePackage.EntitiesBuilderBody"))
|
|
||||||
typealias EntitiesBuilderBody = EntitiesBuilderBody
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("newLine", "$CoreModulePackage.newLine"))
|
|
||||||
val newLine = dev.inmo.tgbotapi.utils.newLine
|
|
||||||
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities"))
|
|
||||||
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = dev.inmo.tgbotapi.utils.buildEntities(separator, init)
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("buildEntities(separator, init)", "$CoreModulePackage.buildEntities"))
|
|
||||||
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = dev.inmo.tgbotapi.utils.buildEntities(regular(separator), init)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This builder can be used to provide building of [TextSource]s [List]
|
|
||||||
*
|
|
||||||
* @see buildEntities
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilder", "$CoreModulePackage.EntitiesBuilder"))
|
|
||||||
typealias EntitiesBuilder = dev.inmo.tgbotapi.utils.EntitiesBuilder
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold"))
|
|
||||||
inline fun EntitiesBuilder.bold(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.bold(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.bold] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln"))
|
|
||||||
inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(init)", "$CoreModulePackage.bold"))
|
|
||||||
inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.bold] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(init)", "$CoreModulePackage.boldln"))
|
|
||||||
inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(parts)", "$CoreModulePackage.bold"))
|
|
||||||
inline fun EntitiesBuilder.bold(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.bold(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.bold] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(parts)", "$CoreModulePackage.boldln"))
|
|
||||||
inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("bold(text)", "$CoreModulePackage.bold"))
|
|
||||||
inline fun EntitiesBuilder.bold(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.bold(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.bold] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(text)", "$CoreModulePackage.boldln"))
|
|
||||||
inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler"))
|
|
||||||
inline fun EntitiesBuilder.spoiler(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.spoiler] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln"))
|
|
||||||
inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(init)", "$CoreModulePackage.spoiler"))
|
|
||||||
inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.spoiler] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(init)", "$CoreModulePackage.spoilerln"))
|
|
||||||
inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(parts)", "$CoreModulePackage.spoiler"))
|
|
||||||
inline fun EntitiesBuilder.spoiler(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.spoiler] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(parts)", "$CoreModulePackage.spoilerln"))
|
|
||||||
inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoiler(text)", "$CoreModulePackage.spoiler"))
|
|
||||||
inline fun EntitiesBuilder.spoiler(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.spoiler] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(text)", "$CoreModulePackage.spoilerln"))
|
|
||||||
inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommand(command)", "$CoreModulePackage.botCommand"))
|
|
||||||
inline fun EntitiesBuilder.botCommand(command: String) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(command))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.botCommand] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("botCommandln(command)", "$CoreModulePackage.botCommandln"))
|
|
||||||
inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag"))
|
|
||||||
inline fun EntitiesBuilder.cashTag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.cashTag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln"))
|
|
||||||
inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(init)", "$CoreModulePackage.cashTag"))
|
|
||||||
inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.cashTag] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(init)", "$CoreModulePackage.cashTagln"))
|
|
||||||
inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(parts)", "$CoreModulePackage.cashTag"))
|
|
||||||
inline fun EntitiesBuilder.cashTag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.cashTag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(parts)", "$CoreModulePackage.cashTagln"))
|
|
||||||
inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTag(text)", "$CoreModulePackage.cashTag"))
|
|
||||||
inline fun EntitiesBuilder.cashTag(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.cashTag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(text)", "$CoreModulePackage.cashTagln"))
|
|
||||||
inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("code(code)", "$CoreModulePackage.code"))
|
|
||||||
inline fun EntitiesBuilder.code(code: String) = add(dev.inmo.tgbotapi.types.message.textsources.code(code))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.code] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("codeln(code)", "$CoreModulePackage.codeln"))
|
|
||||||
inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email"))
|
|
||||||
inline fun EntitiesBuilder.email(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.email(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.email] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln"))
|
|
||||||
inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(init)", "$CoreModulePackage.email"))
|
|
||||||
inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.email] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(init)", "$CoreModulePackage.emailln"))
|
|
||||||
inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(parts)", "$CoreModulePackage.email"))
|
|
||||||
inline fun EntitiesBuilder.email(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.email(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.email] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(parts)", "$CoreModulePackage.emailln"))
|
|
||||||
inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("email(emailAddress)", "$CoreModulePackage.email"))
|
|
||||||
inline fun EntitiesBuilder.email(emailAddress: String) = add(dev.inmo.tgbotapi.types.message.textsources.email(emailAddress))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.email] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(emailAddress)", "$CoreModulePackage.emailln"))
|
|
||||||
inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag"))
|
|
||||||
inline fun EntitiesBuilder.hashtag(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.hashtag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln"))
|
|
||||||
inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(init)", "$CoreModulePackage.hashtag"))
|
|
||||||
inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.hashtag] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(init)", "$CoreModulePackage.hashtagln"))
|
|
||||||
inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(parts)", "$CoreModulePackage.hashtag"))
|
|
||||||
inline fun EntitiesBuilder.hashtag(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.hashtag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(parts)", "$CoreModulePackage.hashtagln"))
|
|
||||||
inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtag(hashtag)", "$CoreModulePackage.hashtag"))
|
|
||||||
inline fun EntitiesBuilder.hashtag(hashtag: String) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(hashtag))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.hashtag] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(hashtag)", "$CoreModulePackage.hashtagln"))
|
|
||||||
inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic"))
|
|
||||||
inline fun EntitiesBuilder.italic(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.italic(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.italic] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln"))
|
|
||||||
inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(init)", "$CoreModulePackage.italic"))
|
|
||||||
inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.italic] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(init)", "$CoreModulePackage.italicln"))
|
|
||||||
inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(parts)", "$CoreModulePackage.italic"))
|
|
||||||
inline fun EntitiesBuilder.italic(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.italic(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.italic] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(parts)", "$CoreModulePackage.italicln"))
|
|
||||||
inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italic(text)", "$CoreModulePackage.italic"))
|
|
||||||
inline fun EntitiesBuilder.italic(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.italic(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.italic] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(text)", "$CoreModulePackage.italicln"))
|
|
||||||
inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(init)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(init)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.mention(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(whoToMention)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(whoToMention: String) = add(dev.inmo.tgbotapi.types.message.textsources.mention(whoToMention))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(whoToMention)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(parts)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(parts: TextSourcesList, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(parts, user))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(parts, user)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts) + newLine
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(user, parts)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(
|
|
||||||
user: User,
|
|
||||||
vararg parts: TextSource
|
|
||||||
) = add(dev.inmo.tgbotapi.types.message.textsources.mention(user, *parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(user, parts)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(user: User, vararg parts: TextSource) = mention(user, *parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(text, user)", "$CoreModulePackage.mention"))
|
|
||||||
inline fun EntitiesBuilder.mention(text: String, user: User) = add(dev.inmo.tgbotapi.types.message.textsources.mention(text, user))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.mention] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(text, user)", "$CoreModulePackage.mentionln"))
|
|
||||||
inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone"))
|
|
||||||
inline fun EntitiesBuilder.phone(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.phone(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.phone] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln"))
|
|
||||||
inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(init)", "$CoreModulePackage.phone"))
|
|
||||||
inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.phone] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(init)", "$CoreModulePackage.phoneln"))
|
|
||||||
inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(parts)", "$CoreModulePackage.phone"))
|
|
||||||
inline fun EntitiesBuilder.phone(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.phone(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.phone] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(parts)", "$CoreModulePackage.phoneln"))
|
|
||||||
inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phone(number)", "$CoreModulePackage.phone"))
|
|
||||||
inline fun EntitiesBuilder.phone(number: String) = add(dev.inmo.tgbotapi.types.message.textsources.phone(number))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.phone] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(number)", "$CoreModulePackage.phoneln"))
|
|
||||||
inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("pre(code, language)", "$CoreModulePackage.pre"))
|
|
||||||
inline fun EntitiesBuilder.pre(code: String, language: String?) = add(dev.inmo.tgbotapi.types.message.textsources.pre(code, language))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.pre] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("preln(code, language)", "$CoreModulePackage.preln"))
|
|
||||||
inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource]
|
|
||||||
*
|
|
||||||
* @see RegularTextSource
|
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular(text)", "$CoreModulePackage.regular"))
|
|
||||||
inline fun EntitiesBuilder.regular(text: String) =
|
|
||||||
add(dev.inmo.tgbotapi.types.message.textsources.regular(text))
|
|
||||||
/**
|
|
||||||
* Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource] and "\n" at the end
|
|
||||||
*
|
|
||||||
* @see RegularTextSource
|
|
||||||
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regular
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln(text)", "$CoreModulePackage.regularln"))
|
|
||||||
inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough"))
|
|
||||||
inline fun EntitiesBuilder.strikethrough(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.strikethrough] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln"))
|
|
||||||
inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(init)", "$CoreModulePackage.strikethrough"))
|
|
||||||
inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.strikethrough] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(init)", "$CoreModulePackage.strikethroughln"))
|
|
||||||
inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(parts)", "$CoreModulePackage.strikethrough"))
|
|
||||||
inline fun EntitiesBuilder.strikethrough(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.strikethrough] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(parts)", "$CoreModulePackage.strikethroughln"))
|
|
||||||
inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethrough(text)", "$CoreModulePackage.strikethrough"))
|
|
||||||
inline fun EntitiesBuilder.strikethrough(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.strikethrough] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(text)", "$CoreModulePackage.strikethroughln"))
|
|
||||||
inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(text, url)", "$CoreModulePackage.link"))
|
|
||||||
inline fun EntitiesBuilder.link(text: String, url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(text, url))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.link] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(text, url)", "$CoreModulePackage.linkln"))
|
|
||||||
inline fun EntitiesBuilder.linkln(text: String, url: String) = link(text, url) + newLine
|
|
||||||
/**
|
|
||||||
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("link(url)", "$CoreModulePackage.link"))
|
|
||||||
inline fun EntitiesBuilder.link(url: String) = add(dev.inmo.tgbotapi.types.message.textsources.link(url))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.link] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("linkln(url)", "$CoreModulePackage.linkln"))
|
|
||||||
inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline"))
|
|
||||||
inline fun EntitiesBuilder.underline(parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.underline(parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.underline] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln"))
|
|
||||||
inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(init)", "$CoreModulePackage.underline"))
|
|
||||||
inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline(
|
|
||||||
buildEntities(separator, init)
|
|
||||||
))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.underline] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(init)", "$CoreModulePackage.underlineln"))
|
|
||||||
inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine
|
|
||||||
/**
|
|
||||||
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(parts)", "$CoreModulePackage.underline"))
|
|
||||||
inline fun EntitiesBuilder.underline(vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.underline(*parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.underline] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(parts)", "$CoreModulePackage.underlineln"))
|
|
||||||
inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underline(text)", "$CoreModulePackage.underline"))
|
|
||||||
inline fun EntitiesBuilder.underline(text: String) = add(dev.inmo.tgbotapi.types.message.textsources.underline(text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.underline] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(text)", "$CoreModulePackage.underlineln"))
|
|
||||||
inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji"))
|
|
||||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, parts: TextSourcesList) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln"))
|
|
||||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, parts: TextSourcesList) = customEmoji(customEmojiId, parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji].
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, init)", "$CoreModulePackage.customEmoji"))
|
|
||||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, buildEntities(separator, init)))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end.
|
|
||||||
* Will reuse separator config from [buildEntities]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, init)", "$CoreModulePackage.customEmojiln"))
|
|
||||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, noinline init: EntitiesBuilderBody) = customEmoji(customEmojiId, init) + newLine
|
|
||||||
/**
|
|
||||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, parts)", "$CoreModulePackage.customEmoji"))
|
|
||||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, vararg parts: TextSource) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, *parts))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, parts)", "$CoreModulePackage.customEmojiln"))
|
|
||||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, vararg parts: TextSource) = customEmoji(customEmojiId, *parts) + newLine
|
|
||||||
/**
|
|
||||||
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji]
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmoji(customEmojiId, text)", "$CoreModulePackage.customEmoji"))
|
|
||||||
inline fun EntitiesBuilder.customEmoji(customEmojiId: CustomEmojiId, text: String) = add(dev.inmo.tgbotapi.types.message.textsources.customEmoji(customEmojiId, text))
|
|
||||||
/**
|
|
||||||
* Version of [EntitiesBuilder.customEmoji] with new line at the end
|
|
||||||
*/
|
|
||||||
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("customEmojiln(customEmojiId, text)", "$CoreModulePackage.customEmojiln"))
|
|
||||||
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine
|
|
||||||
@@ -20,14 +20,8 @@ fun makeUsernameStartattachPrefix(username: String) = "$internalLinkBeginning/$u
|
|||||||
fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}"
|
fun makeUsernameStartattachLink(username: String, data: String? = null) = "${makeUsernameStartattachPrefix(username)}${data?.let { "=$it" } ?: ""}"
|
||||||
inline val Username.usernameLink
|
inline val Username.usernameLink
|
||||||
get() = makeUsernameLink(usernameWithoutAt)
|
get() = makeUsernameLink(usernameWithoutAt)
|
||||||
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.usernameLink", "dev.inmo.tgbotapi.extensions.utils.formatting.usernameLink"))
|
|
||||||
inline val Username.link
|
|
||||||
get() = usernameLink
|
|
||||||
val IdChatIdentifier.chatLink: String
|
val IdChatIdentifier.chatLink: String
|
||||||
get() = makeChatLink(chatId, threadId)
|
get() = makeChatLink(chatId, threadId)
|
||||||
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink"))
|
|
||||||
val IdChatIdentifier.link: String
|
|
||||||
get() = chatLink
|
|
||||||
fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId)
|
fun ChatId.link(threadId: MessageThreadId?) = makeChatLink(chatId, threadId)
|
||||||
inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId)
|
inline fun Username.link(threadId: MessageThreadId?) = makeUsernameLink(usernameWithoutAt, threadId)
|
||||||
inline val Username.deepLinkPrefix
|
inline val Username.deepLinkPrefix
|
||||||
@@ -95,13 +89,6 @@ val Message.messageLink: String?
|
|||||||
messageId
|
messageId
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* @see makeLinkToMessage
|
|
||||||
*/
|
|
||||||
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.messageLink", "dev.inmo.tgbotapi.extensions.utils.formatting.messageLink"))
|
|
||||||
val Message.link: String?
|
|
||||||
get() = messageLink
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no
|
* Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no
|
||||||
* known way to build link
|
* known way to build link
|
||||||
@@ -120,14 +107,6 @@ val Chat.chatLink: String?
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Link which can be used as by any user to get access to [Chat]. Returns null in case when there are no
|
|
||||||
* known way to build link
|
|
||||||
*/
|
|
||||||
@Deprecated("Deprecated due to the conflicts in name", ReplaceWith("this.chatLink", "dev.inmo.tgbotapi.extensions.utils.formatting.chatLink"))
|
|
||||||
val Chat.link: String?
|
|
||||||
get() = chatLink
|
|
||||||
|
|
||||||
private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers"
|
private const val stickerSetAddingLinkPrefix = "$internalLinkBeginning/addstickers"
|
||||||
|
|
||||||
val StickerSetName.stickerSetLink
|
val StickerSetName.stickerSetLink
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ inline fun Flow<ChatEventMessage<*>>.deletedGroupPhotoEvents() = filterGroupEven
|
|||||||
inline fun FlowsUpdatesFilter.deletedGroupPhotoEvents() = filterGroupEvents<DeleteChatPhoto>()
|
inline fun FlowsUpdatesFilter.deletedGroupPhotoEvents() = filterGroupEvents<DeleteChatPhoto>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newGroupMembersEvents() = filterGroupEvents<NewChatMembers>()
|
inline fun Flow<ChatEventMessage<*>>.newGroupMembersEvents() = filterGroupEvents<NewChatMembers>()
|
||||||
inline fun FlowsUpdatesFilter.newGroupMembersEvents() = filterGroupEvents<NewChatMembers>()
|
inline fun FlowsUpdatesFilter.newGroupMembersEvents() = filterGroupEvents<NewChatMembers>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.leftGroupMemberEvents() = filterGroupEvents<LeftChatMember>()
|
inline fun Flow<ChatEventMessage<*>>.leftGroupMemberEvents() = filterGroupEvents<LeftChatMemberEvent>()
|
||||||
inline fun FlowsUpdatesFilter.leftGroupMemberEvents() = filterGroupEvents<LeftChatMember>()
|
inline fun FlowsUpdatesFilter.leftGroupMemberEvents() = filterGroupEvents<LeftChatMemberEvent>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newGroupPhotoEvents() = filterGroupEvents<NewChatPhoto>()
|
inline fun Flow<ChatEventMessage<*>>.newGroupPhotoEvents() = filterGroupEvents<NewChatPhoto>()
|
||||||
inline fun FlowsUpdatesFilter.newGroupPhotoEvents() = filterGroupEvents<NewChatPhoto>()
|
inline fun FlowsUpdatesFilter.newGroupPhotoEvents() = filterGroupEvents<NewChatPhoto>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newGroupTitleEvents() = filterGroupEvents<NewChatTitle>()
|
inline fun Flow<ChatEventMessage<*>>.newGroupTitleEvents() = filterGroupEvents<NewChatTitle>()
|
||||||
@@ -97,8 +97,8 @@ inline fun Flow<ChatEventMessage<*>>.deletedSupergroupPhotoEvents() = filterSupe
|
|||||||
inline fun FlowsUpdatesFilter.deletedSupergroupPhotoEvents() = filterSupergroupEvents<DeleteChatPhoto>()
|
inline fun FlowsUpdatesFilter.deletedSupergroupPhotoEvents() = filterSupergroupEvents<DeleteChatPhoto>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newSupergroupMembersEvents() = filterSupergroupEvents<NewChatMembers>()
|
inline fun Flow<ChatEventMessage<*>>.newSupergroupMembersEvents() = filterSupergroupEvents<NewChatMembers>()
|
||||||
inline fun FlowsUpdatesFilter.newSupergroupMembersEvents() = filterSupergroupEvents<NewChatMembers>()
|
inline fun FlowsUpdatesFilter.newSupergroupMembersEvents() = filterSupergroupEvents<NewChatMembers>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.leftSupergroupMemberEvents() = filterSupergroupEvents<LeftChatMember>()
|
inline fun Flow<ChatEventMessage<*>>.leftSupergroupMemberEvents() = filterSupergroupEvents<LeftChatMemberEvent>()
|
||||||
inline fun FlowsUpdatesFilter.leftSupergroupMemberEvents() = filterSupergroupEvents<LeftChatMember>()
|
inline fun FlowsUpdatesFilter.leftSupergroupMemberEvents() = filterSupergroupEvents<LeftChatMemberEvent>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newSupergroupPhotoEvents() = filterSupergroupEvents<NewChatPhoto>()
|
inline fun Flow<ChatEventMessage<*>>.newSupergroupPhotoEvents() = filterSupergroupEvents<NewChatPhoto>()
|
||||||
inline fun FlowsUpdatesFilter.newSupergroupPhotoEvents() = filterSupergroupEvents<NewChatPhoto>()
|
inline fun FlowsUpdatesFilter.newSupergroupPhotoEvents() = filterSupergroupEvents<NewChatPhoto>()
|
||||||
inline fun Flow<ChatEventMessage<*>>.newSupergroupTitleEvents() = filterSupergroupEvents<NewChatTitle>()
|
inline fun Flow<ChatEventMessage<*>>.newSupergroupTitleEvents() = filterSupergroupEvents<NewChatTitle>()
|
||||||
|
|||||||
@@ -49,21 +49,6 @@ inline fun flatInlineKeyboard(
|
|||||||
block: InlineKeyboardRowBuilder.() -> Unit
|
block: InlineKeyboardRowBuilder.() -> Unit
|
||||||
) = inlineKeyboard { row<InlineKeyboardButton>(block) }
|
) = inlineKeyboard { row<InlineKeyboardButton>(block) }
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
|
||||||
*
|
|
||||||
* @see payButton
|
|
||||||
* @see dataButton
|
|
||||||
* @see gameButton
|
|
||||||
* @see loginButton
|
|
||||||
* @see inlineQueryInCurrentChatButton
|
|
||||||
* @see inlineQueryButton
|
|
||||||
* @see urlButton
|
|
||||||
*/
|
|
||||||
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
|
|
||||||
inline fun InlineKeyboardBuilder.row(
|
|
||||||
block: InlineKeyboardRowBuilder.() -> Unit
|
|
||||||
) = add(InlineKeyboardRowBuilder().apply(block).row)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [PayInlineKeyboardButton]
|
* Creates and put [PayInlineKeyboardButton]
|
||||||
|
|||||||
@@ -67,19 +67,6 @@ inline fun flatReplyKeyboard(
|
|||||||
row<KeyboardButton>(block)
|
row<KeyboardButton>(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder
|
|
||||||
*
|
|
||||||
* @see simpleButton
|
|
||||||
* @see requestContactButton
|
|
||||||
* @see requestLocationButton
|
|
||||||
* @see requestPollButton
|
|
||||||
*/
|
|
||||||
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
|
|
||||||
inline fun ReplyKeyboardBuilder.row(
|
|
||||||
block: ReplyKeyboardRowBuilder.() -> Unit
|
|
||||||
) = add(ReplyKeyboardRowBuilder().apply(block).row)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and put [SimpleKeyboardButton]
|
* Creates and put [SimpleKeyboardButton]
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -9,14 +9,6 @@ import dev.inmo.tgbotapi.types.update.*
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||||
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
|
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
|
||||||
|
|
||||||
/**
|
|
||||||
* @return If [this] is [SentMediaGroupUpdate] - [Update.updateId] of [last] element, or its own [Update.updateId]
|
|
||||||
*/
|
|
||||||
@Deprecated("Redundant", ReplaceWith("updateId"))
|
|
||||||
fun Update.lastUpdateIdentifier(): UpdateIdentifier {
|
|
||||||
return updateId
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The biggest [UpdateIdentifier] OR null
|
* @return The biggest [UpdateIdentifier] OR null
|
||||||
*
|
*
|
||||||
@@ -61,12 +53,3 @@ fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
|
|||||||
resultUpdates.sortBy { it.updateId }
|
resultUpdates.sortBy { it.updateId }
|
||||||
return resultUpdates
|
return resultUpdates
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is
|
|
||||||
* [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate]
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException
|
|
||||||
*/
|
|
||||||
@Deprecated("Redundant", ReplaceWith("this"))
|
|
||||||
fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this
|
|
||||||
|
|||||||
Reference in New Issue
Block a user