1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

Merge pull request #675 from InsanusMokrassar/4.0.0

4.0.0
This commit is contained in:
InsanusMokrassar 2022-11-09 00:14:48 +06:00 committed by GitHub
commit 46fdbc02e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
181 changed files with 3219 additions and 1723 deletions

View File

@ -1,5 +1,20 @@
# TelegramBotAPI changelog
## 4.0.0
**!!! THIS UPDATE CONTAINS FULL REWORK OF MEDIA GROUPS FUNCTIONALITY !!!**
**THIS UPDATE CONTAINS BREAKING CHANGES**
* `Common`:
* All the media groups have been rewritten. Since this update, there are no separated messages types for media groups,
but new type of content (`MediaGroupContent`) has been introduced
* [Bot API 6.3](https://core.telegram.org/bots/api-changelog#november-5-2022) support
* `Versions`:
* `MicroUtils`: `0.13.2` -> `0.14.0`
* `Core`:
* New requests
## 3.3.1
* `Versions`:

View File

@ -1,4 +1,4 @@
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.2-blue)](https://core.telegram.org/bots/api-changelog#august-12-2022)
# TelegramBotAPI [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/tgbotapi) [![Supported version](https://img.shields.io/badge/Telegram%20Bot%20API-6.3-blue)](https://core.telegram.org/bots/api-changelog#november-5-2022)
| Docs | [![KDocs](https://img.shields.io/static/v1?label=Dokka&message=KDocs&color=blue&logo=kotlin)](https://tgbotapi.inmo.dev/index.html) [![Mini tutorial](https://img.shields.io/static/v1?label=Bookstack&message=Tutorial&color=blue&logo=bookstack)](https://bookstack.inmo.dev/books/telegrambotapi/chapter/introduction-tutorial) |
|:---:|:---:|

View File

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

View File

@ -13,7 +13,7 @@ ktor = "2.1.3"
ksp = "1.7.20-1.0.8"
kotlin-poet = "1.12.0"
microutils = "0.13.2"
microutils = "0.14.0"
github-release-plugin = "2.4.1"

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.ForwardMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message
@ -11,46 +12,52 @@ suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = execute(
ForwardMessage(fromChatId, toChatId, messageId, disableNotification, protectContent)
ForwardMessage(fromChatId, toChatId, messageId, threadId, disableNotification, protectContent)
)
suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChatId: ChatIdentifier,
messageId: MessageId,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChat.id, toChatId, messageId, disableNotification, protectContent)
) = forwardMessage(fromChat.id, toChatId, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
fromChatId: ChatIdentifier,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChatId, toChat.id, messageId, disableNotification, protectContent)
) = forwardMessage(fromChatId, toChat.id, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
fromChat: Chat,
toChat: Chat,
messageId: MessageId,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(fromChat.id, toChat.id, messageId, disableNotification, protectContent)
) = forwardMessage(fromChat.id, toChat.id, messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier,
message: Message,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(message.chat, toChatId, message.messageId, disableNotification, protectContent)
) = forwardMessage(message.chat, toChatId, message.messageId, threadId, disableNotification, protectContent)
suspend fun TelegramBot.forwardMessage(
toChat: Chat,
message: Message,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false
) = forwardMessage(message.chat, toChat, message.messageId, disableNotification, protectContent)
) = forwardMessage(message.chat, toChat, message.messageId, threadId, disableNotification, protectContent)

View File

@ -1,70 +1,57 @@
package dev.inmo.tgbotapi.extensions.api.InternalUtils
import dev.inmo.tgbotapi.types.MediaGroupIdentifier
import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.update.*
import dev.inmo.tgbotapi.types.update.abstracts.*
import dev.inmo.tgbotapi.types.update.media_group.*
internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
return if (this is SentMediaGroupUpdate) {
origins.last().updateId
} else {
updateId
}
}
internal fun List<Update>.lastUpdateIdentifier(): UpdateIdentifier? {
return maxByOrNull { it.updateId } ?.lastUpdateIdentifier()
}
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
/**
* Will convert incoming list of updates to list with [MediaGroupUpdate]s
*/
internal fun List<Update>.convertWithMediaGroupUpdates(): List<Update> {
val resultUpdates = mutableListOf<Update>()
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<BaseSentMessageUpdate>>()
val mediaGroups = mutableMapOf<MediaGroupIdentifier, MutableList<Pair<BaseSentMessageUpdate, PossiblySentViaBotCommonMessage<MediaGroupPartContent>>>>()
for (update in this) {
val data = (update.data as? MediaGroupMessage<*>)
if (data == null) {
val message = (update.data as? PossiblySentViaBotCommonMessage<*>) ?.let {
if (it.content is MediaGroupPartContent) {
it as PossiblySentViaBotCommonMessage<MediaGroupPartContent>
} else {
null
}
}
val mediaGroupId = message ?.mediaGroupId
if (message == null || mediaGroupId == null) {
resultUpdates.add(update)
continue
}
when (update) {
is BaseEditMessageUpdate -> resultUpdates.add(
update.toEditMediaGroupUpdate()
)
is BaseSentMessageUpdate -> {
mediaGroups.getOrPut(data.mediaGroupId) {
mediaGroups.getOrPut(mediaGroupId) {
mutableListOf()
}.add(update)
}.add(update to message)
}
else -> resultUpdates.add(update)
}
}
mediaGroups.values.map {
it.toSentMediaGroupUpdate() ?.let { mediaGroupUpdate ->
resultUpdates.add(mediaGroupUpdate)
}
mediaGroups.map { (_, updatesWithMessages) ->
val update = updatesWithMessages.maxBy { it.first.updateId }.first
resultUpdates.add(
update.copy(updatesWithMessages.map { it.second }.asMediaGroupMessage())
)
}
resultUpdates.sortBy { it.updateId }
return resultUpdates
}
internal fun List<BaseSentMessageUpdate>.toSentMediaGroupUpdate(): SentMediaGroupUpdate? = (this as? SentMediaGroupUpdate) ?: let {
if (isEmpty()) {
return@let null
}
val resultList = sortedBy { it.updateId }
when (first()) {
is MessageUpdate -> MessageMediaGroupUpdate(resultList)
is ChannelPostUpdate -> ChannelPostMediaGroupUpdate(resultList)
else -> null
}
}
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate(): EditMediaGroupUpdate = (this as? EditMediaGroupUpdate) ?: let {
when (this) {
is EditMessageUpdate -> EditMessageMediaGroupUpdate(this)
is EditChannelPostUpdate -> EditChannelPostMediaGroupUpdate(this)
else -> error("Unsupported type of ${BaseEditMessageUpdate::class.simpleName}")
}
}
/**
* @return [EditMessageMediaGroupUpdate] in case if [this] is [EditMessageUpdate]. When [this] object is
* [EditChannelPostUpdate] instance - will return [EditChannelPostMediaGroupUpdate]
*
* @throws IllegalStateException
*/
internal fun BaseEditMessageUpdate.toEditMediaGroupUpdate() = this

View File

@ -5,7 +5,9 @@ import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.abstracts.*
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.edit.edit
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
@ -39,6 +41,7 @@ suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -56,7 +59,7 @@ suspend fun TelegramBot.handleLiveLocation(
val capturedLiveLocationMessage = currentLiveLocationMessage
if (capturedLiveLocationMessage == null) {
updateMessageJob.start()
currentLiveLocationMessage = sendLiveLocation(
currentLiveLocationMessage = send(
chatId,
it.latitude,
it.longitude,
@ -64,6 +67,7 @@ suspend fun TelegramBot.handleLiveLocation(
it.horizontalAccuracy,
it.heading,
it.proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -71,7 +75,7 @@ suspend fun TelegramBot.handleLiveLocation(
it.replyMarkup
)
} else {
editLiveLocation(
edit(
capturedLiveLocationMessage,
it.latitude,
it.longitude,
@ -94,6 +98,7 @@ suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -112,6 +117,7 @@ suspend fun TelegramBot.handleLiveLocation(
)
},
liveTimeMillis,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -129,6 +135,7 @@ suspend fun TelegramBot.handleLiveLocation(
chatId: ChatIdentifier,
locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -143,6 +150,7 @@ suspend fun TelegramBot.handleLiveLocation(
)
},
liveTimeMillis,
threadId,
disableNotification,
protectContent,
replyToMessageId,

View File

@ -90,6 +90,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -106,6 +107,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -135,6 +137,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -149,6 +152,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -168,6 +172,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -182,6 +187,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -201,6 +207,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -215,6 +222,7 @@ suspend fun TelegramBot.startLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -235,6 +243,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -248,6 +257,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
to.messageId,
@ -267,6 +277,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
initHorizontalAccuracy: Meters? = null,
initHeading: Degrees? = null,
initProximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -279,6 +290,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
initHorizontalAccuracy,
initHeading,
initProximityAlertRadius,
threadId,
disableNotification,
protectContent,
to.messageId,

View File

@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CloseForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.closeForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
) = execute(
CloseForumTopic(
chatId,
messageThreadId
)
)
suspend fun TelegramBot.closeForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
) = closeForumTopic(chat.id, messageThreadId)
suspend fun TelegramBot.closeForumTopic(
chat: Chat,
forumTopic: ForumTopic
) = closeForumTopic(chat.id, forumTopic.messageThreadId)

View File

@ -0,0 +1,29 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.CreateForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.utils.RGBColor
suspend fun TelegramBot.createForumTopic(
chatId: ChatIdentifier,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
) = execute(
CreateForumTopic(
chatId,
name,
color,
iconEmojiId
)
)
suspend fun TelegramBot.createForumTopic(
chat: Chat,
name: String,
color: RGBColor,
iconEmojiId: CustomEmojiId? = null
) = createForumTopic(chat.id, name, color, iconEmojiId)

View File

@ -0,0 +1,33 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.DeleteForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
) = execute(
DeleteForumTopic(
chatId,
messageThreadId
)
)
suspend fun TelegramBot.deleteForumTopic(
chatId: ChatIdentifier,
forumTopic: ForumTopic
) = deleteForumTopic(chatId, forumTopic.messageThreadId)
suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
) = deleteForumTopic(chat.id, messageThreadId)
suspend fun TelegramBot.deleteForumTopic(
chat: Chat,
forumTopic: ForumTopic
) = deleteForumTopic(chat.id, forumTopic.messageThreadId)

View File

@ -0,0 +1,36 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.EditForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.CustomEmojiId
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.editForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId,
name: String,
iconEmojiId: CustomEmojiId
) = execute(
EditForumTopic(
chatId,
messageThreadId,
name,
iconEmojiId
)
)
suspend fun TelegramBot.editForumTopic(
chat: Chat,
messageThreadId: MessageThreadId,
name: String,
iconEmojiId: CustomEmojiId
) = editForumTopic(chat.id, messageThreadId, name, iconEmojiId)
suspend fun TelegramBot.editForumTopic(
chatIdentifier: ChatIdentifier,
forumTopic: ForumTopic,
iconEmojiId: CustomEmojiId = forumTopic.iconEmojiId ?: error("Icon emoji id in forum topic should be presented when edit forum topic basing on other forum topic object")
) = editForumTopic(chatIdentifier, forumTopic.messageThreadId, forumTopic.name, iconEmojiId)

View File

@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.ReopenForumTopic
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.reopenForumTopic(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
) = execute(
ReopenForumTopic(
chatId,
messageThreadId
)
)
suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
messageThreadId: MessageThreadId
) = reopenForumTopic(chat.id, messageThreadId)
suspend fun TelegramBot.reopenForumTopic(
chat: Chat,
forumTopic: ForumTopic
) = reopenForumTopic(chat.id, forumTopic.messageThreadId)

View File

@ -0,0 +1,28 @@
package dev.inmo.tgbotapi.extensions.api.chat.forum
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.forum.UnpinAllForumTopicMessages
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ForumTopic
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
suspend fun TelegramBot.unpinAllForumTopicMessages(
chatId: ChatIdentifier,
messageThreadId: MessageThreadId
) = execute(
UnpinAllForumTopicMessages(
chatId,
messageThreadId
)
)
suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
messageThreadId: MessageThreadId
) = unpinAllForumTopicMessages(chat.id, messageThreadId)
suspend fun TelegramBot.unpinAllForumTopicMessages(
chat: Chat,
forumTopic: ForumTopic
) = unpinAllForumTopicMessages(chat.id, forumTopic.messageThreadId)

View File

@ -3,7 +3,27 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChat
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.ChannelChat
import dev.inmo.tgbotapi.types.chat.ChannelChatImpl
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChat
import dev.inmo.tgbotapi.types.chat.ExtendedChannelChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChat
import dev.inmo.tgbotapi.types.chat.ExtendedGroupChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChat
import dev.inmo.tgbotapi.types.chat.ExtendedPrivateChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedPublicChat
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChat
import dev.inmo.tgbotapi.types.chat.ExtendedSupergroupChatImpl
import dev.inmo.tgbotapi.types.chat.ExtendedUser
import dev.inmo.tgbotapi.types.chat.GroupChat
import dev.inmo.tgbotapi.types.chat.GroupChatImpl
import dev.inmo.tgbotapi.types.chat.PrivateChat
import dev.inmo.tgbotapi.types.chat.PrivateChatImpl
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.SupergroupChat
import dev.inmo.tgbotapi.types.chat.SupergroupChatImpl
import dev.inmo.tgbotapi.utils.PreviewFeature
suspend fun TelegramBot.getChat(

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetChatMenuButton
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.chat.PrivateChat
suspend fun TelegramBot.getChatMenuButton(

View File

@ -2,7 +2,5 @@ package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetDefaultChatMenuButton
import dev.inmo.tgbotapi.requests.chat.modify.SetDefaultChatMenuButton
import dev.inmo.tgbotapi.types.MenuButton
suspend fun TelegramBot.getDefaultChatMenuButton() = execute(GetDefaultChatMenuButton)

View File

@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.extensions.api.chat.get
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.get.GetForumTopicIconStickers
suspend fun TelegramBot.getForumTopicIconStickers() = execute(GetForumTopicIconStickers)

View File

@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.ApproveChatJoinRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate

View File

@ -3,8 +3,11 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.CreateChatInviteLink
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MembersLimit
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.toTelegramDate
suspend fun TelegramBot.createChatInviteLinkUnlimited(
chatId: ChatIdentifier,

View File

@ -2,8 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.DeclineChatJoinRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.update.ChatJoinRequestUpdate

View File

@ -3,8 +3,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.invite_links
import com.soywiz.klock.DateTime
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.invite_links.EditChatInviteLink
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.ChatInviteLink
import dev.inmo.tgbotapi.types.MembersLimit
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.toTelegramDate
suspend fun TelegramBot.editChatInviteLinkUnlimited(
chatId: ChatIdentifier,

View File

@ -2,7 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User

View File

@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.BanChatSenderChat
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
suspend fun TelegramBot.banChatSenderChat(

View File

@ -2,7 +2,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.GetChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User

View File

@ -2,7 +2,10 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.PromoteChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
@ -20,7 +23,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean?
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null
) = execute(
PromoteChatMember(
chatId,
@ -36,7 +40,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageChat,
canManageTopics
)
)
@ -54,7 +59,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null
) = promoteChatMember(
chat.id,
userId,
@ -69,7 +75,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageChat,
canManageTopics
)
suspend fun TelegramBot.promoteChatMember(
@ -86,7 +93,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null
) = promoteChatMember(
chatId,
user.id,
@ -101,7 +109,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageChat,
canManageTopics
)
suspend fun TelegramBot.promoteChatMember(
@ -118,7 +127,8 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages: Boolean? = null,
canPromoteMembers: Boolean? = null,
canManageVideoChats: Boolean? = null,
canManageChat: Boolean? = null
canManageChat: Boolean? = null,
canManageTopics: Boolean? = null
) = promoteChatMember(
chat.id,
user.id,
@ -133,5 +143,6 @@ suspend fun TelegramBot.promoteChatMember(
canPinMessages,
canPromoteMembers,
canManageVideoChats,
canManageChat
canManageChat,
canManageTopics
)

View File

@ -2,8 +2,12 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.RestrictChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.TelegramDate
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.ChatPermissions
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User
suspend fun TelegramBot.restrictChatMember(

View File

@ -2,7 +2,8 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.SetChatAdministratorCustomTitle
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User

View File

@ -2,7 +2,9 @@ package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatMember
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.UserId
import dev.inmo.tgbotapi.types.chat.PublicChat
import dev.inmo.tgbotapi.types.chat.User

View File

@ -1,8 +1,9 @@
package dev.inmo.tgbotapi.extensions.api.chat.members
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.members.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.requests.chat.members.UnbanChatSenderChat
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.chat.PublicChat
suspend fun TelegramBot.unbanChatSenderChat(

View File

@ -1,8 +1,9 @@
package dev.inmo.tgbotapi.extensions.api.chat.modify
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.chat.modify.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.requests.chat.modify.SetChatMenuButton
import dev.inmo.tgbotapi.types.ChatId
import dev.inmo.tgbotapi.types.MenuButton
import dev.inmo.tgbotapi.types.chat.PrivateChat
suspend fun TelegramBot.setChatMenuButton(

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.send.CopyMessage
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -20,6 +21,7 @@ suspend inline fun TelegramBot.copyMessage(
toChatId: ChatIdentifier,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -32,6 +34,7 @@ suspend inline fun TelegramBot.copyMessage(
toChatId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -50,12 +53,13 @@ suspend inline fun TelegramBot.copyMessage(
toChatId: ChatIdentifier,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChat.id, messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -67,12 +71,13 @@ suspend inline fun TelegramBot.copyMessage(
toChat: Chat,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChatId, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -84,12 +89,13 @@ suspend inline fun TelegramBot.copyMessage(
toChat: Chat,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChat.id, messageId, toChat.id, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -101,6 +107,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
toChatId: ChatIdentifier,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -112,6 +119,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId,
toChatId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -129,12 +137,13 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
toChatId: ChatIdentifier,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChat.id, messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChat.id, messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -145,12 +154,13 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
toChat: Chat,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChatId, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChatId, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -161,12 +171,13 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
toChat: Chat,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(fromChat.id, messageId, toChat.id, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(fromChat.id, messageId, toChat.id, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -177,12 +188,13 @@ suspend inline fun TelegramBot.copyMessage(
message: Message,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(message.chat, message.messageId, toChatId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -193,12 +205,13 @@ suspend inline fun TelegramBot.copyMessage(
message: Message,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(message.chat, message.messageId, toChat, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -208,12 +221,13 @@ suspend inline fun TelegramBot.copyMessage(
toChatId: ChatIdentifier,
message: Message,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(message.chat, message.messageId, toChatId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(message.chat, message.messageId, toChatId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -223,12 +237,13 @@ suspend inline fun TelegramBot.copyMessage(
toChat: Chat,
message: Message,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = copyMessage(message.chat, message.messageId, toChat, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = copyMessage(message.chat, message.messageId, toChat, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -240,6 +255,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -252,6 +268,7 @@ suspend inline fun TelegramBot.copyMessage(
toChatId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -270,6 +287,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -281,6 +299,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -298,6 +317,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -309,6 +329,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -326,6 +347,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId: MessageId,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -337,6 +359,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -354,6 +377,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChatId: ChatIdentifier,
messageId: MessageId,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -365,6 +389,7 @@ suspend inline fun TelegramBot.copyMessage(
messageId,
toChatId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -382,6 +407,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChat: Chat,
messageId: MessageId,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -392,6 +418,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChat.id,
messageId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -408,6 +435,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChatId: ChatIdentifier,
messageId: MessageId,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -418,6 +446,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChatId,
messageId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -434,6 +463,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChat: Chat,
messageId: MessageId,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -444,6 +474,7 @@ suspend inline fun TelegramBot.copyMessage(
fromChat.id,
messageId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,

View File

@ -1,173 +0,0 @@
package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.media.*
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.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChatId: ChatIdentifier,
messages: List<MediaGroupMessage<MediaGroupContent>>,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
): List<MediaGroupMessage<MediaGroupContent>> {
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
if (text != null) {
when (it) {
is TelegramMediaAudio -> it.copy(text = text, parseMode = parseMode)
is TelegramMediaDocument -> it.copy(text = text, parseMode = parseMode)
is TelegramMediaPhoto -> it.copy(text = text, parseMode = parseMode)
is TelegramMediaVideo -> it.copy(text = text, parseMode = parseMode)
}
} else {
it
}
}
return sendMediaGroup(
toChatId,
listOf(first) + messages.drop(1).map {
it.content.toMediaGroupMemberTelegramMedia()
},
disableNotification,
protectContent,
replyToMessageId,
allowSendingWithoutReply
)
}
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: Chat,
messages: List<MediaGroupMessage<MediaGroupContent>>,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat.id, messages, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: ChatIdentifier,
update: SentMediaGroupUpdate,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat, update.data, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: Chat,
update: SentMediaGroupUpdate,
text: String? = null,
parseMode: ParseMode? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat.id, update, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChatId: ChatIdentifier,
messages: List<MediaGroupMessage<MediaGroupContent>>,
entities: TextSourcesList,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
): List<MediaGroupMessage<MediaGroupContent>> {
val first = messages.first().content.toMediaGroupMemberTelegramMedia().let {
when (it) {
is TelegramMediaAudio -> TelegramMediaAudio(it.file, entities, it.duration, it.performer, it.title, it.thumb)
is TelegramMediaDocument -> TelegramMediaDocument(it.file, entities, it.thumb, it.disableContentTypeDetection)
is TelegramMediaPhoto -> TelegramMediaPhoto(it.file, entities)
is TelegramMediaVideo -> TelegramMediaVideo(it.file, entities, it.width, it.height, it.duration, it.thumb)
}
}
return sendMediaGroup(
toChatId,
listOf(first) + messages.drop(1).map {
it.content.toMediaGroupMemberTelegramMedia()
},
disableNotification,
protectContent,
replyToMessageId,
allowSendingWithoutReply
)
}
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: Chat,
messages: List<MediaGroupMessage<MediaGroupContent>>,
entities: TextSourcesList,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat.id, messages, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: ChatIdentifier,
update: SentMediaGroupUpdate,
entities: TextSourcesList,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat, update.data, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
* will be copied as they are
*/
suspend inline fun TelegramBot.copyMessages(
toChat: Chat,
update: SentMediaGroupUpdate,
entities: TextSourcesList,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = copyMessages(toChat.id, update, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)

View File

@ -23,6 +23,7 @@ import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.payments.LabeledPrice
@ -30,6 +31,7 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import kotlinx.coroutines.flow.Flow
import kotlin.js.JsName
import kotlin.jvm.JvmName
@ -55,6 +57,7 @@ suspend inline fun TelegramBot.reply(
phoneNumber,
firstName,
lastName,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -76,6 +79,7 @@ suspend inline fun TelegramBot.reply(
) = sendContact(
to.chat,
contact,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -97,7 +101,7 @@ suspend inline fun TelegramBot.replyWithDice(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDice(to.chat, animationType, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -131,6 +135,7 @@ suspend inline fun TelegramBot.reply(
to.chat,
latitude,
longitude,
to.threadIdOrNull,
disableNotification,
protectContent,
allowSendingWithoutReply,
@ -152,6 +157,7 @@ suspend inline fun TelegramBot.reply(
) = sendLocation(
to.chat,
location,
to.threadIdOrNull,
disableNotification,
protectContent,
allowSendingWithoutReply,
@ -180,6 +186,7 @@ suspend inline fun TelegramBot.reply(
text,
parseMode,
disableWebPagePreview,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -203,6 +210,7 @@ suspend inline fun TelegramBot.reply(
to.chat,
entities,
disableWebPagePreview,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -271,6 +279,7 @@ suspend inline fun TelegramBot.reply(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = to.threadIdOrNull,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = to.messageId,
@ -301,6 +310,7 @@ suspend inline fun TelegramBot.reply(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = to.threadIdOrNull,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = to.messageId,
@ -318,6 +328,7 @@ suspend inline fun TelegramBot.reply(
) = sendVenue(
chat = to.chat,
venue = venue,
threadId = to.threadIdOrNull,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = to.messageId,
@ -336,7 +347,7 @@ suspend inline fun TelegramBot.replyWithGame(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
to.chat, gameShortName, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.replyWithGame(
@ -347,7 +358,7 @@ suspend inline fun TelegramBot.replyWithGame(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
to.chat, game.title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
)
suspend inline fun TelegramBot.reply(
@ -384,6 +395,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
duration,
width,
height,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -403,7 +415,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation(
to: Message,
@ -425,6 +437,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
duration,
width,
height,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -443,7 +456,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, entities, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Audio
@ -461,7 +474,7 @@ suspend inline fun TelegramBot.replyWithAudio(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -473,7 +486,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, text, parseMode, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAudio(
to: Message,
@ -487,7 +500,7 @@ suspend inline fun TelegramBot.replyWithAudio(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -498,7 +511,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, entities, title, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Documents
@ -514,7 +527,7 @@ suspend inline fun TelegramBot.replyWithDocument(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, thumb, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.reply(
to: Message,
@ -526,7 +539,7 @@ suspend inline fun TelegramBot.reply(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.replyWithDocument(
to: Message,
@ -538,7 +551,7 @@ suspend inline fun TelegramBot.replyWithDocument(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, thumb, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
suspend inline fun TelegramBot.reply(
to: Message,
@ -549,7 +562,7 @@ suspend inline fun TelegramBot.reply(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
// Media Group
@ -561,7 +574,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup(
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null
) = sendMediaGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithPlaylist(
to: Message,
@ -569,7 +582,7 @@ suspend inline fun TelegramBot.replyWithPlaylist(
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null
) = sendPlaylist(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithDocuments(
to: Message,
@ -577,7 +590,7 @@ suspend inline fun TelegramBot.replyWithDocuments(
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null
) = sendDocumentsGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithGallery(
to: Message,
@ -585,7 +598,7 @@ suspend inline fun TelegramBot.replyWithGallery(
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null
) = sendVisualMediaGroup(to.chat, media, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
// Photo
@ -599,7 +612,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -610,7 +623,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -621,7 +634,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto(
@ -632,7 +645,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -642,7 +655,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -652,7 +665,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Sticker
@ -664,7 +677,7 @@ suspend inline fun TelegramBot.replyWithSticker(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(to.chat, sticker, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -673,7 +686,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(to.chat, sticker, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Videos
@ -691,7 +704,7 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -702,7 +715,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo(
to: Message,
@ -716,7 +729,7 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, entities, duration, width, height, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -726,7 +739,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// VideoNotes
@ -741,7 +754,7 @@ suspend inline fun TelegramBot.replyWithVideoNote(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(to.chat, videoNote, thumb, duration, size, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -750,7 +763,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(to.chat, videoNote, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Voice
@ -765,7 +778,7 @@ suspend inline fun TelegramBot.replyWithVoice(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, text, parseMode, duration, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -776,7 +789,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, text, parseMode, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVoice(
@ -788,7 +801,7 @@ suspend inline fun TelegramBot.replyWithVoice(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, entities, duration, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -798,7 +811,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, entities, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Invoice
@ -830,7 +843,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Polls
@ -847,7 +860,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -862,7 +875,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -878,7 +891,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -895,7 +908,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -910,7 +923,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
@ -926,7 +939,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
@ -990,6 +1003,7 @@ suspend inline fun TelegramBot.reply(
messageId,
text,
parseMode,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
@ -1027,18 +1041,17 @@ suspend fun TelegramBot.reply(
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) {
execute(
content.createResend(
to.chat.id,
disableNotification,
protectContent,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
): Message = execute(
content.createResend(
to.chat.id,
to.threadIdOrNull,
disableNotification,
protectContent,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
}
)
/**
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
@ -1056,6 +1069,7 @@ suspend fun TelegramBot.reply(
message.chat.id,
locationsFlow,
liveTimeMillis,
message.threadIdOrNull,
disableNotification,
protectContent,
message.messageId,
@ -1081,6 +1095,7 @@ suspend fun TelegramBot.reply(
message.chat.id,
locationsFlow,
liveTimeMillis,
message.threadIdOrNull,
disableNotification,
protectContent,
message.messageId,
@ -1107,6 +1122,7 @@ suspend fun TelegramBot.reply(
message.chat.id,
locationsFlow,
liveTimeMillis,
message.threadIdOrNull,
disableNotification,
protectContent,
message.messageId,
@ -1219,7 +1235,7 @@ suspend fun TelegramBot.reply(
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
is AudioMediaGroupContent -> reply(
is AudioMediaGroupPartContent -> reply(
to = to,
audio = content.media,
text = text,
@ -1291,7 +1307,7 @@ suspend fun TelegramBot.reply(
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
is AudioMediaGroupContent -> reply(
is AudioMediaGroupPartContent -> reply(
to = to,
audio = content.media,
entities = entities,

View File

@ -15,6 +15,7 @@ suspend fun TelegramBot.sendContact(
phoneNumber: String,
firstName: String,
lastName: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -22,7 +23,7 @@ suspend fun TelegramBot.sendContact(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendContact(
chatId, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
@ -33,6 +34,7 @@ suspend fun TelegramBot.sendContact(
suspend fun TelegramBot.sendContact(
chatId: ChatIdentifier,
contact: Contact,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -40,7 +42,7 @@ suspend fun TelegramBot.sendContact(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendContact(
chatId, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
@ -53,13 +55,14 @@ suspend fun TelegramBot.sendContact(
phoneNumber: String,
firstName: String,
lastName: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
chat.id, phoneNumber, firstName, lastName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, phoneNumber, firstName, lastName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -69,11 +72,12 @@ suspend fun TelegramBot.sendContact(
suspend fun TelegramBot.sendContact(
chat: Chat,
contact: Contact,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendContact(
chat.id, contact, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, contact, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.SendDice
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.dice.DiceAnimationType
@ -15,13 +16,14 @@ import dev.inmo.tgbotapi.types.dice.DiceAnimationType
suspend fun TelegramBot.sendDice(
chatId: ChatIdentifier,
animationType: DiceAnimationType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendDice(chatId, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
SendDice(chatId, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
)
/**
@ -31,9 +33,10 @@ suspend fun TelegramBot.sendDice(
suspend fun TelegramBot.sendDice(
chat: Chat,
animationType: DiceAnimationType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendDice(chat.id, animationType, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendDice(chat.id, animationType, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -19,6 +19,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -33,6 +34,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy,
heading,
proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -52,6 +54,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -65,6 +68,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy,
heading,
proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -84,6 +88,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -97,6 +102,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy,
heading,
proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -115,6 +121,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -128,6 +135,7 @@ suspend fun TelegramBot.sendLocation(
horizontalAccuracy,
heading,
proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -147,12 +155,13 @@ suspend fun TelegramBot.sendLiveLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendLocation(chatId, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -165,12 +174,13 @@ suspend fun TelegramBot.sendLiveLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendLocation(chatId, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -184,12 +194,13 @@ suspend fun TelegramBot.sendLiveLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendLocation(chat.id, latitude, longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -202,9 +213,10 @@ suspend fun TelegramBot.sendLiveLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendLocation(chat.id, location.latitude, location.longitude, livePeriod, horizontalAccuracy, heading, proximityAlertRadius, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -20,13 +20,25 @@ suspend fun TelegramBot.sendMessage(
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendTextMessage(chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
SendTextMessage(
chatId,
text,
parseMode,
disableWebPagePreview,
threadId,
disableNotification,
protectContent,
replyToMessageId,
allowSendingWithoutReply,
replyMarkup
)
)
/**
@ -38,32 +50,16 @@ suspend fun TelegramBot.sendTextMessage(
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(
chatId, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, text, parseMode, disableWebPagePreview, threadId, 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 fun TelegramBot.sendMessage(
chat: Chat,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, 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
@ -73,12 +69,31 @@ suspend fun TelegramBot.sendTextMessage(
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, 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 fun TelegramBot.sendMessage(
chat: Chat,
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(chat.id, text, parseMode, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -88,13 +103,14 @@ suspend fun TelegramBot.sendMessage(
chatId: ChatIdentifier,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendTextMessage(chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
SendTextMessage(chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
)
/**
@ -105,13 +121,14 @@ suspend fun TelegramBot.sendMessage(
chatId: ChatIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -122,13 +139,14 @@ suspend fun TelegramBot.sendMessage(
chatId: ChatIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -138,13 +156,14 @@ suspend fun TelegramBot.sendTextMessage(
chatId: ChatIdentifier,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(
chatId, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -155,13 +174,14 @@ suspend fun TelegramBot.sendTextMessage(
chatId: ChatIdentifier,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -172,13 +192,14 @@ suspend fun TelegramBot.sendTextMessage(
chatId: ChatIdentifier,
separator: String,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendTextMessage(chatId, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -188,12 +209,13 @@ suspend fun TelegramBot.sendMessage(
chat: Chat,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -203,13 +225,14 @@ suspend fun TelegramBot.sendMessage(
chat: Chat,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -220,13 +243,14 @@ suspend fun TelegramBot.sendMessage(
chat: Chat,
separator: String,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -237,12 +261,13 @@ suspend fun TelegramBot.sendTextMessage(
chat: Chat,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendTextMessage(chat.id, entities, disableWebPagePreview, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendTextMessage(chat.id, entities, disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -252,13 +277,14 @@ suspend fun TelegramBot.sendTextMessage(
chat: Chat,
separator: TextSource? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -269,10 +295,11 @@ suspend fun TelegramBot.sendTextMessage(
chat: Chat,
separator: String,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = 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)
) = sendTextMessage(chat, buildEntities(separator, builderBody), disableWebPagePreview, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.SendStaticLocation
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.location.Location
@ -16,6 +17,7 @@ suspend fun TelegramBot.sendLocation(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -26,6 +28,7 @@ suspend fun TelegramBot.sendLocation(
chatId,
latitude,
longitude,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
allowSendingWithoutReply = allowSendingWithoutReply,
@ -41,6 +44,7 @@ suspend fun TelegramBot.sendLocation(
suspend fun TelegramBot.sendLocation(
chatId: ChatIdentifier,
location: Location,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -50,6 +54,7 @@ suspend fun TelegramBot.sendLocation(
chatId,
location.latitude,
location.longitude,
threadId,
disableNotification,
protectContent,
allowSendingWithoutReply,
@ -65,6 +70,7 @@ suspend fun TelegramBot.sendLocation(
chat: Chat,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -74,6 +80,7 @@ suspend fun TelegramBot.sendLocation(
chat.id,
latitude,
longitude,
threadId,
disableNotification,
protectContent,
allowSendingWithoutReply,
@ -88,6 +95,7 @@ suspend fun TelegramBot.sendLocation(
suspend fun TelegramBot.sendLocation(
chat: Chat,
location: Location,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
@ -97,6 +105,7 @@ suspend fun TelegramBot.sendLocation(
chat.id,
location.latitude,
location.longitude,
threadId,
disableNotification,
protectContent,
allowSendingWithoutReply,
@ -112,12 +121,13 @@ suspend fun TelegramBot.sendStaticLocation(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageId? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
) = sendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -126,12 +136,13 @@ suspend fun TelegramBot.sendStaticLocation(
suspend fun TelegramBot.sendStaticLocation(
chatId: ChatIdentifier,
location: Location,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageId? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
) = sendLocation(chatId, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -141,12 +152,13 @@ suspend fun TelegramBot.sendStaticLocation(
chat: Chat,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageId? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
) = sendLocation(chat.id, latitude, longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -155,9 +167,10 @@ suspend fun TelegramBot.sendStaticLocation(
suspend fun TelegramBot.sendStaticLocation(
chat: Chat,
location: Location,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageId? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
) = sendLocation(chat.id, location.latitude, location.longitude, threadId, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)

View File

@ -22,6 +22,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -38,6 +39,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -60,6 +62,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -75,6 +78,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -95,6 +99,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -110,6 +115,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -130,6 +136,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType: FoursquareType? = null,
googlePlaceId: GooglePlaceId? = null,
googlePlaceType: GooglePlaceType? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -145,6 +152,7 @@ suspend fun TelegramBot.sendVenue(
foursquareType = foursquareType,
googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -159,6 +167,7 @@ suspend fun TelegramBot.sendVenue(
suspend fun TelegramBot.sendVenue(
chatId: ChatIdentifier,
venue: Venue,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -168,6 +177,7 @@ suspend fun TelegramBot.sendVenue(
SendVenue(
chatId = chatId,
venue = venue,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -183,6 +193,7 @@ suspend fun TelegramBot.sendVenue(
suspend fun TelegramBot.sendVenue(
chat: Chat,
venue: Venue,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -191,6 +202,7 @@ suspend fun TelegramBot.sendVenue(
) = sendVenue(
chatId = chat.id,
venue = venue,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.games.SendGame
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.games.Game
@ -15,6 +16,7 @@ import dev.inmo.tgbotapi.types.games.Game
suspend fun TelegramBot.sendGame(
chatId: ChatIdentifier,
gameShortName: String,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -22,7 +24,7 @@ suspend fun TelegramBot.sendGame(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendGame(
chatId, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
@ -33,13 +35,14 @@ suspend fun TelegramBot.sendGame(
suspend fun TelegramBot.sendGame(
chat: Chat,
gameShortName: String,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chat.id, gameShortName, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, gameShortName, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -49,13 +52,14 @@ suspend fun TelegramBot.sendGame(
suspend fun TelegramBot.sendGame(
chatId: ChatIdentifier,
game: Game,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chatId, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -65,11 +69,12 @@ suspend fun TelegramBot.sendGame(
suspend fun TelegramBot.sendGame(
chat: Chat,
game: Game,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendGame(
chat.id, game.title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, game.title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAnimation
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -24,6 +25,7 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -39,6 +41,7 @@ suspend fun TelegramBot.sendAnimation(
duration,
width,
height,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -59,13 +62,14 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -81,12 +85,13 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -100,12 +105,13 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -120,6 +126,7 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -134,6 +141,7 @@ suspend fun TelegramBot.sendAnimation(
duration,
width,
height,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -153,13 +161,14 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(
chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, animation.fileId, animation.thumb ?.fileId, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -174,12 +183,13 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -192,9 +202,10 @@ suspend fun TelegramBot.sendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAnimation(chat.id, animation, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAnimation(chat.id, animation, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendAudio
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -24,6 +25,7 @@ suspend fun TelegramBot.sendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -39,6 +41,7 @@ suspend fun TelegramBot.sendAudio(
duration,
performer,
title,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -60,12 +63,13 @@ suspend fun TelegramBot.sendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -77,12 +81,13 @@ suspend fun TelegramBot.sendAudio(
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -94,12 +99,13 @@ suspend fun TelegramBot.sendAudio(
text: String? = null,
parseMode: ParseMode? = null,
title: String? = audio.title,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chat.id, audio, text, parseMode, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -114,6 +120,7 @@ suspend inline fun TelegramBot.sendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -128,6 +135,7 @@ suspend inline fun TelegramBot.sendAudio(
duration,
performer,
title,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -148,12 +156,13 @@ suspend inline fun TelegramBot.sendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chat.id, audio, thumb, entities, duration, performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -164,12 +173,13 @@ suspend inline fun TelegramBot.sendAudio(
audio: AudioFile,
entities: TextSourcesList,
title: String? = audio.title,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, entities, audio.duration, audio.performer, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -180,9 +190,10 @@ suspend inline fun TelegramBot.sendAudio(
audio: AudioFile,
entities: TextSourcesList,
title: String? = audio.title,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendAudio(chat.id, audio, entities, title, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendAudio(chat.id, audio, entities, title, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendDocument
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -21,6 +22,7 @@ suspend fun TelegramBot.sendDocument(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -34,6 +36,7 @@ suspend fun TelegramBot.sendDocument(
thumb,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -53,13 +56,14 @@ suspend fun TelegramBot.sendDocument(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(chat.id, document, thumb, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -70,6 +74,7 @@ suspend fun TelegramBot.sendDocument(
document: DocumentFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -77,7 +82,7 @@ suspend fun TelegramBot.sendDocument(
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
chatId, document.fileId, document.thumb ?.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
)
/**
@ -89,13 +94,14 @@ suspend fun TelegramBot.sendDocument(
document: DocumentFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(chat.id, document, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(chat.id, document, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -106,6 +112,7 @@ suspend inline fun TelegramBot.sendDocument(
document: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -118,6 +125,7 @@ suspend inline fun TelegramBot.sendDocument(
document,
thumb,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -136,13 +144,14 @@ suspend inline fun TelegramBot.sendDocument(
document: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(chat.id, document, thumb, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(chat.id, document, thumb, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -152,6 +161,7 @@ suspend inline fun TelegramBot.sendDocument(
chatId: ChatIdentifier,
document: DocumentFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -159,7 +169,7 @@ suspend inline fun TelegramBot.sendDocument(
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(
chatId, document.fileId, document.thumb ?.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
chatId, document.fileId, document.thumb ?.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection
)
/**
@ -170,10 +180,11 @@ suspend inline fun TelegramBot.sendDocument(
chat: Chat,
document: DocumentFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null
) = sendDocument(chat.id, document, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
) = sendDocument(chat.id, document, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)

View File

@ -5,9 +5,10 @@ import dev.inmo.tgbotapi.requests.send.media.*
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.AudioContent
import dev.inmo.tgbotapi.types.message.content.DocumentContent
import dev.inmo.tgbotapi.utils.RiskFeature
@ -20,13 +21,14 @@ import kotlin.jvm.JvmName
suspend fun TelegramBot.sendMediaGroup(
chatId: ChatIdentifier,
media: List<MediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = execute(
SendMediaGroup<MediaGroupContent>(
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
SendMediaGroup<MediaGroupPartContent>(
chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
)
@ -37,12 +39,13 @@ suspend fun TelegramBot.sendMediaGroup(
suspend fun TelegramBot.sendMediaGroup(
chat: Chat,
media: List<MediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendMediaGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -52,13 +55,14 @@ suspend fun TelegramBot.sendMediaGroup(
@JvmName("sendMedaGroupByContent")
suspend fun TelegramBot.sendMediaGroup(
chatId: ChatIdentifier,
media: List<MediaGroupContent>,
media: List<MediaGroupPartContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendMediaGroup(
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -68,13 +72,14 @@ suspend fun TelegramBot.sendMediaGroup(
@JvmName("sendMedaGroupByContent")
suspend fun TelegramBot.sendMediaGroup(
chat: Chat,
media: List<MediaGroupContent>,
media: List<MediaGroupPartContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendMediaGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -83,13 +88,14 @@ suspend fun TelegramBot.sendMediaGroup(
suspend fun TelegramBot.sendPlaylist(
chatId: ChatIdentifier,
media: List<AudioMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = execute(
SendPlaylist(
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
)
@ -99,12 +105,13 @@ suspend fun TelegramBot.sendPlaylist(
suspend fun TelegramBot.sendPlaylist(
chat: Chat,
media: List<AudioMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendPlaylist(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -114,12 +121,13 @@ suspend fun TelegramBot.sendPlaylist(
suspend fun TelegramBot.sendPlaylist(
chatId: ChatIdentifier,
media: List<AudioContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendPlaylist(
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -129,12 +137,13 @@ suspend fun TelegramBot.sendPlaylist(
suspend fun TelegramBot.sendPlaylist(
chat: Chat,
media: List<AudioContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendPlaylist(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -143,13 +152,14 @@ suspend fun TelegramBot.sendPlaylist(
suspend fun TelegramBot.sendDocumentsGroup(
chatId: ChatIdentifier,
media: List<DocumentMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = execute(
SendDocumentsGroup(
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
)
@ -159,12 +169,13 @@ suspend fun TelegramBot.sendDocumentsGroup(
suspend fun TelegramBot.sendDocumentsGroup(
chat: Chat,
media: List<DocumentMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendDocumentsGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -174,12 +185,13 @@ suspend fun TelegramBot.sendDocumentsGroup(
suspend fun TelegramBot.sendDocumentsGroup(
chatId: ChatIdentifier,
media: List<DocumentContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendDocumentsGroup(
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -189,12 +201,13 @@ suspend fun TelegramBot.sendDocumentsGroup(
suspend fun TelegramBot.sendDocumentsGroup(
chat: Chat,
media: List<DocumentContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendDocumentsGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -203,13 +216,14 @@ suspend fun TelegramBot.sendDocumentsGroup(
suspend fun TelegramBot.sendVisualMediaGroup(
chatId: ChatIdentifier,
media: List<VisualMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = execute(
SendVisualMediaGroup(
chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
)
@ -219,12 +233,13 @@ suspend fun TelegramBot.sendVisualMediaGroup(
suspend fun TelegramBot.sendVisualMediaGroup(
chat: Chat,
media: List<VisualMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendVisualMediaGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -233,13 +248,14 @@ suspend fun TelegramBot.sendVisualMediaGroup(
@JvmName("sendVisualMediaGroupByContent")
suspend fun TelegramBot.sendVisualMediaGroup(
chatId: ChatIdentifier,
media: List<VisualMediaGroupContent>,
media: List<VisualMediaGroupPartContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendVisualMediaGroup(
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chatId, media.map { it.toMediaGroupMemberTelegramMedia() }, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)
/**
@ -248,11 +264,12 @@ suspend fun TelegramBot.sendVisualMediaGroup(
@JvmName("sendVisualMediaGroupByContent")
suspend fun TelegramBot.sendVisualMediaGroup(
chat: Chat,
media: List<VisualMediaGroupContent>,
media: List<VisualMediaGroupPartContent>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = sendVisualMediaGroup(
chat.id, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
chat.id, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply
)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendPhoto
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -20,6 +21,7 @@ suspend fun TelegramBot.sendPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -31,6 +33,7 @@ suspend fun TelegramBot.sendPhoto(
fileId,
text,
parseMode,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -48,12 +51,13 @@ suspend fun TelegramBot.sendPhoto(
fileId: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -64,12 +68,13 @@ suspend fun TelegramBot.sendPhoto(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -80,12 +85,13 @@ suspend fun TelegramBot.sendPhoto(
photo: Photo,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photo, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photo, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -96,12 +102,13 @@ suspend fun TelegramBot.sendPhoto(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize.fileId, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -112,12 +119,13 @@ suspend fun TelegramBot.sendPhoto(
photoSize: PhotoSize,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photoSize, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photoSize, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -128,6 +136,7 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
fileId: InputFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -138,6 +147,7 @@ suspend inline fun TelegramBot.sendPhoto(
chatId,
fileId,
entities,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -154,12 +164,13 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
fileId: InputFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -169,12 +180,13 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
photo: Photo,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -184,12 +196,13 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
photo: Photo,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photo, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photo, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -199,12 +212,13 @@ suspend inline fun TelegramBot.sendPhoto(
chatId: ChatIdentifier,
photoSize: PhotoSize,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chatId, photoSize.fileId, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chatId, photoSize.fileId, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -214,9 +228,10 @@ suspend inline fun TelegramBot.sendPhoto(
chat: Chat,
photoSize: PhotoSize,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendPhoto(chat.id, photoSize, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendPhoto(chat.id, photoSize, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.send.media.SendSticker
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.files.Sticker
@ -16,13 +17,14 @@ import dev.inmo.tgbotapi.types.files.Sticker
suspend fun TelegramBot.sendSticker(
chatId: ChatIdentifier,
sticker: InputFile,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
SendSticker(chatId, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
SendSticker(chatId, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
)
/**
@ -32,12 +34,13 @@ suspend fun TelegramBot.sendSticker(
suspend fun TelegramBot.sendSticker(
chat: Chat,
sticker: InputFile,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat.id, sticker, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendSticker(chat.id, sticker, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -46,12 +49,13 @@ suspend fun TelegramBot.sendSticker(
suspend fun TelegramBot.sendSticker(
chatId: ChatIdentifier,
sticker: Sticker,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chatId, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendSticker(chatId, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -60,9 +64,10 @@ suspend fun TelegramBot.sendSticker(
suspend fun TelegramBot.sendSticker(
chat: Chat,
sticker: Sticker,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendSticker(chat, sticker.fileId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendSticker(chat, sticker.fileId, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendVideo
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -24,6 +25,7 @@ suspend fun TelegramBot.sendVideo(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -40,6 +42,7 @@ suspend fun TelegramBot.sendVideo(
width,
height,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -57,12 +60,13 @@ suspend fun TelegramBot.sendVideo(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -77,12 +81,13 @@ suspend fun TelegramBot.sendVideo(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -94,12 +99,13 @@ suspend fun TelegramBot.sendVideo(
video: VideoFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -113,6 +119,7 @@ suspend inline fun TelegramBot.sendVideo(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -128,6 +135,7 @@ suspend inline fun TelegramBot.sendVideo(
width,
height,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -144,12 +152,13 @@ suspend inline fun TelegramBot.sendVideo(
chatId: ChatIdentifier,
video: VideoFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, entities, video.duration, video.width, video.height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -163,12 +172,13 @@ suspend inline fun TelegramBot.sendVideo(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, thumb, entities, duration, width, height, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -179,9 +189,10 @@ suspend inline fun TelegramBot.sendVideo(
chat: Chat,
video: VideoFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideo(chat.id, video, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideo(chat.id, video, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -5,6 +5,7 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
import dev.inmo.tgbotapi.requests.send.media.SendVideoNote
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.files.VideoNoteFile
@ -19,6 +20,7 @@ suspend fun TelegramBot.sendVideoNote(
thumb: InputFile? = null,
duration: Long? = null,
size: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -31,6 +33,7 @@ suspend fun TelegramBot.sendVideoNote(
thumb,
duration,
size,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -46,13 +49,14 @@ suspend fun TelegramBot.sendVideoNote(
suspend fun TelegramBot.sendVideoNote(
chatId: ChatIdentifier,
videoNote: VideoNoteFile,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(
chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, videoNote.fileId, videoNote.thumb ?.fileId, videoNote.duration, videoNote.width, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -65,12 +69,13 @@ suspend fun TelegramBot.sendVideoNote(
thumb: InputFile? = null,
duration: Long? = null,
size: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(chat.id, videoNote, thumb, duration, size, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideoNote(chat.id, videoNote, thumb, duration, size, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -79,9 +84,10 @@ suspend fun TelegramBot.sendVideoNote(
suspend fun TelegramBot.sendVideoNote(
chat: Chat,
videoNote: VideoNoteFile,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(chat.id, videoNote, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVideoNote(chat.id, videoNote, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.media.SendVoice
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -21,6 +22,7 @@ suspend fun TelegramBot.sendVoice(
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -33,6 +35,7 @@ suspend fun TelegramBot.sendVoice(
text,
parseMode,
duration,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -51,12 +54,13 @@ suspend fun TelegramBot.sendVoice(
text: String? = null,
parseMode: ParseMode? = null,
duration: Long? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(chat.id, voice, text, parseMode, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -67,13 +71,14 @@ suspend fun TelegramBot.sendVoice(
voice: VoiceFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, voice.fileId, text, parseMode, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -85,12 +90,13 @@ suspend fun TelegramBot.sendVoice(
voice: VoiceFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(chat.id, voice, text, parseMode, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(chat.id, voice, text, parseMode, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
@ -102,6 +108,7 @@ suspend inline fun TelegramBot.sendVoice(
voice: InputFile,
entities: TextSourcesList,
duration: Long? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -113,6 +120,7 @@ suspend inline fun TelegramBot.sendVoice(
voice,
entities,
duration,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -130,12 +138,13 @@ suspend inline fun TelegramBot.sendVoice(
voice: InputFile,
entities: TextSourcesList,
duration: Long? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(chat.id, voice, entities, duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(chat.id, voice, entities, duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -145,13 +154,14 @@ suspend inline fun TelegramBot.sendVoice(
chatId: ChatIdentifier,
voice: VoiceFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(
chatId, voice.fileId, entities, voice.duration, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, voice.fileId, entities, voice.duration, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -161,9 +171,10 @@ suspend inline fun TelegramBot.sendVoice(
chat: Chat,
voice: VoiceFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendVoice(chat.id, voice, entities, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendVoice(chat.id, voice, entities, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -31,13 +31,14 @@ suspend fun TelegramBot.sendInvoice(
shouldSendPhoneNumberToProvider: Boolean = false,
shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = execute(
SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
SendInvoice(chatId, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts ?.sorted(), startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
)
/**
@ -63,9 +64,10 @@ suspend fun TelegramBot.sendInvoice(
shouldSendPhoneNumberToProvider: Boolean = false,
shouldSendEmailToProvider: Boolean = false,
priceDependOnShipAddress: Boolean = false,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null
) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendInvoice(user.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)

View File

@ -6,6 +6,7 @@ import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat
@ -23,6 +24,7 @@ suspend fun TelegramBot.sendRegularPoll(
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -30,7 +32,7 @@ suspend fun TelegramBot.sendRegularPoll(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendRegularPoll(
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
/**
@ -46,12 +48,13 @@ suspend fun TelegramBot.sendRegularPoll(
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -65,13 +68,14 @@ suspend fun TelegramBot.sendRegularPoll(
isClosed: Boolean = false,
allowMultipleAnswers: Boolean = false,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -87,13 +91,14 @@ suspend fun TelegramBot.sendRegularPoll(
isAnonymous: Boolean = poll.isAnonymous,
allowMultipleAnswers: Boolean = poll.allowMultipleAnswers,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
@ -111,6 +116,7 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -118,7 +124,7 @@ suspend fun TelegramBot.sendQuizPoll(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
@ -136,13 +142,14 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -160,13 +167,14 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -184,13 +192,14 @@ suspend fun TelegramBot.sendQuizPoll(
explanation: String? = null,
parseMode: ParseMode? = null,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
@ -207,6 +216,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
isClosed: Boolean = false,
entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -214,7 +224,7 @@ suspend inline fun TelegramBot.sendQuizPoll(
replyMarkup: KeyboardMarkup? = null
) = execute(
SendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
)
@ -231,13 +241,14 @@ suspend inline fun TelegramBot.sendQuizPoll(
isClosed: Boolean = false,
entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -254,13 +265,14 @@ suspend inline fun TelegramBot.sendQuizPoll(
isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chatId, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)
/**
@ -277,11 +289,12 @@ suspend inline fun TelegramBot.sendQuizPoll(
isAnonymous: Boolean = quizPoll.isAnonymous,
entities: TextSourcesList,
closeInfo: ScheduledCloseInfo? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
chat.id, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup
)

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.extensions.api.utils
import dev.inmo.tgbotapi.extensions.api.InternalUtils.convertWithMediaGroupUpdates
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.update.abstracts.BaseMessageUpdate
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver
@ -30,10 +30,21 @@ fun CoroutineScope.updateHandlerWithMediaGroupsAdaptation(
launch {
launch {
for (update in updatesChannel) {
when (val data = update.data) {
is MediaGroupMessage<*> -> mediaGroupChannel.send("${data.mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
else -> output(update)
val dataAsPossiblySentViaBotCommonMessage = update.data as? PossiblySentViaBotCommonMessage<*>
if (dataAsPossiblySentViaBotCommonMessage == null) {
output(update)
continue
}
val mediaGroupId = dataAsPossiblySentViaBotCommonMessage.mediaGroupId
if (mediaGroupId == null) {
output(update)
continue
}
mediaGroupChannel.send("${mediaGroupId}${update::class.simpleName}" to update as BaseMessageUpdate)
}
}
launch {

View File

@ -66,12 +66,12 @@ suspend fun BehaviourContext.waitAudioMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContent<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContent<AudioMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitDocumentMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContent<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContent<DocumentMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitMedia(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
@ -81,12 +81,12 @@ suspend fun BehaviourContext.waitAnyMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContent<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContent<MediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitVisualMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContent<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContent<VisualMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitTextedMediaContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },

View File

@ -9,7 +9,6 @@ import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
@ -25,20 +24,7 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitContentMess
initRequest,
errorFactory
) {
val messages = when (it) {
is SentMediaGroupUpdate -> {
if (includeMediaGroups) {
it.data
} else {
emptyList()
}
}
is BaseSentMessageUpdate -> listOf(it.data)
else -> return@expectFlow emptyList()
}
messages.mapNotNull { message ->
(message as? CommonMessage<*>) ?.withContent<O>()
}
listOfNotNull((it.data as? CommonMessage<*>) ?.withContent<O>())
}
internal inline fun <reified T : MessageContent> contentMessageConverter(
@ -103,12 +89,12 @@ suspend fun BehaviourContext.waitAudioMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContentMessage<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContentMessage<AudioMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitDocumentMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContentMessage<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContentMessage<DocumentMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitMediaMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
@ -118,12 +104,12 @@ suspend fun BehaviourContext.waitAnyMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContentMessage<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContentMessage<MediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitVisualMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitContentMessage<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitContentMessage<VisualMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitTextedMediaContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },

View File

@ -15,7 +15,7 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedConte
initRequest: Request<*>? = null,
includeMediaGroups: Boolean = true,
noinline errorFactory: NullableRequestBuilder<*> = { null }
): Flow<O> = waitEditedContentMessage<O>(initRequest, includeMediaGroups, errorFactory).map { it.content }
): Flow<O> = waitEditedContentMessage<O>(initRequest, errorFactory).map { it.content }
suspend fun BehaviourContext.waitEditedMessageContent(
initRequest: Request<*>? = null,
@ -64,12 +64,12 @@ suspend fun BehaviourContext.waitEditedAudioMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContent<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContent<AudioMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitEditedDocumentMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContent<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContent<DocumentMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitEditedMedia(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
@ -79,12 +79,12 @@ suspend fun BehaviourContext.waitEditedAnyMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContent<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContent<MediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitEditedVisualMediaGroupContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContent<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContent<VisualMediaGroupPartContent>(initRequest, includeMediaGroups, errorFactory)
suspend fun BehaviourContext.waitEditedTextedMediaContent(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },

View File

@ -3,11 +3,11 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.utils.baseEditMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
import dev.inmo.tgbotapi.utils.RiskFeature
@ -17,7 +17,6 @@ import kotlinx.coroutines.flow.Flow
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedContentMessage(
initRequest: Request<*>? = null,
includeMediaGroups: Boolean = true,
noinline errorFactory: NullableRequestBuilder<*> = { null }
): Flow<CommonMessage<O>> = expectFlow(
initRequest,
@ -26,11 +25,7 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedConte
val messages = when (it) {
is BaseEditMessageUpdate -> {
val commonMessage = it.data.commonMessageOrNull() ?: return@expectFlow emptyList()
if (commonMessage !is MediaGroupMessage<*> || includeMediaGroups) {
listOf(commonMessage)
} else {
emptyList()
}
listOf(commonMessage)
}
else -> return@expectFlow emptyList()
}
@ -41,109 +36,103 @@ suspend inline fun <reified O : MessageContent> BehaviourContext.waitEditedConte
suspend fun BehaviourContext.waitEditedMessageContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<MessageContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<MessageContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedContactMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<ContactContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<ContactContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedDiceMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<DiceContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<DiceContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedGameMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<GameContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<GameContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedLocationMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<LocationContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<LocationContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedLiveLocationMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<LiveLocationContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<LiveLocationContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedStaticLocationMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<StaticLocationContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<StaticLocationContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedTextMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<TextContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<TextContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedVenueMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<VenueContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<VenueContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedAudioMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<AudioMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<AudioMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedDocumentMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<DocumentMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<DocumentMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedMediaMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = false
) = waitEditedContentMessage<MediaContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContentMessage<MediaContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedAnyMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<MediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<MediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedVisualMediaGroupContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<VisualMediaGroupContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<VisualMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedTextedMediaContentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = true
) = waitEditedContentMessage<TextedMediaContent>(initRequest, includeMediaGroups, errorFactory)
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<TextedMediaContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedAnimationMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<AnimationContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<AnimationContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedAudioMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = false
) = waitEditedContentMessage<AudioContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContentMessage<AudioContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedDocumentMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = false
) = waitEditedContentMessage<DocumentContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContentMessage<DocumentContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedPhotoMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = false
) = waitEditedContentMessage<PhotoContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContentMessage<PhotoContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedStickerMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<StickerContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<StickerContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedVideoMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null },
includeMediaGroups: Boolean = false
) = waitEditedContentMessage<VideoContent>(initRequest, includeMediaGroups, errorFactory)
) = waitEditedContentMessage<VideoContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedVideoNoteMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<VideoNoteContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<VideoNoteContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedVoiceMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<VoiceContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<VoiceContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitEditedInvoiceMessage(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEditedContentMessage<InvoiceContent>(initRequest, false, errorFactory)
) = waitEditedContentMessage<InvoiceContent>(initRequest, errorFactory)

View File

@ -7,6 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
@ -136,3 +139,15 @@ suspend fun BehaviourContext.waitWebAppDataEvents(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<WebAppData>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicClosed(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ForumTopicClosed>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicCreated(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ForumTopicCreated>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicReopened(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEvents<ForumTopicReopened>(initRequest, errorFactory)

View File

@ -7,6 +7,9 @@ import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
@ -133,3 +136,15 @@ suspend fun BehaviourContext.waitWebAppDataEventsMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<WebAppData>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicClosedEventsMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<ForumTopicClosed>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicCreatedEventsMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<ForumTopicCreated>(initRequest, errorFactory)
suspend fun BehaviourContext.waitForumTopicReopenedEventsMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = waitEventsMessages<ForumTopicReopened>(initRequest, errorFactory)

View File

@ -1,40 +1,46 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
typealias MediaGroupFilter<T> = SimpleFilter<List<MediaGroupMessage<T>>>
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun <reified O : MediaGroupContent> BehaviourContext.buildMediaGroupWaiter(
suspend inline fun <reified T : MediaGroupPartContent> BehaviourContext.buildMediaGroupWaiter(
initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }
): Flow<List<O>> = buildMediaGroupMessagesWaiter<O>(initRequest, errorFactory).map { it.map { it.content } }
): Flow<MediaGroupContent<T>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
update.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull<MediaGroupContent<*>>() ?.let { message ->
if (message.content.group.all { it is T }) {
listOf(message.content as MediaGroupContent<T>)
} else {
null
}
} ?: emptyList()
}
suspend fun BehaviourContext.waitMediaGroup(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupWaiter<MediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupWaiter<MediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitPlaylist(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupWaiter<AudioMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupWaiter<AudioMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitDocumentsGroup(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupWaiter<DocumentMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupWaiter<DocumentMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitVisualGallery(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupWaiter<VisualMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupWaiter<VisualMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitPhotoGallery(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }

View File

@ -1,44 +1,46 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContent
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
import dev.inmo.tgbotapi.requests.abstracts.Request
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.lowLevelRiskFeatureMessage
import kotlinx.coroutines.flow.Flow
@RiskFeature(lowLevelRiskFeatureMessage)
suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupMessagesWaiter(
suspend inline fun <reified T : MediaGroupPartContent> BehaviourContext.buildMediaGroupMessagesWaiter(
initRequest: Request<*>? = null,
noinline errorFactory: NullableRequestBuilder<*> = { null }
): Flow<List<MediaGroupMessage<T>>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
update.sentMediaGroupUpdateOrNull() ?.data ?.let { mediaGroup ->
val mapped = mediaGroup.mapNotNull { it.withContent<T>() }
listOf(
mapped
)
): Flow<MediaGroupMessage<T>> = flowsUpdatesFilter.expectFlow(bot, initRequest, errorFactory) { update ->
update.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull<MediaGroupContent<*>>() ?.let { message ->
if (message.content.group.all { it is T }) {
listOf(message as MediaGroupMessage<T>)
} else {
null
}
} ?: emptyList()
}
suspend fun BehaviourContext.waitMediaGroupMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupMessagesWaiter<MediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupMessagesWaiter<MediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitPlaylistMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupMessagesWaiter<AudioMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupMessagesWaiter<AudioMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitDocumentsGroupMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupMessagesWaiter<DocumentMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupMessagesWaiter<DocumentMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitVisualGalleryMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }
) = buildMediaGroupMessagesWaiter<VisualMediaGroupContent>(initRequest, errorFactory)
) = buildMediaGroupMessagesWaiter<VisualMediaGroupPartContent>(initRequest, errorFactory)
suspend fun BehaviourContext.waitPhotoGalleryMessages(
initRequest: Request<*>? = null,
errorFactory: NullableRequestBuilder<*> = { null }

View File

@ -3,18 +3,13 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupMessage
import dev.inmo.tgbotapi.types.update.abstracts.Update
/**
* Allow only messages which are not [MediaGroupMessage]
*/
val MessageFilterExcludingMediaGroups: BehaviourContextAndTwoTypesReceiver<Boolean, CommonMessage<*>, Update> = { _, update ->
update !is MediaGroupMessage<*>
}
/**
* Allow only messages which are not [MediaGroupMessage]
*/
val CommonMessageFilterExcludeMediaGroups = SimpleFilter<Message> {
it !is MediaGroupMessage<*>
it !is CommonMessage<*> || it.content !is MediaGroupContent<*>
}

View File

@ -0,0 +1,12 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
/**
* Allow only messages which are not in some forum
*/
val MessageFilterForums = SimpleFilter<Message> {
it.threadIdOrNull == null
}

View File

@ -14,7 +14,6 @@ import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
typealias CommonMessageFilter<T> = SimpleFilter<CommonMessage<T>>
@ -26,7 +25,6 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
when (it) {
is BaseSentMessageUpdate -> it.data.whenCommonMessage(::listOfNotNull)
is SentMediaGroupUpdate -> it.data
else -> null
} ?.mapNotNull { message ->
if (message.content is T) message as CommonMessage<T> else null
@ -287,7 +285,7 @@ suspend fun <BC : BehaviourContext> BC.onVenue(
* data
*/
suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
initialFilter: CommonMessageFilter<AudioMediaGroupContent>? = null,
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
@ -311,7 +309,7 @@ suspend fun <BC : BehaviourContext> BC.onAudioMediaGroup(
* data
*/
suspend fun <BC : BehaviourContext> BC.onDocumentMediaGroupContent(
initialFilter: CommonMessageFilter<DocumentMediaGroupContent>? = null,
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>

View File

@ -222,7 +222,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedVenue(
* data
*/
suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
initialFilter: CommonMessageFilter<AudioMediaGroupContent>? = null,
initialFilter: CommonMessageFilter<AudioMediaGroupPartContent>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, AudioMediaGroupMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in AudioMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, AudioMediaGroupMessage>
@ -246,7 +246,7 @@ suspend fun <BC : BehaviourContext> BC.onEditedAudioMediaGroup(
* data
*/
suspend fun <BC : BehaviourContext> BC.onEditedDocumentMediaGroupContent(
initialFilter: CommonMessageFilter<DocumentMediaGroupContent>? = null,
initialFilter: CommonMessageFilter<DocumentMediaGroupPartContent>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DocumentMediaGroupMessage, Update> = MessageFilterByChat,
markerFactory: MarkerFactory<in DocumentMediaGroupMessage, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DocumentMediaGroupMessage>

View File

@ -11,9 +11,13 @@ import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.chatEventMessageOrNull
import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.*
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicClosed
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicCreated
import dev.inmo.tgbotapi.types.message.ChatEvents.forum.ForumTopicReopened
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.PrivateEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.ChatEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.SupergroupEventMessage
import dev.inmo.tgbotapi.types.message.payments.SuccessfulPaymentEvent
import dev.inmo.tgbotapi.types.update.abstracts.Update
@ -27,6 +31,16 @@ internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.on
(it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? ChatEventMessage<T>) ?.let(::listOfNotNull)
}
internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent, reified CEM : ChatEventMessage<T>> BC.onEventWithCustomChatEventMessage(
initialFilter: SimpleFilter<CEM>? = null,
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CEM, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in CEM, Any> = ByChatMessageMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CEM>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
@Suppress("UNCHECKED_CAST")
(it.baseSentMessageUpdateOrNull() ?.data ?.chatEventMessageOrNull() ?.takeIf { it.chatEvent is T } as? CEM) ?.let(::listOfNotNull)
}
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
@ -503,12 +517,61 @@ suspend fun <BC : BehaviourContext> BC.onWebAppData(
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, PrivateEventMessage<WebAppData>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<WebAppData>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<WebAppData>>
) = onEvent(
initialFilter ?.let { { it is PrivateEventMessage<WebAppData> && initialFilter(it) } },
subcontextUpdatesFilter ?.let { { message: ChatEventMessage<WebAppData>, update: Update -> message is PrivateEventMessage<WebAppData> && subcontextUpdatesFilter(message, update) } },
markerFactory
) {
if (it is PrivateEventMessage<WebAppData>) {
scenarioReceiver(it)
}
}
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onForumTopicClosed(
initialFilter: SimpleFilter<SupergroupEventMessage<ForumTopicClosed>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<ForumTopicClosed>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicClosed>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicClosed>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onForumTopicCreated(
initialFilter: SimpleFilter<SupergroupEventMessage<ForumTopicCreated>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<ForumTopicCreated>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicCreated>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicCreated>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param markerFactory Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onForumTopicReopened(
initialFilter: SimpleFilter<SupergroupEventMessage<ForumTopicReopened>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, SupergroupEventMessage<ForumTopicReopened>, Update>? = MessageFilterByChat,
markerFactory: MarkerFactory<in ChatEventMessage<ForumTopicReopened>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, SupergroupEventMessage<ForumTopicReopened>>
) = onEventWithCustomChatEventMessage(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)

View File

@ -13,11 +13,20 @@ internal suspend inline fun <BC : BehaviourContext, reified T> BC.on(
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = null,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>,
noinline updateToData: (Update) -> List<T>?
) = flowsUpdatesFilter.expectFlow(bot) {
updateToData(it) ?.mapNotNull { data ->
if (initialFilter ?.invoke(data) != false) it to data else null
} ?: emptyList()
}.subscribeSafelyWithoutExceptionsAsync(
) = flowsUpdatesFilter.expectFlow(
bot,
filter = initialFilter ?.let {
{
updateToData(it) ?.mapNotNull { data ->
if (initialFilter(data)) it to data else null
} ?: emptyList()
}
} ?: {
updateToData(it) ?.mapNotNull { data ->
it to data
} ?: emptyList()
}
).subscribeSafelyWithoutExceptionsAsync(
scope,
{ markerFactory(it.second) }
) { (update, triggerData) ->

View File

@ -0,0 +1,164 @@
@file:Suppress("unused")
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.utils.PreviewFeature
@PreviewFeature
internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupPartContent> BC.buildMediaGroupMessagesTrigger(
initialFilter: SimpleFilter<MediaGroupMessage<T>>? = null,
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<T>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<T>, Any> = ByChatMessageMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<T>>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
it.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull<MediaGroupContent<*>>() ?.let {
if (it.content.group.all { it.content is T }) {
listOf(it as MediaGroupMessage<T>)
} else {
null
}
} ?: emptyList()
}
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onMediaGroupMessages(
initialFilter: SimpleFilter<MediaGroupMessage<MediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<MediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<MediaGroupPartContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<MediaGroupPartContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onPlaylistMessages(
initialFilter: SimpleFilter<MediaGroupMessage<AudioMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<AudioMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<AudioMediaGroupPartContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<AudioMediaGroupPartContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onDocumentsGroupMessages(
initialFilter: SimpleFilter<MediaGroupMessage<DocumentMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<DocumentMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<DocumentMediaGroupPartContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<DocumentMediaGroupPartContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onVisualGalleryMessages(
initialFilter: SimpleFilter<MediaGroupMessage<VisualMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<VisualMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<VisualMediaGroupPartContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<VisualMediaGroupPartContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onVisualMediaGroupMessages(
initialFilter: SimpleFilter<MediaGroupMessage<VisualMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<VisualMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<VisualMediaGroupPartContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<VisualMediaGroupPartContent>>
) = onVisualGalleryMessages(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onPhotoGalleryMessages(
initialFilter: SimpleFilter<MediaGroupMessage<PhotoContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<PhotoContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<PhotoContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<PhotoContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
* to combinate several filters
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
* data
*/
suspend fun <BC : BehaviourContext> BC.onVideoGalleryMessages(
initialFilter: SimpleFilter<MediaGroupMessage<VideoContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupMessage<VideoContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupMessage<VideoContent>, Any> = ByChatMessageMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupMessage<VideoContent>>
) = buildMediaGroupMessagesTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)

View File

@ -3,28 +3,31 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessagesFilterByChat
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMediaGroupMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.AnyMarkerFactory
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
import dev.inmo.tgbotapi.extensions.utils.sentMediaGroupUpdateOrNull
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.extensions.utils.baseSentMessageUpdateOrNull
import dev.inmo.tgbotapi.extensions.utils.commonMessageOrNull
import dev.inmo.tgbotapi.extensions.utils.withContentOrNull
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.utils.PreviewFeature
@PreviewFeature
internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupContent> BC.buildMediaGroupTrigger(
initialFilter: SimpleFilter<List<MediaGroupMessage<T>>>? = null,
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<T>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<T>>, Any> = ByChatMediaGroupMarkerFactory,
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<T>>>
internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupPartContent> BC.buildMediaGroupTrigger(
initialFilter: SimpleFilter<MediaGroupContent<T>>? = null,
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<T>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<T>, Any> = AnyMarkerFactory(),
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<T>>
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
(it.sentMediaGroupUpdateOrNull() ?.data ?.takeIf { messages ->
messages.all { message ->
message.content is T
it.baseSentMessageUpdateOrNull() ?.data ?.commonMessageOrNull() ?.withContentOrNull<MediaGroupContent<*>>() ?.let {
if (it.content.group.all { it.content is T }) {
listOf(it.content as MediaGroupContent<T>)
} else {
null
}
} as? List<MediaGroupMessage<T>>) ?.let(::listOfNotNull)
} ?: emptyList()
}
/**
@ -40,10 +43,10 @@ internal suspend inline fun <BC : BehaviourContext, reified T : MediaGroupConten
* data
*/
suspend fun <BC : BehaviourContext> BC.onMediaGroup(
initialFilter: SimpleFilter<List<MediaGroupMessage<MediaGroupContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<MediaGroupContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<MediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<MediaGroupContent>>>
initialFilter: SimpleFilter<MediaGroupContent<MediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<MediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<MediaGroupPartContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<MediaGroupPartContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -59,10 +62,10 @@ suspend fun <BC : BehaviourContext> BC.onMediaGroup(
* data
*/
suspend fun <BC : BehaviourContext> BC.onPlaylist(
initialFilter: SimpleFilter<List<MediaGroupMessage<AudioMediaGroupContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<AudioMediaGroupContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<AudioMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<AudioMediaGroupContent>>>
initialFilter: SimpleFilter<MediaGroupContent<AudioMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<AudioMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<AudioMediaGroupPartContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<AudioMediaGroupPartContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -78,10 +81,10 @@ suspend fun <BC : BehaviourContext> BC.onPlaylist(
* data
*/
suspend fun <BC : BehaviourContext> BC.onDocumentsGroup(
initialFilter: SimpleFilter<List<MediaGroupMessage<DocumentMediaGroupContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<DocumentMediaGroupContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<DocumentMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<DocumentMediaGroupContent>>>
initialFilter: SimpleFilter<MediaGroupContent<DocumentMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<DocumentMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<DocumentMediaGroupPartContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<DocumentMediaGroupPartContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -97,10 +100,10 @@ suspend fun <BC : BehaviourContext> BC.onDocumentsGroup(
* data
*/
suspend fun <BC : BehaviourContext> BC.onVisualGallery(
initialFilter: SimpleFilter<List<MediaGroupMessage<VisualMediaGroupContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<VisualMediaGroupContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<VisualMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<VisualMediaGroupContent>>>
initialFilter: SimpleFilter<MediaGroupContent<VisualMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<VisualMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<VisualMediaGroupPartContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<VisualMediaGroupPartContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -116,10 +119,10 @@ suspend fun <BC : BehaviourContext> BC.onVisualGallery(
* data
*/
suspend fun <BC : BehaviourContext> BC.onVisualMediaGroup(
initialFilter: SimpleFilter<List<MediaGroupMessage<VisualMediaGroupContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<VisualMediaGroupContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<VisualMediaGroupContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<VisualMediaGroupContent>>>
initialFilter: SimpleFilter<MediaGroupContent<VisualMediaGroupPartContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<VisualMediaGroupPartContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<VisualMediaGroupPartContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<VisualMediaGroupPartContent>>
) = onVisualGallery(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -135,10 +138,10 @@ suspend fun <BC : BehaviourContext> BC.onVisualMediaGroup(
* data
*/
suspend fun <BC : BehaviourContext> BC.onPhotoGallery(
initialFilter: SimpleFilter<List<MediaGroupMessage<PhotoContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<PhotoContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<PhotoContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<PhotoContent>>>
initialFilter: SimpleFilter<MediaGroupContent<PhotoContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<PhotoContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<PhotoContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<PhotoContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
/**
@ -154,8 +157,8 @@ suspend fun <BC : BehaviourContext> BC.onPhotoGallery(
* data
*/
suspend fun <BC : BehaviourContext> BC.onVideoGallery(
initialFilter: SimpleFilter<List<MediaGroupMessage<VideoContent>>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, List<MediaGroupMessage<VideoContent>>, Update>? = MessagesFilterByChat,
markerFactory: MarkerFactory<in List<MediaGroupMessage<VideoContent>>, Any> = ByChatMediaGroupMarkerFactory,
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, List<MediaGroupMessage<VideoContent>>>
initialFilter: SimpleFilter<MediaGroupContent<VideoContent>>? = null,
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MediaGroupContent<VideoContent>, Update>? = null,
markerFactory: MarkerFactory<in MediaGroupContent<VideoContent>, Any> = AnyMarkerFactory(),
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MediaGroupContent<VideoContent>>
) = buildMediaGroupTrigger(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)

View File

@ -0,0 +1,5 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
private val commonAnyMarker = MarkerFactory<Any, Any> { it }
fun <T> AnyMarkerFactory() = commonAnyMarker as MarkerFactory<T, T>

View File

@ -1,8 +0,0 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
import dev.inmo.tgbotapi.extensions.utils.shortcuts.chat
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
object ByChatMediaGroupMarkerFactory : MarkerFactory<List<MediaGroupMessage<*>>, Any> {
override suspend fun invoke(data: List<MediaGroupMessage<*>>) = data.chat ?: error("Data must not be empty")
}

View File

@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.abstracts.types.MessageAction
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializationStrategyClass
@ -18,11 +19,13 @@ data class ForwardMessage(
val toChatId: ChatIdentifier,
@SerialName(messageIdField)
override val messageId: MessageId,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
val disableNotification: Boolean = false,
@SerialName(protectContentField)
override val protectContent: Boolean = false
): SimpleRequest<PossiblyForwardedMessage>, MessageAction, ProtectContent {
): SimpleRequest<PossiblyForwardedMessage>, MessageAction, ProtectContent, OptionallyMessageThreadRequest {
override val chatId: ChatIdentifier
get() = fromChatId

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class CloseForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId
): ModifyForumRequest {
override fun method(): String = "closeForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,32 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class CreateForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(nameField)
val name: String,
@SerialName(iconColorField)
val color: RGBColor,
@SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId? = null,
): ForumRequest<ForumTopic> {
init {
if (name.length !in threadNameLength) {
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
}
}
override fun method(): String = "createForumTopic"
override val resultDeserializer: DeserializationStrategy<ForumTopic>
get() = ForumTopic.serializer()
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class DeleteForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId
): ModifyForumRequest {
override fun method(): String = "deleteForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,30 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class EditForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId,
@SerialName(nameField)
val name: String,
@SerialName(iconCustomEmojiIdField)
val iconEmojiId: CustomEmojiId,
): ModifyForumRequest {
init {
if (name.length !in threadNameLength) {
throw IllegalArgumentException("Thread name must be in $threadNameLength range")
}
}
override fun method(): String = "editForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,6 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
sealed interface ForumRequest<T : Any> : SimpleRequest<T>, ChatRequest

View File

@ -0,0 +1,10 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import kotlinx.serialization.DeserializationStrategy
import kotlinx.serialization.builtins.serializer
sealed interface ModifyForumRequest : ForumRequest<Boolean> {
override val resultDeserializer: DeserializationStrategy<Boolean>
get() = Boolean.serializer()
}

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class ReopenForumTopic (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId
): ModifyForumRequest {
override fun method(): String = "reopenForumTopic"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,20 @@
package dev.inmo.tgbotapi.requests.chat.forum
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.utils.RGBColor
import kotlinx.serialization.*
import kotlinx.serialization.builtins.serializer
@Serializable
data class UnpinAllForumTopicMessages (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@SerialName(messageThreadIdField)
val messageThreadId: MessageThreadId
): ModifyForumRequest {
override fun method(): String = "unpinAllForumTopicMessages"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
}

View File

@ -0,0 +1,23 @@
package dev.inmo.tgbotapi.requests.chat.get
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.files.StickerSerializer
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.builtins.serializer
@Serializable
object GetForumTopicIconStickers : SimpleRequest<List<Sticker>> {
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
private val deserializer = ListSerializer(StickerSerializer)
override fun method(): String = "getForumTopicIconStickers"
override val resultDeserializer: DeserializationStrategy<List<Sticker>>
get() = deserializer
}

View File

@ -35,7 +35,9 @@ data class PromoteChatMember(
@SerialName(canManageVideoChatsField)
private val canManageVideoChats: Boolean? = null,
@SerialName(canManageChatField)
private val canManageChat: Boolean? = null
private val canManageChat: Boolean? = null,
@SerialName(canManageTopicsField)
private val canManageTopics: Boolean? = null
) : ChatMemberRequest<Boolean>, UntilDate {
override fun method(): String = "promoteChatMember"
override val resultDeserializer: DeserializationStrategy<Boolean>

View File

@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.abstracts.TextedOutput
import dev.inmo.tgbotapi.abstracts.types.MessageAction
import dev.inmo.tgbotapi.abstracts.types.ProtectContent
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.requests.send.abstracts.OptionallyMessageThreadRequest
import dev.inmo.tgbotapi.requests.send.abstracts.ReplyingMarkupSendMessageRequest
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource
@ -26,6 +27,7 @@ fun CopyMessage(
messageId: MessageId,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -38,6 +40,7 @@ fun CopyMessage(
text,
parseMode,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -50,6 +53,7 @@ fun CopyMessage(
fromChatId: ChatIdentifier,
messageId: MessageId,
entities: List<TextSource>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -62,6 +66,7 @@ fun CopyMessage(
entities.makeString(),
null,
entities.toRawMessageEntities(),
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -75,6 +80,7 @@ fun CopyMessage(
toChatId: ChatIdentifier,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -87,6 +93,7 @@ fun CopyMessage(
text,
parseMode,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -99,6 +106,7 @@ fun CopyMessage(
messageId: MessageId,
toChatId: ChatIdentifier,
entities: List<TextSource>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -111,6 +119,7 @@ fun CopyMessage(
entities.makeString(),
null,
entities.toRawMessageEntities(),
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -132,6 +141,8 @@ data class CopyMessage internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
@ -146,7 +157,8 @@ data class CopyMessage internal constructor(
ReplyingMarkupSendMessageRequest<MessageId>,
MessageAction,
TextedOutput,
ProtectContent {
ProtectContent,
OptionallyMessageThreadRequest {
override val chatId: ChatIdentifier
get() = fromChatId
override val textSources: List<TextSource>? by lazy {

View File

@ -22,6 +22,8 @@ data class SendContact(
val firstName: String,
@SerialName(lastNameField)
val lastName: String? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
@ -38,6 +40,7 @@ data class SendContact(
constructor(
chatId: ChatIdentifier,
contact: Contact,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -48,6 +51,7 @@ data class SendContact(
contact.phoneNumber,
contact.firstName,
contact.lastName,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -64,6 +68,7 @@ data class SendContact(
fun Contact.toRequest(
chatId: ChatIdentifier,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -72,6 +77,7 @@ fun Contact.toRequest(
): SendContact = SendContact(
chatId,
this,
threadId,
disableNotification,
protectContent,
replyToMessageId,

View File

@ -20,6 +20,8 @@ data class SendDice(
override val chatId: ChatIdentifier,
@SerialName(emojiField)
val animationType: DiceAnimationType? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId?,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -18,6 +18,7 @@ fun SendLocation(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -31,6 +32,7 @@ fun SendLocation(
null,
null,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -42,12 +44,13 @@ fun SendStaticLocation(
chatId: ChatIdentifier,
latitude: Double,
longitude: Double,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = SendLocation(chatId, latitude, longitude, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
) = SendLocation(chatId, latitude, longitude, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply, replyMarkup)
fun SendLiveLocation(
chatId: ChatIdentifier,
@ -57,6 +60,7 @@ fun SendLiveLocation(
horizontalAccuracy: Meters? = null,
heading: Degrees? = null,
proximityAlertRadius: Meters? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -70,6 +74,7 @@ fun SendLiveLocation(
horizontalAccuracy,
heading,
proximityAlertRadius,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -93,6 +98,8 @@ data class SendLocation internal constructor(
override val heading: Degrees? = null,
@SerialName(proximityAlertRadiusField)
override val proximityAlertRadius: Meters? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -25,6 +25,7 @@ fun SendTextMessage(
text: String,
parseMode: ParseMode? = null,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -35,6 +36,7 @@ fun SendTextMessage(
text,
parseMode,
null,
threadId,
disableWebPagePreview,
disableNotification,
protectContent,
@ -47,6 +49,7 @@ fun SendTextMessage(
chatId: ChatIdentifier,
entities: TextSourcesList,
disableWebPagePreview: Boolean? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -57,6 +60,7 @@ fun SendTextMessage(
entities.makeString(),
null,
entities.toRawMessageEntities(),
threadId,
disableWebPagePreview,
disableNotification,
protectContent,
@ -75,6 +79,8 @@ data class SendTextMessage internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(entitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableWebPagePreviewField)
override val disableWebPagePreview: Boolean? = null,
@SerialName(disableNotificationField)

View File

@ -32,6 +32,8 @@ data class SendVenue(
val googlePlaceId: GooglePlaceId? = null,
@SerialName(googlePlaceTypeField)
val googlePlaceType: GooglePlaceType? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
@ -50,6 +52,7 @@ data class SendVenue(
constructor(
chatId: ChatIdentifier,
venue: Venue,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -65,6 +68,7 @@ data class SendVenue(
foursquareType = venue.foursquareType,
googlePlaceId = venue.googlePlaceId,
googlePlaceType = venue.googlePlaceType,
threadId = threadId,
disableNotification = disableNotification,
protectContent = protectContent,
replyToMessageId = replyToMessageId,
@ -81,6 +85,7 @@ data class SendVenue(
fun Venue.toRequest(
chatId: ChatIdentifier,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -89,6 +94,7 @@ fun Venue.toRequest(
): SendVenue = SendVenue(
chatId,
this,
threadId,
disableNotification,
protectContent,
replyToMessageId,

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.types.MessageThreadId
interface OptionallyMessageThreadRequest {
val threadId: MessageThreadId?
}

View File

@ -2,5 +2,6 @@ package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.abstracts.types.ChatRequest
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.MessageThreadId
interface SendChatMessageRequest<T: Any> : SimpleRequest<T>, ChatRequest

View File

@ -2,4 +2,8 @@ package dev.inmo.tgbotapi.requests.send.abstracts
import dev.inmo.tgbotapi.abstracts.types.*
interface SendMessageRequest<T: Any> : SendChatMessageRequest<T>, ReplyMessageId, DisableNotification, ProtectContent
interface SendMessageRequest<T: Any> : SendChatMessageRequest<T>,
ReplyMessageId,
DisableNotification,
ProtectContent,
OptionallyMessageThreadRequest

View File

@ -18,6 +18,8 @@ data class SendGame (
override val chatId: ChatIdentifier,
@SerialName(gameShortNameField)
val gameShortName: String,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -28,6 +28,7 @@ fun SendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -49,6 +50,7 @@ fun SendAnimation(
duration,
width,
height,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -74,6 +76,7 @@ fun SendAnimation(
duration: Long? = null,
width: Int? = null,
height: Int? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -95,6 +98,7 @@ fun SendAnimation(
duration,
width,
height,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -135,6 +139,8 @@ data class SendAnimationData internal constructor(
override val width: Int? = null,
@SerialName(heightField)
override val height: Int? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -29,6 +29,7 @@ fun SendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -50,6 +51,7 @@ fun SendAudio(
duration,
performer,
title,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -75,6 +77,7 @@ fun SendAudio(
duration: Long? = null,
performer: String? = null,
title: String? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -96,6 +99,7 @@ fun SendAudio(
duration,
performer,
title,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -136,6 +140,8 @@ data class SendAudioData internal constructor(
override val performer: String? = null,
@SerialName(titleField)
override val title: String? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -34,6 +34,7 @@ fun SendDocument(
thumb: InputFile? = null,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -53,6 +54,7 @@ fun SendDocument(
text,
parseMode,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -85,6 +87,7 @@ fun SendDocument(
document: InputFile,
thumb: InputFile? = null,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -104,6 +107,7 @@ fun SendDocument(
entities.makeString(),
null,
entities.toRawMessageEntities(),
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -148,6 +152,8 @@ data class SendDocumentData internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -6,29 +6,38 @@ import dev.inmo.tgbotapi.requests.send.abstracts.SendMessageRequest
import dev.inmo.tgbotapi.requests.send.media.base.*
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.media.*
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializerClass
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupPartContent
import dev.inmo.tgbotapi.types.message.content.AudioContent
import dev.inmo.tgbotapi.types.message.content.DocumentContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.asMediaGroupMessage
import kotlinx.serialization.*
import kotlinx.serialization.builtins.ListSerializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.json.JsonArray
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.buildJsonArray
import kotlinx.serialization.json.jsonPrimitive
const val rawSendingMediaGroupsWarning = "Media groups contains restrictions related to combinations of media" +
" types. Currently it is possible to combine photo + video OR audio OR documents"
@RiskFeature(rawSendingMediaGroupsWarning)
fun <T : MediaGroupContent> SendMediaGroup(
fun <T : MediaGroupPartContent> SendMediaGroup(
chatId: ChatIdentifier,
media: List<MediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
): Request<List<MediaGroupMessage<T>>> {
): Request<PossiblySentViaBotCommonMessage<T>> {
if (media.size !in mediaCountInMediaGroup) {
throwRangeError("Count of members in media group", mediaCountInMediaGroup, media.size)
}
@ -47,6 +56,7 @@ fun <T : MediaGroupContent> SendMediaGroup(
val data = SendMediaGroupData(
chatId,
media,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -60,7 +70,7 @@ fun <T : MediaGroupContent> SendMediaGroup(
data,
SendMediaGroupFiles(files)
)
}) as Request<List<MediaGroupMessage<T>>>
}) as Request<PossiblySentViaBotCommonMessage<T>>
}
/**
@ -72,11 +82,12 @@ fun <T : MediaGroupContent> SendMediaGroup(
inline fun SendPlaylist(
chatId: ChatIdentifier,
media: List<AudioMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = SendMediaGroup<AudioContent>(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
) = SendMediaGroup<AudioContent>(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Use this method to be sure that you are correctly sending documents media group
@ -87,11 +98,12 @@ inline fun SendPlaylist(
inline fun SendDocumentsGroup(
chatId: ChatIdentifier,
media: List<DocumentMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = SendMediaGroup<DocumentContent>(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
) = SendMediaGroup<DocumentContent>(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
/**
* Use this method to be sure that you are correctly sending visual media group
@ -103,20 +115,35 @@ inline fun SendDocumentsGroup(
inline fun SendVisualMediaGroup(
chatId: ChatIdentifier,
media: List<VisualMediaGroupMemberTelegramMedia>,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null
) = SendMediaGroup<VisualMediaGroupContent>(chatId, media, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
) = SendMediaGroup<VisualMediaGroupPartContent>(chatId, media, threadId, disableNotification, protectContent, replyToMessageId, allowSendingWithoutReply)
private val messagesListSerializer: KSerializer<List<MediaGroupMessage<MediaGroupContent>>>
= ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass())
private object MessagesListSerializer: KSerializer<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
private val serializer = ListSerializer(TelegramBotAPIMessageDeserializeOnlySerializerClass<PossiblySentViaBotCommonMessage<MediaGroupPartContent>>())
override val descriptor: SerialDescriptor = serializer.descriptor
override fun deserialize(decoder: Decoder): PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>> {
val messages = serializer.deserialize(decoder)
return messages.asMediaGroupMessage()
}
override fun serialize(encoder: Encoder, value: PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>) {
serializer.serialize(encoder, value.content.group.map { it.sourceMessage })
}
}
@Serializable
data class SendMediaGroupData internal constructor(
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
val media: List<MediaGroupMemberTelegramMedia> = emptyList(),
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)
@ -125,7 +152,8 @@ data class SendMediaGroupData internal constructor(
override val replyToMessageId: MessageId? = null,
@SerialName(allowSendingWithoutReplyField)
override val allowSendingWithoutReply: Boolean? = null
) : DataRequest<List<MediaGroupMessage<MediaGroupContent>>>, SendMessageRequest<List<MediaGroupMessage<MediaGroupContent>>> {
) : DataRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>,
SendMessageRequest<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>> {
@SerialName(mediaField)
private val convertedMedia: String
get() = buildJsonArray {
@ -138,8 +166,8 @@ data class SendMediaGroupData internal constructor(
override fun method(): String = "sendMediaGroup"
override val requestSerializer: SerializationStrategy<*>
get() = serializer()
override val resultDeserializer: DeserializationStrategy<List<MediaGroupMessage<MediaGroupContent>>>
get() = messagesListSerializer
override val resultDeserializer: DeserializationStrategy<PossiblySentViaBotCommonMessage<MediaGroupContent<MediaGroupPartContent>>>
get() = MessagesListSerializer
}
data class SendMediaGroupFiles internal constructor(

View File

@ -23,6 +23,7 @@ fun SendPhoto(
photo: InputFile,
text: String? = null,
parseMode: ParseMode? = null,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -35,6 +36,7 @@ fun SendPhoto(
text,
parseMode,
null,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -53,6 +55,7 @@ fun SendPhoto(
chatId: ChatIdentifier,
photo: InputFile,
entities: TextSourcesList,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -65,6 +68,7 @@ fun SendPhoto(
entities.makeString(),
null,
entities.toRawMessageEntities(),
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -94,6 +98,8 @@ data class SendPhotoData internal constructor(
override val parseMode: ParseMode? = null,
@SerialName(captionEntitiesField)
private val rawEntities: List<RawMessageEntity>? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

View File

@ -15,6 +15,7 @@ import kotlinx.serialization.json.JsonObject
fun SendSticker(
chatId: ChatIdentifier,
sticker: InputFile,
threadId: MessageThreadId? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
replyToMessageId: MessageId? = null,
@ -23,6 +24,7 @@ fun SendSticker(
): Request<ContentMessage<StickerContent>> = SendStickerByFileId(
chatId,
sticker as? FileId,
threadId,
disableNotification,
protectContent,
replyToMessageId,
@ -44,6 +46,8 @@ data class SendStickerByFileId internal constructor(
override val chatId: ChatIdentifier,
@SerialName(stickerField)
val sticker: FileId? = null,
@SerialName(messageThreadIdField)
override val threadId: MessageThreadId? = null,
@SerialName(disableNotificationField)
override val disableNotification: Boolean = false,
@SerialName(protectContentField)

Some files were not shown because too many files have changed in this diff Show More