1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-17 04:20:13 +00:00

Compare commits

...

55 Commits

Author SHA1 Message Date
8b15296ee7 Update CHANGELOG.md 2022-11-01 12:41:35 +06:00
0fcc717269 Update libs.versions.toml 2022-11-01 12:41:24 +06:00
2ce26b4f1e Update CHANGELOG.md 2022-10-31 02:28:23 +06:00
b5d499b623 Update libs.versions.toml 2022-10-31 02:27:23 +06:00
102515dc8a Update CHANGELOG.md 2022-10-31 02:25:16 +06:00
777a58ce9a a little bit refactor hasCommands 2022-10-30 20:10:12 +06:00
7471da4ff0 update version of library 2022-10-30 19:48:04 +06:00
e753db0e71 Merge pull request #662 from InsanusMokrassar/renovate/korlibs
Update korlibs to v3.3.0
2022-10-28 18:54:53 +06:00
70984424e3 Merge pull request #669 from madhead/feature/initial-filters
Add `hasCommands` / `hasNoCommands` extensions on `CommonMessage`
2022-10-28 18:54:16 +06:00
c8354a330e Merge pull request #670 from InsanusMokrassar/renovate/ktor
Update ktor to v2.1.3
2022-10-28 18:53:38 +06:00
037ad8b87c Update gradle.properties 2022-10-28 18:51:52 +06:00
renovate[bot]
89550107d6 Update ktor to v2.1.3 2022-10-28 11:44:50 +00:00
madhead
86cc7cfb3d Add hasCommands / hasNoCommands extensions on CommonMessage
These extensions are meant to be used as arguments to the `initialFilter` parameter in behaviour builder triggers.
2022-10-24 03:46:30 +02:00
renovate[bot]
858586e608 Update korlibs to v3.3.0 2022-10-23 00:42:04 +00:00
d9846f27c9 Merge pull request #665 from InsanusMokrassar/3.3.0
3.3.0
2022-10-22 18:00:02 +06:00
c10da2a10a Update CHANGELOG.md 2022-10-22 17:59:54 +06:00
8ed216619d deprecate TelegramBot#getStickerSet 2022-10-22 17:41:55 +06:00
62a9c687d5 update dependencies and changelog 2022-10-22 14:33:43 +06:00
c2918c308f Merge pull request #668 from d1snin/wait-command-message
Added `BehaviourContext.waitCommandMessage` supporting `BotCommand`
2022-10-20 06:56:06 +06:00
d1snin
81fbff0bf5 added BehaviourContext.waitCommandMessage supporting BotCommand 2022-10-19 22:15:15 +03:00
54fb58de81 Update CHANGELOG.md 2022-10-19 19:25:01 +06:00
94ed4fed10 Update libs.versions.toml 2022-10-19 19:19:14 +06:00
63ceec70ca Merge pull request #664 from d1snin/bot-command
added `EntitiesBuilder.botCommand` and `EntitiesBuilder.botCommandln`…
2022-10-13 23:32:58 +06:00
636382fc8f Update EntitiesBuilder.kt 2022-10-13 23:31:41 +06:00
ac7bf60182 Update BotCommandTextSource.kt 2022-10-13 23:30:34 +06:00
bd91d4a0c0 Update CommandHandling.kt 2022-10-13 23:29:36 +06:00
d1snin
7488eb9d4b added botCommand text source factory function supporting BotCommand 2022-10-13 19:56:26 +03:00
6fcd248aff update microutils 2022-10-13 18:25:44 +06:00
5fa1804003 start 0.3.3 2022-10-13 18:24:59 +06:00
d1snin
0c9919e9e7 added command handling functions supporting BotCommand 2022-10-12 21:04:20 +03:00
d1snin
9405aa4467 added EntitiesBuilder.botCommand and EntitiesBuilder.botCommandln overloads supporting BotCommand 2022-10-12 20:57:42 +03:00
4f75bc792d Merge pull request #659 from InsanusMokrassar/3.2.7
3.2.7
2022-10-01 23:36:51 +06:00
fda53cf171 update dependencies 2022-10-01 22:09:01 +06:00
b588622c3d deprecate old row methods for keyboard builders 2022-09-28 20:48:55 +06:00
8b64a0c94e keyboard builders become typealiases 2022-09-28 20:38:16 +06:00
959f0dffba start 3.2.7 2022-09-28 20:02:45 +06:00
8fc9185884 Merge pull request #656 from InsanusMokrassar/3.2.6
3.2.6
2022-09-19 14:59:34 +06:00
3a9cf03958 add edit extensions with builders of text sources 2022-09-19 14:34:19 +06:00
7cd97ac779 All the extensions related to text messages (replies, sending, editing) got their duplicates with buildEntities lambda and separator 2022-09-19 13:52:14 +06:00
c460b4eacc small refactoring inside of entities builder 2022-09-19 12:57:22 +06:00
0aa58bd9f6 improve deprecation messages in old entities builder 2022-09-19 12:10:17 +06:00
a4a82f69c6 replace entities builder 2022-09-19 11:18:01 +06:00
d450ed9126 Fixes in ChatMemberSerializer#serialize method 2022-09-19 02:17:40 +06:00
69c5f1ae7d start 3.2.6 2022-09-19 02:16:12 +06:00
e4e8eadfb5 Merge pull request #655 from InsanusMokrassar/3.2.5
3.2.5
2022-09-19 01:51:49 +06:00
c1374c118d Improve support of new exceptions recovering mechanism 2022-09-19 01:39:23 +06:00
6004b159ec 3.2.5 2022-09-19 00:17:30 +06:00
67f95682d5 Merge pull request #654 from InsanusMokrassar/3.2.4
3.2.4
2022-09-16 21:29:21 +06:00
5aa5460a43 new edits 2022-09-16 16:36:21 +06:00
e937845fc7 start 3.2.4 2022-09-16 15:43:40 +06:00
96f40e55bc Merge pull request #653 from InsanusMokrassar/3.2.3
3.2.3
2022-09-15 15:28:54 +06:00
d3d8603c35 upfix 2022-09-15 15:22:08 +06:00
759650892c fix in DeleteMyCommands 2022-09-15 15:06:19 +06:00
b58550a9ec start 3.2.3 2022-09-15 15:05:38 +06:00
e15817e7c5 Merge pull request #652 from InsanusMokrassar/3.2.2
3.2.2
2022-09-15 13:11:29 +06:00
30 changed files with 1684 additions and 152 deletions

View File

@@ -1,5 +1,69 @@
# TelegramBotAPI changelog # TelegramBotAPI changelog
## 3.3.1
* `Versions`:
* `Ktor`: `2.1.2` -> `2.1.3`
* `Klock`: `3.2.0` -> `3.3.1`
* `MicroUtils`: `0.13.1` -> `0.13.2`
* `Utils`:
* New extensions on `CommonMessage`: `hasCommands` and `hasNoCommands`. Useful for the `initialFilter` parameter in behaviour builder triggers.
## 3.3.0
**THIS VERSION CONTAINS UPGRADE KOTLIN (AND ALL RELATED LIBRARIES) UP TO 1.7.20**
* `Versions`:
* `Kotlin`: `1.7.10` -> `1.7.20`
* `Kotlin Serialization`: `1.4.0` -> `1.4.1`
* `Korlibs`: `3.1.0` -> `3.2.0`
* `MicroUtils`: `0.12.17` -> `0.13.1`
* `Core`:
* Add opportunity to create command text source and add command in entities builder
via `BotCommamd` (thanks to [d1shin](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/664))
* `API`:
* New extensions `TelegramBot#getStickerSetOrNull` and `TelegramBot#getStickerSetOrThrow`
* Old `TelegramBot#getStickerSet` has been deprecated
* `Behaviour Builder`:
* Add opportunity to use triggers and waiters with `BotCommand` (thanks to [d1shin](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/664))
## 3.2.7
* `Versions`:
* `MicroUtils`: `0.12.13` -> `0.12.17`
* `Ktor`: `2.1.1` -> `2.1.2`
* `Utils`:
* Next classes become typealiases instead of classes:
* `ReplyKeyboardBuilder`
* `ReplyKeyboardRowBuilder`
* `InlineKeyboardBuilder`
* `InlineKeyboardRowBuilder`
## 3.2.6
* `Core`:
* Fixes in `ChatMemberSerializer#serialize` method
* Migration of `EntitiesBuilder` from `Utils` to `Core`
* `API`:
* All the extensions related to text messages (replies, sending, editing) got their duplicates with `buildEntities` lambda and separator
* `Utils`:
* Migration of `EntitiesBuilder` from `Utils` to `Core`
## 3.2.5
* `Common`:
* Improve support of new exceptions recovering mechanism
## 3.2.4
* `API`:
* New `edit`'s with chats and message ids
## 3.2.3
* `Core`:
* Fixes in `DeleteMyCommands`
## 3.2.2 ## 3.2.2
* `Versions`: * `Versions`:

View File

@@ -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=3.2.2 library_version=3.3.1

View File

@@ -1,19 +1,19 @@
[versions] [versions]
kotlin = "1.7.10" kotlin = "1.7.20"
kotlin-serialization = "1.4.0" kotlin-serialization = "1.4.1"
kotlin-coroutines = "1.6.4" kotlin-coroutines = "1.6.4"
javax-activation = "1.1.1" javax-activation = "1.1.1"
korlibs = "3.1.0" korlibs = "3.3.1"
uuid = "0.5.0" uuid = "0.5.0"
ktor = "2.1.1" ktor = "2.1.3"
ksp = "1.7.10-1.0.6" ksp = "1.7.20-1.0.7"
kotlin-poet = "1.12.0" kotlin-poet = "1.12.0"
microutils = "0.12.13" microutils = "0.13.2"
github-release-plugin = "2.4.1" github-release-plugin = "2.4.1"

View File

@@ -18,6 +18,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
import dev.inmo.tgbotapi.utils.buildEntities
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -183,6 +185,57 @@ suspend fun TelegramBot.edit(
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(message, replyMarkup) ) = editMessageReplyMarkup(message, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chatId, messageId, text, parseMode, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
chatId: ChatIdentifier,
messageId: MessageId,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
@@ -193,7 +246,7 @@ suspend fun TelegramBot.edit(
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(message, text, parseMode, disableWebPagePreview, replyMarkup) ) = edit(message.chat.id, message.messageId, text, parseMode, disableWebPagePreview, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -204,4 +257,52 @@ suspend fun TelegramBot.edit(
entities: TextSourcesList, entities: TextSourcesList,
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(message, entities, disableWebPagePreview, replyMarkup) ) = edit(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.edit(
message: ContentMessage<TextContent>,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = edit(message, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)

View File

@@ -11,7 +11,8 @@ import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage 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.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.utils.*
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -67,6 +68,32 @@ suspend fun TelegramBot.editMessageText(
EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup) EditChatMessageText(chatId, messageId, entities, disableWebPagePreview, replyMarkup)
) )
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
chatId: ChatIdentifier,
messageId: MessageId,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
chatId: ChatIdentifier,
messageId: MessageId,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(chatId, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
@@ -79,6 +106,32 @@ suspend fun TelegramBot.editMessageText(
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup) ) = editMessageText(chat.id, messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
chat: Chat,
messageId: MessageId,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
chat: Chat,
messageId: MessageId,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(chat.id, messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
@@ -90,6 +143,30 @@ suspend fun TelegramBot.editMessageText(
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) ) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
message: ContentMessage<TextContent>,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that * as a builder for that
@@ -101,3 +178,29 @@ suspend fun TelegramBot.editMessageText(
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup) ) = editMessageText(message.chat.id, message.messageId, entities, disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
suspend fun TelegramBot.editMessageText(
message: Message,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
suspend fun TelegramBot.editMessageText(
message: Message,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(message.chat.id, message.messageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)

View File

@@ -6,6 +6,9 @@ import dev.inmo.tgbotapi.types.InlineMessageIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
import dev.inmo.tgbotapi.utils.buildEntities
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@@ -29,3 +32,27 @@ suspend fun TelegramBot.editMessageText(
disableWebPagePreview: Boolean? = null, disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup)) ) = execute(EditInlineMessageText(inlineMessageId, entities, disableWebPagePreview, replyMarkup))
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
inlineMessageId: InlineMessageIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.editMessageText(
inlineMessageId: InlineMessageIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = editMessageText(inlineMessageId, buildEntities(separator, builderBody), disableWebPagePreview, replyMarkup)

View File

@@ -10,8 +10,21 @@ suspend fun TelegramBot.getStickerSet(
GetStickerSet(name) GetStickerSet(name)
) )
@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow"))
suspend fun TelegramBot.getStickerSet( suspend fun TelegramBot.getStickerSet(
sticker: Sticker sticker: Sticker
) = getStickerSet( ) = getStickerSet(
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method") sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
) )
suspend fun TelegramBot.getStickerSetOrNull(
sticker: Sticker
) = sticker.stickerSetName ?.let {
getStickerSet(it)
}
suspend fun TelegramBot.getStickerSetOrThrow(
sticker: Sticker
) = getStickerSet(
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
)

View File

@@ -11,7 +11,6 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning
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.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@@ -25,11 +24,12 @@ import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.*
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlin.js.JsName import kotlin.js.JsName
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
@@ -210,6 +210,36 @@ suspend inline fun TelegramBot.reply(
replyMarkup replyMarkup
) )
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.reply(
to: Message,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.reply(
to: Message,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = reply(to, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
// Venue // Venue
@@ -1245,7 +1275,7 @@ suspend fun TelegramBot.reply(
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: Message,
content: TextedMediaContent, content: TextedMediaContent,
entities: List<TextSource>, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,

View File

@@ -29,7 +29,7 @@ import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.*
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlin.js.JsName import kotlin.js.JsName
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
@@ -218,6 +218,38 @@ suspend inline fun TelegramBot.reply(
replyMarkup replyMarkup
) )
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.reply(
toChatId: ChatId,
toMessageId: MessageId,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.reply(
toChatId: ChatId,
toMessageId: MessageId,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = reply(toChatId, toMessageId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
// Venue // Venue

View File

@@ -2,12 +2,14 @@ package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.SendTextMessage import dev.inmo.tgbotapi.requests.send.SendTextMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
import dev.inmo.tgbotapi.utils.buildEntities
/** /**
* @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
@@ -95,6 +97,39 @@ suspend fun TelegramBot.sendMessage(
SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) )
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendMessage(
chatId: ChatIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendMessage(
chatId: ChatIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, 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
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
@@ -112,6 +147,39 @@ suspend fun TelegramBot.sendTextMessage(
chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
) )
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendTextMessage(
chatId: ChatIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendTextMessage(
chatId: ChatIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, 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
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
@@ -127,6 +195,39 @@ suspend fun TelegramBot.sendMessage(
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendMessage(
chat: Chat,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendMessage(
chat: Chat,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, 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
@@ -142,3 +243,36 @@ suspend fun TelegramBot.sendTextMessage(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendTextMessage(
chat: Chat,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.sendTextMessage(
chat: Chat,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@@ -20,12 +20,13 @@ import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.media.* import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.*
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
/** /**
@@ -560,6 +561,40 @@ suspend fun TelegramBot.send(
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) = sendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.send(
chatId: ChatIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = send(chatId, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/** /**
* Will execute [sendTextMessage] request * Will execute [sendTextMessage] request
* @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
@@ -576,6 +611,39 @@ suspend fun TelegramBot.send(
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chat, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup) ) = sendTextMessage(chat, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.send(
chat: Chat,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
* as a builder for that
*/
suspend fun TelegramBot.send(
chat: Chat,
separator: String,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
builderBody: EntitiesBuilderBody
) = send(chat, buildEntities(separator, builderBody), disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/** /**
* Will execute [sendPhoto] request * Will execute [sendPhoto] request
* @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

View File

@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
@@ -39,6 +40,12 @@ suspend fun BehaviourContext.waitCommandMessage(
errorFactory: NullableRequestBuilder<*> = { null } errorFactory: NullableRequestBuilder<*> = { null }
) = waitCommandMessage(Regex(command), initRequest, errorFactory) ) = waitCommandMessage(Regex(command), initRequest, errorFactory)
suspend fun BehaviourContext.waitCommandMessage(
botCommand: BotCommand,
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitCommandMessage(botCommand.command, initRequest, errorFactory)
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter { fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
it.content.textSources.firstOrNull() is BotCommandTextSource it.content.textSources.firstOrNull() is BotCommandTextSource
} }

View File

@@ -12,6 +12,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.Mar
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull import dev.inmo.tgbotapi.extensions.utils.botCommandTextSourceOrNull
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.content.TextMessage import dev.inmo.tgbotapi.types.message.content.TextMessage
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
@@ -82,6 +83,15 @@ suspend fun <BC : BehaviourContext> BC.command(
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage> scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) ) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
suspend fun <BC : BehaviourContext> BC.command(
botCommand: BotCommand,
requireOnlyCommandInMessage: Boolean = true,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
) = command(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
suspend fun <BC : BehaviourContext> BC.onCommand( suspend fun <BC : BehaviourContext> BC.onCommand(
commandRegex: Regex, commandRegex: Regex,
requireOnlyCommandInMessage: Boolean = true, requireOnlyCommandInMessage: Boolean = true,
@@ -100,6 +110,15 @@ suspend fun <BC : BehaviourContext> BC.onCommand(
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage> scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) ): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
suspend fun <BC : BehaviourContext> BC.onCommand(
botCommand: BotCommand,
requireOnlyCommandInMessage: Boolean = true,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, TextMessage>
): Job = onCommand(botCommand.command, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
suspend fun <BC : BehaviourContext> BC.commandWithArgs( suspend fun <BC : BehaviourContext> BC.commandWithArgs(
commandRegex: Regex, commandRegex: Regex,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups, initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
@@ -134,6 +153,20 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
scenarioReceiver = scenarioReceiver scenarioReceiver = scenarioReceiver
) )
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
botCommand: BotCommand,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
) = commandWithArgs(
botCommand.command,
initialFilter = initialFilter,
subcontextUpdatesFilter = subcontextUpdatesFilter,
markerFactory = markerFactory,
scenarioReceiver = scenarioReceiver
)
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs( suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
commandRegex: Regex, commandRegex: Regex,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups, initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
@@ -149,3 +182,11 @@ suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory, markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>> scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver) ): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
botCommand: BotCommand,
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, TextMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in TextMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, TextMessage, Array<String>>
): Job = onCommandWithArgs(botCommand.command, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)

View File

@@ -4,6 +4,7 @@ import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.types.Response import dev.inmo.tgbotapi.types.Response
import dev.inmo.tgbotapi.types.RetryAfterError import dev.inmo.tgbotapi.types.RetryAfterError
import io.ktor.utils.io.errors.IOException import io.ktor.utils.io.errors.IOException
import kotlinx.coroutines.CopyableThrowable
fun newRequestException( fun newRequestException(
response: Response, response: Response,
@@ -35,9 +36,11 @@ fun newRequestException(
} }
} ?: CommonRequestException(response, plainAnswer, message, cause) } ?: CommonRequestException(response, plainAnswer, message, cause)
sealed class BotException(message: String = "Something went wrong", cause: Throwable? = null) : IOException(message, cause) sealed class BotException(message: String = "Something went wrong", cause: Throwable? = null) : IOException(message, cause), CopyableThrowable<BotException>
class CommonBotException(message: String = "Something went wrong", cause: Throwable? = null) : BotException(message, cause) class CommonBotException(message: String = "Something went wrong", cause: Throwable? = null) : BotException(message, cause) {
override fun createCopy(): BotException = CommonBotException(message!!, cause)
}
sealed class RequestException constructor( sealed class RequestException constructor(
val response: Response, val response: Response,
@@ -50,28 +53,46 @@ sealed class RequestException constructor(
) )
class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class CommonRequestException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = CommonRequestException(response, plainAnswer, message, cause)
}
class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class UnauthorizedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = UnauthorizedException(response, plainAnswer, message, cause)
}
class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class ReplyMessageNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = ReplyMessageNotFoundException(response, plainAnswer, message, cause)
}
class MessageIsNotModifiedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class MessageIsNotModifiedException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = MessageIsNotModifiedException(response, plainAnswer, message, cause)
}
class MessageToEditNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class MessageToEditNotFoundException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = MessageToEditNotFoundException(response, plainAnswer, message, cause)
}
class InvalidPhotoDimensionsException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class InvalidPhotoDimensionsException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = InvalidPhotoDimensionsException(response, plainAnswer, message, cause)
}
class WrongFileIdentifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class WrongFileIdentifierException(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = WrongFileIdentifierException(response, plainAnswer, message, cause)
}
class TooMuchRequestsException(val retryAfter: RetryAfterError, response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class TooMuchRequestsException(val retryAfter: RetryAfterError, response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = TooMuchRequestsException(retryAfter, response, plainAnswer, message, cause)
}
class GetUpdatesConflict(response: Response, plainAnswer: String, message: String?, cause: Throwable?) : class GetUpdatesConflict(response: Response, plainAnswer: String, message: String?, cause: Throwable?) :
RequestException(response, plainAnswer, message, cause) RequestException(response, plainAnswer, message, cause) {
override fun createCopy(): BotException = GetUpdatesConflict(response, plainAnswer, message, cause)
}

View File

@@ -77,21 +77,23 @@ class KtorRequestsExecutor(
val result = it.exceptionOrNull() ?.let { e -> val result = it.exceptionOrNull() ?.let { e ->
pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it } pipelineStepsHolder.onRequestException(request, e) ?.let { return@let it }
if (e is ClientRequestException) { when (e) {
val exceptionResult = runCatchingSafely { is ClientRequestException -> {
val content = e.response.bodyAsText() val exceptionResult = runCatchingSafely {
val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content) val content = e.response.bodyAsText()
newRequestException( val responseObject = jsonFormatter.decodeFromString(Response.serializer(), content)
responseObject, newRequestException(
content, responseObject,
"Can't get result object from $content" content,
) "Can't get result object from $content"
)
}
exceptionResult.exceptionOrNull() ?.let {
CommonBotException(cause = e)
} ?: exceptionResult.getOrThrow()
} }
exceptionResult.exceptionOrNull() ?.let { is BotException -> e
CommonBotException(cause = e) else -> CommonBotException(cause = e)
} ?: exceptionResult.getOrThrow()
} else {
CommonBotException(cause = e)
} }
} ?.let { Result.failure(it) } ?: it } ?.let { Result.failure(it) } ?: it
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories) pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories)

View File

@@ -17,7 +17,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
): Any? = (request as? MultipartRequest) ?.let { castedRequest -> ): Any? = (request as? MultipartRequest) ?.let { castedRequest ->
MultiPartFormDataContent( MultiPartFormDataContent(
formData { formData {
val params = castedRequest.paramsJson.mapWithCommonValues() val params = castedRequest.paramsJson.mapWithCommonValues() - castedRequest.mediaMap.keys
for ((key, value) in castedRequest.mediaMap + params) { for ((key, value) in castedRequest.mediaMap + params) {
when (value) { when (value) {
is MultipartFile -> appendInput( is MultipartFile -> appendInput(

View File

@@ -18,8 +18,10 @@ data class DeleteMyCommands(
override val ietfLanguageCode: IetfLanguageCode? = null override val ietfLanguageCode: IetfLanguageCode? = null
) : MyCommandsRequest<Boolean> { ) : MyCommandsRequest<Boolean> {
override fun method(): String = "deleteMyCommands" override fun method(): String = "deleteMyCommands"
override val requestSerializer: SerializationStrategy<DeleteMyCommands> = serializer() override val requestSerializer: SerializationStrategy<DeleteMyCommands>
override val resultDeserializer: DeserializationStrategy<Boolean> = Boolean.serializer() get() = serializer()
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
constructor( constructor(
scope: BotCommandScope = BotCommandScopeDefault, scope: BotCommandScope = BotCommandScopeDefault,

View File

@@ -13,6 +13,7 @@ import kotlinx.serialization.json.JsonObject
data class SetChatPhoto ( data class SetChatPhoto (
@SerialName(chatIdField) @SerialName(chatIdField)
override val chatId: ChatIdentifier, override val chatId: ChatIdentifier,
@Transient
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically") val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
): ChatRequest, MultipartRequest<Boolean> { ): ChatRequest, MultipartRequest<Boolean> {
override fun method(): String = "setChatPhoto" override fun method(): String = "setChatPhoto"

View File

@@ -0,0 +1,102 @@
package dev.inmo.tgbotapi.types.buttons.inline
import dev.inmo.tgbotapi.types.LoginURL
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
/**
* Creates and put [PayInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun payInlineButton(
text: String
) = PayInlineKeyboardButton(text)
/**
* Creates and put [CallbackDataInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun dataInlineButton(
text: String,
data: String
) = CallbackDataInlineKeyboardButton(text, data)
/**
* Creates and put [CallbackGameInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun gameInlineButton(
text: String
) = CallbackGameInlineKeyboardButton(text)
/**
* Creates and put [LoginURLInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun loginInlineButton(
text: String,
loginUrl: LoginURL
) = LoginURLInlineKeyboardButton(text, loginUrl)
/**
* Creates and put [SwitchInlineQueryCurrentChatInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun inlineQueryInCurrentChatInlineButton(
text: String,
data: String
) = SwitchInlineQueryCurrentChatInlineKeyboardButton(text, data)
/**
* Creates and put [SwitchInlineQueryInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun inlineQueryInlineButton(
text: String,
data: String
) = SwitchInlineQueryInlineKeyboardButton(text, data)
/**
* Creates and put [URLInlineKeyboardButton]
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun urlInlineButton(
text: String,
url: String
) = URLInlineKeyboardButton(text, url)
/**
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun webAppInlineButton(
text: String,
webApp: WebAppInfo
) = WebAppInlineKeyboardButton(text, webApp)
/**
* Creates and put [WebAppInlineKeyboardButton]. Please, remember that this button is available in private chats only
*
* @see inlineKeyboard
* @see InlineKeyboardBuilder.row
*/
inline fun webAppInlineButton(
text: String,
url: String
) = webAppInlineButton(text, WebAppInfo(url))

View File

@@ -0,0 +1,69 @@
package dev.inmo.tgbotapi.types.buttons.reply
import dev.inmo.tgbotapi.types.buttons.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
import dev.inmo.tgbotapi.types.webapps.WebAppInfo
/**
* Creates and put [SimpleKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun simpleReplyButton(
text: String
) = SimpleKeyboardButton(text)
/**
* Creates and put [RequestContactKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun requestContactReplyButton(
text: String
) = RequestContactKeyboardButton(text)
/**
* Creates and put [RequestLocationKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun requestLocationReplyButton(
text: String
) = RequestLocationKeyboardButton(text)
/**
* Creates and put [RequestPollKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun requestPollReplyButton(
text: String,
pollType: KeyboardButtonPollType
) = RequestPollKeyboardButton(text, pollType)
/**
* Creates and put [WebAppKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun webAppReplyButton(
text: String,
webApp: WebAppInfo
) = WebAppKeyboardButton(text, webApp)
/**
* Creates and put [WebAppKeyboardButton]
*
* @see replyKeyboard
* @see ReplyKeyboardBuilder.row
*/
inline fun webAppReplyButton(
text: String,
url: String
) = webAppReplyButton(text, WebAppInfo(url))

View File

@@ -34,12 +34,12 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
override fun serialize(encoder: Encoder, value: ChatMember) { override fun serialize(encoder: Encoder, value: ChatMember) {
when (value) { when (value) {
is OwnerChatMember -> OwnerChatMember.serializer() is OwnerChatMember -> OwnerChatMember.serializer().serialize(encoder, value)
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer() is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer().serialize(encoder, value)
is MemberChatMember -> MemberChatMemberImpl.serializer() is MemberChatMemberImpl -> MemberChatMemberImpl.serializer().serialize(encoder, value)
is RestrictedChatMember -> RestrictedChatMember.serializer() is RestrictedChatMember -> RestrictedChatMember.serializer().serialize(encoder, value)
is LeftChatMember -> LeftChatMemberImpl.serializer() is LeftChatMemberImpl -> LeftChatMemberImpl.serializer().serialize(encoder, value)
is KickedChatMember -> KickedChatMember.serializer() is KickedChatMember -> KickedChatMember.serializer().serialize(encoder, value)
} }
} }
} }

View File

@@ -1,7 +1,8 @@
package dev.inmo.tgbotapi.types.message.textsources package dev.inmo.tgbotapi.types.message.textsources
import dev.inmo.tgbotapi.types.usernameRegex import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.usernameRegex
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.internal.* import dev.inmo.tgbotapi.utils.internal.*
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@@ -32,3 +33,6 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun botCommand(command: String) = BotCommandTextSource("/$command") inline fun botCommand(command: String) = BotCommandTextSource("/$command")
@Suppress("NOTHING_TO_INLINE")
inline fun botCommand(botCommand: BotCommand) = botCommand(botCommand.command)

View File

@@ -0,0 +1,578 @@
@file:Suppress("NOTHING_TO_INLINE", "unused")
package dev.inmo.tgbotapi.utils
import dev.inmo.micro_utils.common.joinTo
import dev.inmo.tgbotapi.types.BotCommand
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.textsources.*
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit
val newLine = regular("\n")
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build()
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init)
/**
* This builder can be used to provide building of [TextSource]s [List]
*
* @see buildEntities
*/
class EntitiesBuilder(
val separator: TextSource? = null
) {
private val entitiesList: MutableTextSourcesList = mutableListOf()
/**
* It is not safe field which contains potentially changeable [List]
*/
val entities: TextSourcesList
get() = entitiesList
/**
* @return New immutable list which will be deattached from this builder
*/
fun build(): TextSourcesList = if (separator != null) entities.joinTo(separator) else entities.toList()
fun add(source: TextSource): EntitiesBuilder {
entitiesList.add(source)
return this
}
fun addAll(sources: Iterable<TextSource>): EntitiesBuilder {
entitiesList.addAll(sources)
return this
}
operator fun TextSource.unaryPlus() = add(this)
operator fun TextSourcesList.unaryPlus() = addAll(this)
operator fun invoke(vararg source: TextSource) = addAll(source.toList())
operator fun String.unaryPlus(): EntitiesBuilder {
add(dev.inmo.tgbotapi.types.message.textsources.regular(this))
return this@EntitiesBuilder
}
operator fun plus(text: String) = text.unaryPlus()
operator fun plus(source: TextSource) = add(source)
operator fun plus(sources: Iterable<TextSource>) = addAll(sources)
operator fun plus(other: EntitiesBuilder) = if (other == this) {
// do nothing; assume user is using something like regular("Hello, ") + bold("world") in buildEntities
this
} else {
addAll(other.entitiesList)
}
}
/**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine
/**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine
/**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine
/**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine
/**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine
/**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine
/**
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine
/**
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand]
*/
inline fun EntitiesBuilder.botCommand(botCommand: BotCommand) = add(dev.inmo.tgbotapi.types.message.textsources.botCommand(botCommand))
/**
* Version of [EntitiesBuilder.botCommand] with new line at the end
*/
inline fun EntitiesBuilder.botCommandln(botCommand: BotCommand) = botCommand(botCommand) + newLine
/**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine
/**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine
/**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine
/**
* Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine
/**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine
/**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine
/**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine
/**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine
/**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine
/**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine
/**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine
/**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine
/**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine
/**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine
/**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine
/**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine
/**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts, user) + newLine
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
*/
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]
*/
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
*/
inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text, user) + newLine
/**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine
/**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine
/**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine
/**
* Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code, language) + newLine
/**
* Will add simple [dev.inmo.tgbotapi.types.message.textsources.regular] [TextSource]
*
* @see RegularTextSource
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln
*/
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
*/
inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine
/**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine
/**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine
/**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine
/**
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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
*/
inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
/**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine
/**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine
/**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
/**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.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
*/
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]
*/
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]
*/
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]
*/
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
*/
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]
*/
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
*/
inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine

View File

@@ -6,23 +6,23 @@ import dev.inmo.tgbotapi.types.buttons.Matrix
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/ */
fun <T> row(block: RowBuilder<T>.() -> Unit): List<T> { inline fun <T> row(block: RowBuilder<T>.() -> Unit): List<T> {
return RowBuilder<T>().also(block).row return RowBuilder<T>().apply(block).row
} }
/** /**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/ */
fun <T> MatrixBuilder<T>.row(block: RowBuilder<T>.() -> Unit) { inline fun <T> MatrixBuilder<T>.row(block: RowBuilder<T>.() -> Unit) {
add(RowBuilder<T>().also(block).row) add(RowBuilder<T>().apply(block).row)
} }
/** /**
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardRowBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardRowBuilder
*/ */
fun <T> MatrixBuilder<T>.row(vararg elements: T) { inline fun <T> MatrixBuilder<T>.row(vararg elements: T) {
add(elements.toList()) add(elements.toList())
} }
@@ -30,7 +30,7 @@ fun <T> MatrixBuilder<T>.row(vararg elements: T) {
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/ */
fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> { inline fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
return MatrixBuilder<T>().also(block).matrix return MatrixBuilder<T>().also(block).matrix
} }
@@ -38,7 +38,7 @@ fun <T> matrix(block: MatrixBuilder<T>.() -> Unit): Matrix<T> {
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/ */
fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> { inline fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
return MatrixBuilder<T>().apply { return MatrixBuilder<T>().apply {
row(block) row(block)
}.matrix }.matrix
@@ -48,7 +48,7 @@ fun <T> flatMatrix(block: RowBuilder<T>.() -> Unit): Matrix<T> {
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.InlineKeyboardBuilder
* @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder * @see dev.inmo.tgbotapi.extensions.utils.types.buttons.ReplyKeyboardBuilder
*/ */
fun <T> flatMatrix(vararg elements: T): Matrix<T> { inline fun <T> flatMatrix(vararg elements: T): Matrix<T> {
return MatrixBuilder<T>().apply { return MatrixBuilder<T>().apply {
row { elements.forEach { +it } } row { elements.forEach { +it } }
}.matrix }.matrix

View File

@@ -1,8 +1,8 @@
package dev.inmo.tgbotapi.types package dev.inmo.tgbotapi.types
import dev.inmo.tgbotapi.TestsJsonFormat import dev.inmo.tgbotapi.TestsJsonFormat
import dev.inmo.tgbotapi.extensions.utils.formatting.*
import dev.inmo.tgbotapi.types.message.textsources.TextSourceSerializer import dev.inmo.tgbotapi.types.message.textsources.TextSourceSerializer
import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.makeString import dev.inmo.tgbotapi.utils.extensions.makeString
import kotlinx.serialization.builtins.ListSerializer import kotlinx.serialization.builtins.ListSerializer
import kotlin.test.Test import kotlin.test.Test

View File

@@ -6,343 +6,384 @@ import dev.inmo.micro_utils.common.joinTo
import dev.inmo.tgbotapi.types.CustomEmojiId import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.textsources.* import dev.inmo.tgbotapi.types.message.textsources.*
import dev.inmo.tgbotapi.utils.EntitiesBuilderBody
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
typealias EntitiesBuilderBody = EntitiesBuilder.() -> Unit private const val ReplacedInCoreModuleReason = "Replaced in core module"
val newLine = regular("\n") private const val CoreModulePackage = "dev.inmo.tgbotapi.utils"
inline fun buildEntities(separator: TextSource? = null, init: EntitiesBuilderBody): TextSourcesList = EntitiesBuilder(separator).apply(init).build() @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilderBody", "$CoreModulePackage.EntitiesBuilderBody"))
inline fun buildEntities(separator: String, init: EntitiesBuilderBody) = buildEntities(regular(separator), init) 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] * This builder can be used to provide building of [TextSource]s [List]
* *
* @see buildEntities * @see buildEntities
*/ */
class EntitiesBuilder @RiskFeature constructor( @Deprecated(ReplacedInCoreModuleReason, ReplaceWith("EntitiesBuilder", "$CoreModulePackage.EntitiesBuilder"))
val separator: TextSource? = null typealias EntitiesBuilder = dev.inmo.tgbotapi.utils.EntitiesBuilder
) {
private val entitiesList: MutableTextSourcesList = mutableListOf()
/**
* It is not safe field which contains potentially changeable [List]
*/
val entities: TextSourcesList
get() = entitiesList
/**
* @return New immutable list which will be deattached from this builder
*/
fun build(): TextSourcesList = if (separator != null) entities.joinTo(separator) else entities.toList()
fun add(source: TextSource): EntitiesBuilder {
entitiesList.add(source)
return this
}
fun addAll(sources: Iterable<TextSource>): EntitiesBuilder {
entitiesList.addAll(sources)
return this
}
operator fun TextSource.unaryPlus() = add(this)
operator fun TextSourcesList.unaryPlus() = addAll(this)
operator fun invoke(vararg source: TextSource) = addAll(source.toList())
operator fun String.unaryPlus(): EntitiesBuilder {
add(dev.inmo.tgbotapi.types.message.textsources.regular(this))
return this@EntitiesBuilder
}
operator fun plus(text: String) = text.unaryPlus()
operator fun plus(source: TextSource) = add(source)
operator fun plus(sources: Iterable<TextSource>) = addAll(sources)
operator fun plus(other: EntitiesBuilder) = if (other == this) {
// do nothing; assume user is using something like regular("Hello, ") + bold("world") in buildEntities
this
} else {
addAll(other.entitiesList)
}
}
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * 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)) 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 * 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 inline fun EntitiesBuilder.boldln(parts: TextSourcesList) = bold(parts) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold]. * Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.bold(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.bold(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.bold] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("boldln(init)", "$CoreModulePackage.boldln"))
inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine inline fun EntitiesBuilder.boldln(noinline init: EntitiesBuilderBody) = bold(init) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * 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)) 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 * 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 inline fun EntitiesBuilder.boldln(vararg parts: TextSource) = bold(*parts) + newLine
/** /**
* Add bold using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.bold] * 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)) 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 * 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 inline fun EntitiesBuilder.boldln(text: String) = bold(text) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * 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)) 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 * 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 inline fun EntitiesBuilder.spoilerln(parts: TextSourcesList) = spoiler(parts) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler]. * Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.spoiler(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.spoiler(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.spoiler] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("spoilerln(init)", "$CoreModulePackage.spoilerln"))
inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine inline fun EntitiesBuilder.spoilerln(noinline init: EntitiesBuilderBody) = spoiler(init) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * 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)) 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 * 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 inline fun EntitiesBuilder.spoilerln(vararg parts: TextSource) = spoiler(*parts) + newLine
/** /**
* Add spoiler using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.spoiler] * 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)) 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 * 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 inline fun EntitiesBuilder.spoilerln(text: String) = spoiler(text) + newLine
/** /**
* Add botCommand using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.botCommand] * 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)) 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 * 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 inline fun EntitiesBuilder.botCommandln(command: String) = botCommand(command) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * 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)) 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 * 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 inline fun EntitiesBuilder.cashTagln(parts: TextSourcesList) = cashTag(parts) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag]. * Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.cashTag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.cashTag(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.cashTag] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("cashTagln(init)", "$CoreModulePackage.cashTagln"))
inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine inline fun EntitiesBuilder.cashTagln(noinline init: EntitiesBuilderBody) = cashTag(init) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * 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)) 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 * 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 inline fun EntitiesBuilder.cashTagln(vararg parts: TextSource) = cashTag(*parts) + newLine
/** /**
* Add cashTag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.cashTag] * 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)) 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 * 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 inline fun EntitiesBuilder.cashTagln(text: String) = cashTag(text) + newLine
/** /**
* Add code using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.code] * 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)) 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 * 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 inline fun EntitiesBuilder.codeln(code: String) = code(code) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * 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)) 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 * 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 inline fun EntitiesBuilder.emailln(parts: TextSourcesList) = email(parts) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email]. * Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.email(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.email(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.email] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("emailln(init)", "$CoreModulePackage.emailln"))
inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine inline fun EntitiesBuilder.emailln(noinline init: EntitiesBuilderBody) = email(init) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * 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)) 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 * 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 inline fun EntitiesBuilder.emailln(vararg parts: TextSource) = email(*parts) + newLine
/** /**
* Add email using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.email] * 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)) 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 * 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 inline fun EntitiesBuilder.emailln(emailAddress: String) = email(emailAddress) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * 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)) 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 * 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 inline fun EntitiesBuilder.hashtagln(parts: TextSourcesList) = hashtag(parts) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag]. * Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.hashtag(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.hashtag(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.hashtag] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("hashtagln(init)", "$CoreModulePackage.hashtagln"))
inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine inline fun EntitiesBuilder.hashtagln(noinline init: EntitiesBuilderBody) = hashtag(init) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * 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)) 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 * 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 inline fun EntitiesBuilder.hashtagln(vararg parts: TextSource) = hashtag(*parts) + newLine
/** /**
* Add hashtag using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.hashtag] * 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)) 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 * 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 inline fun EntitiesBuilder.hashtagln(hashtag: String) = hashtag(hashtag) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * 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)) 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 * 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 inline fun EntitiesBuilder.italicln(parts: TextSourcesList) = italic(parts) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic]. * Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.italic(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.italic(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.italic] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("italicln(init)", "$CoreModulePackage.italicln"))
inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine inline fun EntitiesBuilder.italicln(noinline init: EntitiesBuilderBody) = italic(init) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * 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)) 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 * 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 inline fun EntitiesBuilder.italicln(vararg parts: TextSource) = italic(*parts) + newLine
/** /**
* Add italic using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.italic] * 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)) 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 * 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 inline fun EntitiesBuilder.italicln(text: String) = italic(text) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * 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)) 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 * 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 inline fun EntitiesBuilder.mentionln(parts: TextSourcesList) = mention(parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention]. * Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.mention(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.mention(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.mention] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mentionln(init)", "$CoreModulePackage.mentionln"))
inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine inline fun EntitiesBuilder.mentionln(noinline init: EntitiesBuilderBody) = mention(init) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * 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)) 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 * 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 inline fun EntitiesBuilder.mentionln(vararg parts: TextSource) = mention(*parts) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * 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)) 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 * 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 inline fun EntitiesBuilder.mentionln(whoToMention: String) = mention(whoToMention) + newLine
/** /**
* Add mention using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.mention] * 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)) 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 * 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 inline fun EntitiesBuilder.mentionln(parts: TextSourcesList, user: User) = mention(parts) + newLine
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("mention(user, parts)", "$CoreModulePackage.mention"))
inline fun EntitiesBuilder.mention( inline fun EntitiesBuilder.mention(
user: User, user: User,
vararg parts: TextSource vararg parts: TextSource
@@ -350,60 +391,75 @@ inline fun EntitiesBuilder.mention(
/** /**
* Version of [EntitiesBuilder.mention] with new line at the end * 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 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] * 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)) 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 * 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 inline fun EntitiesBuilder.mentionln(text: String, user: User) = mention(text) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * 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)) 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 * 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 inline fun EntitiesBuilder.phoneln(parts: TextSourcesList) = phone(parts) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone]. * Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.phone(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.phone(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.phone] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("phoneln(init)", "$CoreModulePackage.phoneln"))
inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine inline fun EntitiesBuilder.phoneln(noinline init: EntitiesBuilderBody) = phone(init) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * 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)) 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 * 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 inline fun EntitiesBuilder.phoneln(vararg parts: TextSource) = phone(*parts) + newLine
/** /**
* Add phone using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.phone] * 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)) 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 * 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 inline fun EntitiesBuilder.phoneln(number: String) = phone(number) + newLine
/** /**
* Add pre using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.pre] * 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)) 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 * 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 inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) + newLine
/** /**
@@ -412,6 +468,7 @@ inline fun EntitiesBuilder.preln(code: String, language: String?) = pre(code) +
* @see RegularTextSource * @see RegularTextSource
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln * @see dev.inmo.tgbotapi.extensions.utils.formatting.regularln
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regular(text)", "$CoreModulePackage.regular"))
inline fun EntitiesBuilder.regular(text: String) = inline fun EntitiesBuilder.regular(text: String) =
add(dev.inmo.tgbotapi.types.message.textsources.regular(text)) add(dev.inmo.tgbotapi.types.message.textsources.regular(text))
/** /**
@@ -420,130 +477,163 @@ inline fun EntitiesBuilder.regular(text: String) =
* @see RegularTextSource * @see RegularTextSource
* @see dev.inmo.tgbotapi.extensions.utils.formatting.regular * @see dev.inmo.tgbotapi.extensions.utils.formatting.regular
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("regularln(text)", "$CoreModulePackage.regularln"))
inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine inline fun EntitiesBuilder.regularln(text: String) = regular(text) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * 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)) 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 * 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 inline fun EntitiesBuilder.strikethroughln(parts: TextSourcesList) = strikethrough(parts) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough]. * Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.strikethrough(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.strikethrough(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.strikethrough] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("strikethroughln(init)", "$CoreModulePackage.strikethroughln"))
inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine inline fun EntitiesBuilder.strikethroughln(noinline init: EntitiesBuilderBody) = strikethrough(init) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * 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)) 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 * 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 inline fun EntitiesBuilder.strikethroughln(vararg parts: TextSource) = strikethrough(*parts) + newLine
/** /**
* Add strikethrough using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.strikethrough] * 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)) 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 * 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 inline fun EntitiesBuilder.strikethroughln(text: String) = strikethrough(text) + newLine
/** /**
* Add link using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.link] * 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)) 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 * 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 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] * 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)) 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 * 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 inline fun EntitiesBuilder.linkln(url: String) = link(url) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * 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)) 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 * 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 inline fun EntitiesBuilder.underlineln(parts: TextSourcesList) = underline(parts) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline]. * Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline].
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
inline fun EntitiesBuilder.underline(noinline init: EntitiesBuilderBody) = add(dev.inmo.tgbotapi.types.message.textsources.underline(buildEntities(separator, init))) @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. * Version of [EntitiesBuilder.underline] with new line at the end.
* Will reuse separator config from [buildEntities] * Will reuse separator config from [buildEntities]
*/ */
@Deprecated(ReplacedInCoreModuleReason, ReplaceWith("underlineln(init)", "$CoreModulePackage.underlineln"))
inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine inline fun EntitiesBuilder.underlineln(noinline init: EntitiesBuilderBody) = underline(init) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * 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)) 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 * 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 inline fun EntitiesBuilder.underlineln(vararg parts: TextSource) = underline(*parts) + newLine
/** /**
* Add underline using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.underline] * 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)) 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 * 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 inline fun EntitiesBuilder.underlineln(text: String) = underline(text) + newLine
/** /**
* Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji] * 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)) 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 * 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 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]. * Add customEmoji using [EntitiesBuilder.add] with [dev.inmo.tgbotapi.types.message.textsources.customEmoji].
* Will reuse separator config from [buildEntities] * 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))) 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. * Version of [EntitiesBuilder.customEmoji] with new line at the end.
* Will reuse separator config from [buildEntities] * 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 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] * 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)) 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 * 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 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] * 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)) 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 * 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 inline fun EntitiesBuilder.customEmojiln(customEmojiId: CustomEmojiId, text: String) = customEmoji(customEmojiId, text) + newLine

View File

@@ -4,8 +4,7 @@ import dev.inmo.tgbotapi.types.LoginURL
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.* import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.types.webapps.WebAppInfo
import dev.inmo.tgbotapi.utils.MatrixBuilder import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.RowBuilder
/** /**
* Core DSL part of Inline Keyboard DSL. Can accept only [InlineKeyboardButton] and returns ready to use * Core DSL part of Inline Keyboard DSL. Can accept only [InlineKeyboardButton] and returns ready to use
@@ -15,12 +14,12 @@ import dev.inmo.tgbotapi.utils.RowBuilder
* @see InlineKeyboardBuilder.row * @see InlineKeyboardBuilder.row
* @see InlineKeyboardRowBuilder * @see InlineKeyboardRowBuilder
*/ */
class InlineKeyboardBuilder : MatrixBuilder<InlineKeyboardButton>() { typealias InlineKeyboardBuilder = MatrixBuilder<InlineKeyboardButton>
/**
* Creates [InlineKeyboardMarkup] using internal [matrix] /**
*/ * Creates [InlineKeyboardMarkup] using internal [matrix]
fun build() = InlineKeyboardMarkup(matrix) */
} fun InlineKeyboardBuilder.build() = InlineKeyboardMarkup(matrix)
/** /**
* Row builder of [InlineKeyboardBuilder] * Row builder of [InlineKeyboardBuilder]
@@ -28,7 +27,7 @@ class InlineKeyboardBuilder : MatrixBuilder<InlineKeyboardButton>() {
* @see inlineKeyboard * @see inlineKeyboard
* @see InlineKeyboardBuilder.row * @see InlineKeyboardBuilder.row
*/ */
class InlineKeyboardRowBuilder : RowBuilder<InlineKeyboardButton>() typealias InlineKeyboardRowBuilder = RowBuilder<InlineKeyboardButton>
/** /**
* Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup] * Factory-function for [InlineKeyboardBuilder]. It will [apply] [block] to internally created [InlineKeyboardMarkup]
@@ -48,7 +47,7 @@ inline fun inlineKeyboard(
*/ */
inline fun flatInlineKeyboard( inline fun flatInlineKeyboard(
block: InlineKeyboardRowBuilder.() -> Unit block: InlineKeyboardRowBuilder.() -> Unit
) = inlineKeyboard { row(block) } ) = inlineKeyboard { row<InlineKeyboardButton>(block) }
/** /**
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder * Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
@@ -61,6 +60,7 @@ inline fun flatInlineKeyboard(
* @see inlineQueryButton * @see inlineQueryButton
* @see urlButton * @see urlButton
*/ */
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
inline fun InlineKeyboardBuilder.row( inline fun InlineKeyboardBuilder.row(
block: InlineKeyboardRowBuilder.() -> Unit block: InlineKeyboardRowBuilder.() -> Unit
) = add(InlineKeyboardRowBuilder().apply(block).row) ) = add(InlineKeyboardRowBuilder().apply(block).row)

View File

@@ -2,8 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.types.buttons
import dev.inmo.tgbotapi.types.buttons.* import dev.inmo.tgbotapi.types.buttons.*
import dev.inmo.tgbotapi.types.webapps.WebAppInfo import dev.inmo.tgbotapi.types.webapps.WebAppInfo
import dev.inmo.tgbotapi.utils.MatrixBuilder import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.RowBuilder
/** /**
* Core DSL part of Keyboard DSL. Can accept only [KeyboardButton] and returns ready to use * Core DSL part of Keyboard DSL. Can accept only [KeyboardButton] and returns ready to use
@@ -13,17 +12,17 @@ import dev.inmo.tgbotapi.utils.RowBuilder
* @see ReplyKeyboardBuilder.row * @see ReplyKeyboardBuilder.row
* @see ReplyKeyboardRowBuilder * @see ReplyKeyboardRowBuilder
*/ */
class ReplyKeyboardBuilder : MatrixBuilder<KeyboardButton>() { typealias ReplyKeyboardBuilder = MatrixBuilder<KeyboardButton>
/**
* Creates [InlineKeyboardMarkup] using internal [matrix] /**
*/ * Creates [InlineKeyboardMarkup] using internal [matrix]
fun build( */
resizeKeyboard: Boolean? = null, fun ReplyKeyboardBuilder.build(
oneTimeKeyboard: Boolean? = null, resizeKeyboard: Boolean? = null,
inputFieldPlaceholder: String? = null, oneTimeKeyboard: Boolean? = null,
selective: Boolean? = null, inputFieldPlaceholder: String? = null,
) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) selective: Boolean? = null,
} ) = ReplyKeyboardMarkup(matrix, resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
/** /**
* Row builder of [KeyboardButton] * Row builder of [KeyboardButton]
@@ -31,7 +30,7 @@ class ReplyKeyboardBuilder : MatrixBuilder<KeyboardButton>() {
* @see replyKeyboard * @see replyKeyboard
* @see ReplyKeyboardBuilder.row * @see ReplyKeyboardBuilder.row
*/ */
class ReplyKeyboardRowBuilder : RowBuilder<KeyboardButton>() typealias ReplyKeyboardRowBuilder = RowBuilder<KeyboardButton>
/** /**
* Factory-function for [ReplyKeyboardBuilder]. It will [apply] [block] to internally created [ReplyKeyboardMarkup] * Factory-function for [ReplyKeyboardBuilder]. It will [apply] [block] to internally created [ReplyKeyboardMarkup]
@@ -58,7 +57,7 @@ inline fun flatReplyKeyboard(
selective: Boolean? = null, selective: Boolean? = null,
block: ReplyKeyboardRowBuilder.() -> Unit block: ReplyKeyboardRowBuilder.() -> Unit
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) { ) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
row(block) row<KeyboardButton>(block)
} }
/** /**
@@ -69,6 +68,7 @@ inline fun flatReplyKeyboard(
* @see requestLocationButton * @see requestLocationButton
* @see requestPollButton * @see requestPollButton
*/ */
@Deprecated("Redundant", ReplaceWith("this.row(block)", "dev.inmo.tgbotapi.utils.row"))
inline fun ReplyKeyboardBuilder.row( inline fun ReplyKeyboardBuilder.row(
block: ReplyKeyboardRowBuilder.() -> Unit block: ReplyKeyboardRowBuilder.() -> Unit
) = add(ReplyKeyboardRowBuilder().apply(block).row) ) = add(ReplyKeyboardRowBuilder().apply(block).row)

View File

@@ -0,0 +1,44 @@
package dev.inmo.tgbotapi.extensions.utils.updates
import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
/**
* A predicate to test whether a message contains any commands in its body.
* Use it as the `initialFilter` parameter in behaviour builder triggers.
* E.g.
*
* ```kotlin
* onContentMessage(
* initialFilter = CommonMessage<MessageContent>::hasCommands
* ) {
* // the message contains at least one command here
* }
* ```
*
* @return true if this [CommonMessage] contains any commands. False otherwise.
* @see hasNoCommands
*/
fun CommonMessage<*>.hasCommands(): Boolean = withContentOrNull<TextContent>() ?.content ?.textSources ?.any {
it is BotCommandTextSource
} ?: false
/**
* A predicate to test whether a message contains any commands in its body.
* Use it as the `initialFilter` parameter in behaviour builder triggers.
* E.g.
*
* ```kotlin
* onContentMessage(
* initialFilter = CommonMessage<MessageContent>::hasNoCommands
* ) {
* // the message contains no commands here
* }
* ```
*
* @return true if this [CommonMessage] does not contain any commands. False otherwise.
* @see hasCommands
*/
fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands()

View File

@@ -3,8 +3,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
import dev.inmo.micro_utils.coroutines.* import dev.inmo.micro_utils.coroutines.*
import dev.inmo.tgbotapi.bot.RequestsExecutor import dev.inmo.tgbotapi.bot.RequestsExecutor
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.bot.exceptions.GetUpdatesConflict import dev.inmo.tgbotapi.bot.exceptions.*
import dev.inmo.tgbotapi.bot.exceptions.RequestException
import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates import dev.inmo.tgbotapi.extensions.utils.updates.convertWithMediaGroupUpdates
import dev.inmo.tgbotapi.extensions.utils.updates.lastUpdateIdentifier import dev.inmo.tgbotapi.extensions.utils.updates.lastUpdateIdentifier
import dev.inmo.tgbotapi.requests.GetUpdates import dev.inmo.tgbotapi.requests.GetUpdates
@@ -101,10 +100,10 @@ fun TelegramBot.createAccumulatedUpdatesRetrieverFlow(
): Flow<Update> = longPollingFlow( ): Flow<Update> = longPollingFlow(
timeoutSeconds = 0, timeoutSeconds = 0,
exceptionsHandler = { exceptionsHandler = {
if (it is HttpRequestTimeoutException) { when {
throw CancellationException("Cancel due to absence of new updates") it is HttpRequestTimeoutException ||
} else { (it is CommonBotException && it.cause is HttpRequestTimeoutException) -> throw CancellationException("Cancel due to absence of new updates")
exceptionsHandler ?.invoke(it) else -> exceptionsHandler ?.invoke(it)
} }
}, },
allowedUpdates = allowedUpdates allowedUpdates = allowedUpdates