mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-25 23:55:48 +00:00
Compare commits
25 Commits
2.1.2
...
ca01ce7843
| Author | SHA1 | Date | |
|---|---|---|---|
| ca01ce7843 | |||
| 54fad3f338 | |||
| 15ef481fd7 | |||
| 91e1202674 | |||
| bdd39963a8 | |||
| 01dfedf540 | |||
| 8ded892b72 | |||
| d0b606469b | |||
| 678f79da04 | |||
| fde2c79f4c | |||
| acaf46e015 | |||
| 3f9237b5de | |||
| 3d7334dd62 | |||
| 26306f1567 | |||
| 247553d990 | |||
| 049a8a3263 | |||
| cc67a31e97 | |||
| 8791573145 | |||
| 5752f7a4fb | |||
| ade236eaa3 | |||
| e7340a483a | |||
| c7dc69d09f | |||
| c2487c5adc | |||
| 7c4808f163 | |||
| b91b516659 |
36
CHANGELOG.md
36
CHANGELOG.md
@@ -1,11 +1,41 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 2.2.0
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* For `CopyMessage` order of parameters has been changed
|
||||||
|
* `ReplyForce` defaults changes:
|
||||||
|
* All old companion properties (like `ReplyForce.ReplyForceSelective`) have been renamed:
|
||||||
|
* `ReplyForceSelective` -> `Selective`
|
||||||
|
* `ReplyForceNonSelective` -> `NonSelective`
|
||||||
|
* `ReplyForceDefault` -> `Default`
|
||||||
|
* New companion functions:
|
||||||
|
* `ReplyForce#Selective`
|
||||||
|
* `ReplyForce#NonSelective`
|
||||||
|
* Rename `CreatorChatMember` -> `OwnerChatMember`
|
||||||
|
* `API`:
|
||||||
|
* For `copyMessage` order of parameters has been changed
|
||||||
|
* `Utils`:
|
||||||
|
* New extension `Message#sameChat`
|
||||||
|
* New extension `Message#sameMessage`
|
||||||
|
* New functions `flatInlineKeyboard` and `flatReplyKeyboard`
|
||||||
|
* Experimentally add new triple of class casts: `if*`, `*OrNull` and `*OrThrow`
|
||||||
|
|
||||||
|
## 2.1.3
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils`: `0.11.9` -> `0.11.12`
|
||||||
|
* `Utils`:
|
||||||
|
* Rename `UserId` extension `link` to `userLink`
|
||||||
|
* `Core`
|
||||||
|
* `ChatJoinRequest#inviteLink` is nullable due to the fact that join requests without link do not require invite link
|
||||||
|
|
||||||
## 2.1.2
|
## 2.1.2
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
* `Coroutines`: `1.6.1` -> `1.6.3`
|
* `Coroutines`: `1.6.1` -> `1.6.3`
|
||||||
* `Ktor`: `2.0.2` -> `2.0.3`
|
* `Ktor`: `2.0.2` -> `2.0.3`
|
||||||
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
* `MicroUtils`: `0.11.6` -> `0.11.9`
|
||||||
|
|
||||||
## 2.1.1
|
## 2.1.1
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
| [](https://github.com/KotlinBy/awesome-kotlin) [](https://github.com/InsanusMokrassar/TelegramBotAPI/actions) [](https://docs.google.com/forms/d/e/1FAIpQLSctdJHT_aEniyYT0-IUAEfo1hsIlezX2owlkEAYX4KPl2V2_A/viewform?usp=sf_link) [](https://t.me/InMoTelegramBotAPI) |
|
||||||
|:---:|
|
|:---:|
|
||||||
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
| [](https://github.com/InsanusMokrassar/TelegramBotAPI-bot_template/generate) [](https://github.com/InsanusMokrassar/TelegramBotAPI-examples/) [](https://tgbotapi.inmo.dev/index.html) [](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|
||||||
|
| [](https://t.me/InMoTelegramBotAPI) |
|
||||||
|
|
||||||
Hello! This is a set of libraries for working with Telegram Bot API.
|
Hello! This is a set of libraries for working with Telegram Bot API.
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ if (new File(projectDir, "secret.gradle").exists()) {
|
|||||||
owner "InsanusMokrassar"
|
owner "InsanusMokrassar"
|
||||||
repo "TelegramBotAPI"
|
repo "TelegramBotAPI"
|
||||||
|
|
||||||
tagName "$library_version"
|
tagName "v$library_version"
|
||||||
releaseName "$library_version"
|
releaseName "$library_version"
|
||||||
targetCommitish "$library_version"
|
targetCommitish "$library_version"
|
||||||
|
|
||||||
|
|||||||
@@ -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=2.1.2
|
library_version=2.2.0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ korlibs = "2.7.0"
|
|||||||
uuid = "0.4.1"
|
uuid = "0.4.1"
|
||||||
ktor = "2.0.3"
|
ktor = "2.0.3"
|
||||||
|
|
||||||
microutils = "0.11.9"
|
microutils = "0.11.12"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
|
|
||||||
|
|||||||
BIN
resources/tg_channel_qr.jpg
Normal file
BIN
resources/tg_channel_qr.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 593 KiB |
@@ -16,8 +16,8 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -26,7 +26,18 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
CopyMessage(fromChatId, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,8 +46,8 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChat: Chat,
|
fromChat: Chat,
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -44,7 +55,7 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, 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
|
||||||
@@ -52,8 +63,8 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -61,7 +72,7 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, 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
|
||||||
@@ -69,40 +80,8 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChat: Chat,
|
fromChat: Chat,
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
message: Message,
|
|
||||||
text: String? = null,
|
|
||||||
parseMode: ParseMode? = null,
|
|
||||||
disableNotification: Boolean = false,
|
|
||||||
protectContent: Boolean = false,
|
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
|
||||||
replyMarkup: KeyboardMarkup? = null
|
|
||||||
) = copyMessage(message.chat, toChatId, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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
|
|
||||||
*/
|
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
|
||||||
toChat: Chat,
|
toChat: Chat,
|
||||||
message: Message,
|
|
||||||
text: String? = null,
|
text: String? = null,
|
||||||
parseMode: ParseMode? = null,
|
parseMode: ParseMode? = null,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
@@ -110,7 +89,7 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(message.chat, toChat, message.messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -119,8 +98,8 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
@@ -128,7 +107,17 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = execute(
|
) = execute(
|
||||||
CopyMessage(fromChatId, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,15 +126,15 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChat: Chat,
|
fromChat: Chat,
|
||||||
toChatId: ChatIdentifier,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChat.id, messageId, toChatId, entities, 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
|
||||||
@@ -153,15 +142,15 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChatId, messageId, toChat.id, entities, 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
|
||||||
@@ -169,15 +158,47 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
*/
|
*/
|
||||||
suspend inline fun TelegramBot.copyMessage(
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
fromChat: Chat,
|
fromChat: Chat,
|
||||||
toChat: Chat,
|
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
entities: TextSourcesList,
|
entities: TextSourcesList,
|
||||||
disableNotification: Boolean = false,
|
disableNotification: Boolean = false,
|
||||||
protectContent: Boolean = false,
|
protectContent: Boolean = false,
|
||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(fromChat.id, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
message: Message,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
toChat: Chat,
|
||||||
|
message: Message,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, 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
|
||||||
@@ -192,7 +213,7 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(message.chat, toChatId, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(message.chat, message.messageId, toChatId, entities, 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
|
||||||
@@ -207,4 +228,4 @@ suspend inline fun TelegramBot.copyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = copyMessage(message.chat, toChat, message.messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|||||||
@@ -0,0 +1,180 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.send
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
||||||
|
import dev.inmo.tgbotapi.requests.send.OrderChangingDeprecationWarn
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
// TODO:: Swap fromChatId and toChatId for more correct order of parameters
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChat.id, toChatId, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChatId, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChat.id, toChat.id, messageId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
CopyMessage(
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
toChatId,
|
||||||
|
entities,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChat.id, toChatId, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChatId, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
|
suspend inline fun TelegramBot.copyMessage(
|
||||||
|
fromChat: Chat,
|
||||||
|
toChat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
entities: TextSourcesList,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = copyMessage(fromChat.id, toChat.id, messageId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
||||||
@@ -16,6 +16,11 @@ import dev.inmo.tgbotapi.types.message.toRawMessageEntities
|
|||||||
import dev.inmo.tgbotapi.utils.extensions.makeString
|
import dev.inmo.tgbotapi.utils.extensions.makeString
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
|
// TODO:: Swap fromChatId and toChatId for more correct order of parameters
|
||||||
|
|
||||||
|
const val OrderChangingDeprecationWarn = "The order of parameters in this factory will be changed soon. To avoid unexpected behaviour, swap message id and target chat id parameters"
|
||||||
|
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChatId: ChatIdentifier,
|
toChatId: ChatIdentifier,
|
||||||
@@ -27,8 +32,21 @@ fun CopyMessage(
|
|||||||
replyToMessageId: MessageIdentifier? = null,
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = CopyMessage(fromChatId, toChatId, messageId, text, parseMode, null, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
|
) = CopyMessage(
|
||||||
|
toChatId,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
null,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
@Deprecated(OrderChangingDeprecationWarn)
|
||||||
fun CopyMessage(
|
fun CopyMessage(
|
||||||
fromChatId: ChatIdentifier,
|
fromChatId: ChatIdentifier,
|
||||||
toChatId: ChatIdentifier,
|
toChatId: ChatIdentifier,
|
||||||
@@ -40,8 +58,57 @@ fun CopyMessage(
|
|||||||
allowSendingWithoutReply: Boolean? = null,
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
replyMarkup: KeyboardMarkup? = null
|
replyMarkup: KeyboardMarkup? = null
|
||||||
) = CopyMessage(
|
) = CopyMessage(
|
||||||
fromChatId,
|
|
||||||
toChatId,
|
toChatId,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
entities.makeString(),
|
||||||
|
null,
|
||||||
|
entities.toRawMessageEntities(),
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CopyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
text: String? = null,
|
||||||
|
parseMode: ParseMode? = null,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = CopyMessage(
|
||||||
|
toChatId,
|
||||||
|
fromChatId,
|
||||||
|
messageId,
|
||||||
|
text,
|
||||||
|
parseMode,
|
||||||
|
null,
|
||||||
|
disableNotification,
|
||||||
|
protectContent,
|
||||||
|
replyToMessageId,
|
||||||
|
allowSendingWithoutReply,
|
||||||
|
replyMarkup
|
||||||
|
)
|
||||||
|
|
||||||
|
fun CopyMessage(
|
||||||
|
fromChatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
toChatId: ChatIdentifier,
|
||||||
|
entities: List<TextSource>,
|
||||||
|
disableNotification: Boolean = false,
|
||||||
|
protectContent: Boolean = false,
|
||||||
|
replyToMessageId: MessageIdentifier? = null,
|
||||||
|
allowSendingWithoutReply: Boolean? = null,
|
||||||
|
replyMarkup: KeyboardMarkup? = null
|
||||||
|
) = CopyMessage(
|
||||||
|
toChatId,
|
||||||
|
fromChatId,
|
||||||
messageId,
|
messageId,
|
||||||
entities.makeString(),
|
entities.makeString(),
|
||||||
null,
|
null,
|
||||||
@@ -55,10 +122,10 @@ fun CopyMessage(
|
|||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CopyMessage internal constructor(
|
data class CopyMessage internal constructor(
|
||||||
@SerialName(fromChatIdField)
|
|
||||||
val fromChatId: ChatIdentifier,
|
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
val toChatId: ChatIdentifier,
|
val toChatId: ChatIdentifier,
|
||||||
|
@SerialName(fromChatIdField)
|
||||||
|
val fromChatId: ChatIdentifier,
|
||||||
@SerialName(messageIdField)
|
@SerialName(messageIdField)
|
||||||
override val messageId: MessageIdentifier,
|
override val messageId: MessageIdentifier,
|
||||||
@SerialName(captionField)
|
@SerialName(captionField)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import kotlinx.serialization.encoding.Encoder
|
|||||||
import kotlinx.serialization.json.JsonPrimitive
|
import kotlinx.serialization.json.JsonPrimitive
|
||||||
import kotlinx.serialization.json.longOrNull
|
import kotlinx.serialization.json.longOrNull
|
||||||
|
|
||||||
|
const val internalLinkBeginning = "https://t.me"
|
||||||
|
|
||||||
@Serializable(ChatIdentifierSerializer::class)
|
@Serializable(ChatIdentifierSerializer::class)
|
||||||
sealed class ChatIdentifier
|
sealed class ChatIdentifier
|
||||||
|
|
||||||
@@ -26,16 +28,29 @@ data class ChatId(
|
|||||||
* https://core.telegram.org/bots/api#formatting-options
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
*/
|
*/
|
||||||
@Warning("This API have restrictions in Telegram System")
|
@Warning("This API have restrictions in Telegram System")
|
||||||
val Identifier.link: String
|
val Identifier.userLink: String
|
||||||
get() = "tg://user?id=$this"
|
get() = "tg://user?id=$this"
|
||||||
/**
|
/**
|
||||||
* https://core.telegram.org/bots/api#formatting-options
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
*/
|
*/
|
||||||
@Warning("This API have restrictions in Telegram System")
|
@Warning("This API have restrictions in Telegram System")
|
||||||
val UserId.link: String
|
val UserId.userLink: String
|
||||||
get() = chatId.link
|
get() = chatId.userLink
|
||||||
val User.link: String
|
val User.link: String
|
||||||
get() = id.link
|
get() = id.userLink
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||||
|
val Identifier.link: String
|
||||||
|
get() = "tg://user?id=$this"
|
||||||
|
/**
|
||||||
|
* https://core.telegram.org/bots/api#formatting-options
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("userLink", "dev.inmo.tgbotapi.types.userLink"))
|
||||||
|
val ChatId.link: String
|
||||||
|
get() = chatId.link
|
||||||
|
|
||||||
typealias UserId = ChatId
|
typealias UserId = ChatId
|
||||||
|
|
||||||
|
|||||||
@@ -415,6 +415,7 @@ const val mediaField = "media"
|
|||||||
const val disableEditMessageField = "disable_edit_message"
|
const val disableEditMessageField = "disable_edit_message"
|
||||||
const val scoreField = "score"
|
const val scoreField = "score"
|
||||||
const val forceField = "force"
|
const val forceField = "force"
|
||||||
|
const val forceReplyField = "force_reply"
|
||||||
|
|
||||||
const val regularPollType = "regular"
|
const val regularPollType = "regular"
|
||||||
const val quizPollType = "quiz"
|
const val quizPollType = "quiz"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.types.buttons
|
package dev.inmo.tgbotapi.types.buttons
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.inputFieldPlaceholderField
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.inputFieldPlaceholderLimit
|
|
||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
@@ -10,13 +9,24 @@ data class ReplyForce(
|
|||||||
@SerialName(inputFieldPlaceholderField)
|
@SerialName(inputFieldPlaceholderField)
|
||||||
val inputFieldPlaceholder: String? = null
|
val inputFieldPlaceholder: String? = null
|
||||||
) : KeyboardMarkup {
|
) : KeyboardMarkup {
|
||||||
@SerialName("force_reply")
|
@SerialName(forceReplyField)
|
||||||
@Required
|
@Required
|
||||||
val forceReply: Boolean = true
|
val forceReply: Boolean = true
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val ReplyForceSelective = ReplyForce(true)
|
fun Selective(inputFieldPlaceholder: String? = null) = ReplyForce(true, inputFieldPlaceholder)
|
||||||
val ReplyForceNonSelective = ReplyForce(false)
|
fun NonSelective(inputFieldPlaceholder: String? = null) = ReplyForce(false, inputFieldPlaceholder)
|
||||||
|
val Selective = Selective()
|
||||||
|
val NonSelective = NonSelective()
|
||||||
|
val Default = ReplyForce()
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("ReplyForce.Selective"))
|
||||||
|
inline val ReplyForceSelective
|
||||||
|
get() = Selective
|
||||||
|
@Deprecated("Renamed", ReplaceWith("ReplyForce.NonSelective"))
|
||||||
|
inline val ReplyForceNonSelective
|
||||||
|
get() = NonSelective
|
||||||
|
@Deprecated("Renamed", ReplaceWith("ReplyForce.Default"))
|
||||||
val ReplyForceDefault = ReplyForce()
|
val ReplyForceDefault = ReplyForce()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ data class ChatJoinRequest(
|
|||||||
@SerialName(dateField)
|
@SerialName(dateField)
|
||||||
val date: TelegramDate,
|
val date: TelegramDate,
|
||||||
@SerialName(inviteLinkField)
|
@SerialName(inviteLinkField)
|
||||||
val inviteLink: ChatInviteLink,
|
val inviteLink: ChatInviteLink? = null,
|
||||||
@SerialName(bioField)
|
@SerialName(bioField)
|
||||||
val bio: String? = null
|
val bio: String? = null
|
||||||
) : FromUser {
|
) : FromUser {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
|||||||
override fun deserialize(decoder: Decoder): ChatMember {
|
override fun deserialize(decoder: Decoder): ChatMember {
|
||||||
val json = JsonObject.serializer().deserialize(decoder)
|
val json = JsonObject.serializer().deserialize(decoder)
|
||||||
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
|
return when (json[statusField] ?.jsonPrimitive ?.content ?: error("Status field of chat member must be specified, but incoming json contains next: $json")) {
|
||||||
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(CreatorChatMember.serializer(), json)
|
"creator" -> nonstrictJsonFormat.decodeFromJsonElement(OwnerChatMember.serializer(), json)
|
||||||
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
|
"administrator" -> nonstrictJsonFormat.decodeFromJsonElement(AdministratorChatMemberImpl.serializer(), json)
|
||||||
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
|
"member" -> nonstrictJsonFormat.decodeFromJsonElement(MemberChatMemberImpl.serializer(), json)
|
||||||
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
|
"restricted" -> nonstrictJsonFormat.decodeFromJsonElement(RestrictedChatMember.serializer(), json)
|
||||||
@@ -34,7 +34,7 @@ object ChatMemberSerializer : KSerializer<ChatMember> {
|
|||||||
|
|
||||||
override fun serialize(encoder: Encoder, value: ChatMember) {
|
override fun serialize(encoder: Encoder, value: ChatMember) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is CreatorChatMember -> CreatorChatMember.serializer()
|
is OwnerChatMember -> OwnerChatMember.serializer()
|
||||||
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
|
is AdministratorChatMemberImpl -> AdministratorChatMemberImpl.serializer()
|
||||||
is MemberChatMember -> MemberChatMemberImpl.serializer()
|
is MemberChatMember -> MemberChatMemberImpl.serializer()
|
||||||
is RestrictedChatMember -> RestrictedChatMember.serializer()
|
is RestrictedChatMember -> RestrictedChatMember.serializer()
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.types.chat.User
|
|||||||
import kotlinx.serialization.*
|
import kotlinx.serialization.*
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
data class CreatorChatMember(
|
data class OwnerChatMember(
|
||||||
override val user: User,
|
override val user: User,
|
||||||
@SerialName(isAnonymousField)
|
@SerialName(isAnonymousField)
|
||||||
override val isAnonymous: Boolean = false,
|
override val isAnonymous: Boolean = false,
|
||||||
@@ -38,3 +38,6 @@ data class CreatorChatMember(
|
|||||||
@Required
|
@Required
|
||||||
private val type: String = "creator"
|
private val type: String = "creator"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("OwnerChatMember", "dev.inmo.tgbotapi.types.chat.member.OwnerChatMember"))
|
||||||
|
typealias CreatorChatMember = OwnerChatMember
|
||||||
@@ -28,7 +28,7 @@ class ChatIdentifierTests {
|
|||||||
@Test
|
@Test
|
||||||
fun `Creating_link_from_ChatId_is_correct`() {
|
fun `Creating_link_from_ChatId_is_correct`() {
|
||||||
val chatId = chatIdentifierChatId.toChatId()
|
val chatId = chatIdentifierChatId.toChatId()
|
||||||
assertEquals(chatIdentifierLink, chatId.link)
|
assertEquals(chatIdentifierLink, chatId.userLink)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -1828,14 +1828,26 @@ inline fun InlineQueryResult.requireInlineQueryResultVoiceCommon(): InlineQueryR
|
|||||||
this as InlineQueryResultVoiceCommon
|
this as InlineQueryResultVoiceCommon
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
|
@Deprecated("Renamed", ReplaceWith("whenOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.whenOwnerChatMember"))
|
||||||
inline fun <T> ChatMember.whenCreatorChatMember(block: (CreatorChatMember) -> T) = asCreatorChatMember() ?.let(block)
|
inline fun <T> ChatMember.whenCreatorChatMember(block: (CreatorChatMember) -> T) = asCreatorChatMember() ?.let(block)
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
|
@Deprecated("Renamed", ReplaceWith("asOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.asOwnerChatMember"))
|
||||||
inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember
|
inline fun ChatMember.asCreatorChatMember(): CreatorChatMember? = this as? CreatorChatMember
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
|
@Deprecated("Renamed", ReplaceWith("requireOwnerChatMember", "dev.inmo.tgbotapi.extensions.utils.requireOwnerChatMember"))
|
||||||
inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember
|
inline fun ChatMember.requireCreatorChatMember(): CreatorChatMember = this as CreatorChatMember
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun <T> ChatMember.whenOwnerChatMember(block: (OwnerChatMember) -> T) = asOwnerChatMember() ?.let(block)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun ChatMember.asOwnerChatMember(): OwnerChatMember? = this as? OwnerChatMember
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
inline fun ChatMember.requireOwnerChatMember(): OwnerChatMember = this as OwnerChatMember
|
||||||
|
|
||||||
@PreviewFeature
|
@PreviewFeature
|
||||||
inline fun <T> ChatMember.whenKickedChatMember(block: (KickedChatMember) -> T) = asKickedChatMember() ?.let(block)
|
inline fun <T> ChatMember.whenKickedChatMember(block: (KickedChatMember) -> T) = asKickedChatMember() ?.let(block)
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,16 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.utils.extensions
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is placed in the same chat that [other]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameChat(other: Message) = chat.id == other.chat.id
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat
|
||||||
|
* and have equal [Message.messageId] identifier
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun Message.sameMessage(other: Message) = sameChat(other) && messageId == other.messageId
|
||||||
@@ -5,5 +5,5 @@ import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
|||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
|
|
||||||
@RiskFeature(RawFieldsUsageWarning)
|
@RiskFeature(RawFieldsUsageWarning)
|
||||||
val ChatJoinRequest.invite_link: ChatInviteLink
|
val ChatJoinRequest.invite_link: ChatInviteLink?
|
||||||
get() = inviteLink
|
get() = inviteLink
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import dev.inmo.tgbotapi.types.message.textsources.link
|
|||||||
import dev.inmo.tgbotapi.types.chat.*
|
import dev.inmo.tgbotapi.types.chat.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
private const val internalLinkBeginning = "https://t.me"
|
|
||||||
|
|
||||||
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
|
fun makeUsernameLink(username: String) = "$internalLinkBeginning/$username"
|
||||||
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
fun makeUsernameDeepLinkPrefix(username: String) = "${makeUsernameLink(username)}?start="
|
||||||
inline val Username.link
|
inline val Username.link
|
||||||
@@ -73,7 +71,7 @@ val Message.link: String?
|
|||||||
val Chat.link: String?
|
val Chat.link: String?
|
||||||
get() {
|
get() {
|
||||||
if (this is UsernameChat) {
|
if (this is UsernameChat) {
|
||||||
username ?.username ?.let { return it }
|
username ?.link
|
||||||
}
|
}
|
||||||
if (this is ExtendedPublicChat) {
|
if (this is ExtendedPublicChat) {
|
||||||
inviteLink ?.let { return it }
|
inviteLink ?.let { return it }
|
||||||
|
|||||||
@@ -40,6 +40,16 @@ inline fun inlineKeyboard(
|
|||||||
block: InlineKeyboardBuilder.() -> Unit
|
block: InlineKeyboardBuilder.() -> Unit
|
||||||
) = InlineKeyboardBuilder().apply(block).build()
|
) = InlineKeyboardBuilder().apply(block).build()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory-function for [InlineKeyboardBuilder], but in difference with [inlineKeyboard] this function will create single-row
|
||||||
|
* inline keyboard
|
||||||
|
*
|
||||||
|
* @see InlineKeyboardBuilder.row
|
||||||
|
*/
|
||||||
|
inline fun flatInlineKeyboard(
|
||||||
|
block: InlineKeyboardRowBuilder.() -> Unit
|
||||||
|
) = inlineKeyboard { row(block) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
* Creates an [InlineKeyboardRowBuilder] and [apply] [block] with this builder
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -47,6 +47,20 @@ inline fun replyKeyboard(
|
|||||||
block: ReplyKeyboardBuilder.() -> Unit
|
block: ReplyKeyboardBuilder.() -> Unit
|
||||||
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
|
) = ReplyKeyboardBuilder().apply(block).build(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory-function for [ReplyKeyboardBuilder], but in difference with [replyKeyboard] this method will create single-row
|
||||||
|
* keyboard
|
||||||
|
*/
|
||||||
|
inline fun flatReplyKeyboard(
|
||||||
|
resizeKeyboard: Boolean? = null,
|
||||||
|
oneTimeKeyboard: Boolean? = null,
|
||||||
|
inputFieldPlaceholder: String? = null,
|
||||||
|
selective: Boolean? = null,
|
||||||
|
block: ReplyKeyboardRowBuilder.() -> Unit
|
||||||
|
) = replyKeyboard(resizeKeyboard, oneTimeKeyboard, inputFieldPlaceholder, selective) {
|
||||||
|
row(block)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder
|
* Creates an [ReplyKeyboardRowBuilder] and [apply] [block] with this builder
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user