1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +00:00

fixes in inaccessible message support

This commit is contained in:
InsanusMokrassar 2024-01-07 15:52:49 +06:00
parent 5190f7b856
commit b5f4219635
63 changed files with 493 additions and 390 deletions

View File

@ -6,9 +6,8 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent import dev.inmo.tgbotapi.types.message.content.MediaGroupCollectionContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -23,7 +22,7 @@ suspend fun TelegramBot.deleteMessage(
) = deleteMessage(chat.id, messageId) ) = deleteMessage(chat.id, messageId)
suspend fun TelegramBot.deleteMessage( suspend fun TelegramBot.deleteMessage(
message: Message message: AccessibleMessage
): Boolean { ): Boolean {
val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>) val mediaGroupContent = ((message as? ContentMessage<*>) ?.content as? MediaGroupCollectionContent<*>)
if (mediaGroupContent == null) { if (mediaGroupContent == null) {
@ -46,9 +45,9 @@ suspend fun TelegramBot.delete(
) = deleteMessage(chat, messageId) ) = deleteMessage(chat, messageId)
suspend fun TelegramBot.delete( suspend fun TelegramBot.delete(
message: Message message: AccessibleMessage
) = deleteMessage(message) ) = deleteMessage(message)
suspend fun Message.delete( suspend fun AccessibleMessage.delete(
requestsExecutor: TelegramBot requestsExecutor: TelegramBot
) = requestsExecutor.deleteMessage(this) ) = requestsExecutor.deleteMessage(this)

View File

@ -1,11 +1,9 @@
package dev.inmo.tgbotapi.extensions.api package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.DeleteMessage
import dev.inmo.tgbotapi.requests.DeleteMessages import dev.inmo.tgbotapi.requests.DeleteMessages
import dev.inmo.tgbotapi.requests.ForwardMessages
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.deleteMessages( suspend fun TelegramBot.deleteMessages(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -37,7 +35,7 @@ suspend fun TelegramBot.deleteMessages(
) )
suspend fun TelegramBot.deleteMessages( suspend fun TelegramBot.deleteMessages(
messages: List<Message> messages: List<AccessibleMessage>
) = messages.groupBy { it.chat }.map { (chat, messages) -> ) = messages.groupBy { it.chat }.map { (chat, messages) ->
deleteMessages( deleteMessages(
chatId = chat.id, chatId = chat.id,
@ -63,5 +61,5 @@ suspend fun TelegramBot.delete(
) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList())) ) = deleteMessages(chatId = chatId, messageIds = (listOf(firstMessageId, secondMessageId) + messageIds.toList()))
suspend fun TelegramBot.delete( suspend fun TelegramBot.delete(
messages: List<Message> messages: List<AccessibleMessage>
) = deleteMessages(messages) ) = deleteMessages(messages)

View File

@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.types.threadId
suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
@ -49,7 +49,7 @@ suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
message: Message, message: AccessibleMessage,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false
@ -57,7 +57,7 @@ suspend fun TelegramBot.forwardMessage(
suspend fun TelegramBot.forwardMessage( suspend fun TelegramBot.forwardMessage(
toChat: Chat, toChat: Chat,
message: Message, message: AccessibleMessage,
threadId: MessageThreadId? = toChat.id.threadId, threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false protectContent: Boolean = false

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.ForwardMessages import dev.inmo.tgbotapi.requests.ForwardMessages
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.forwardMessages( suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
@ -66,7 +66,7 @@ suspend fun TelegramBot.forwardMessages(
suspend fun TelegramBot.forwardMessages( suspend fun TelegramBot.forwardMessages(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messages: List<Message>, messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -141,7 +141,7 @@ suspend fun TelegramBot.forward(
suspend fun TelegramBot.forward( suspend fun TelegramBot.forward(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messages: List<Message>, messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,

View File

@ -2,39 +2,24 @@ package dev.inmo.tgbotapi.extensions.api
import korlibs.time.DateTime import korlibs.time.DateTime
import korlibs.time.TimeSpan import korlibs.time.TimeSpan
import dev.inmo.micro_utils.coroutines.LinkedSupervisorJob
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
import dev.inmo.tgbotapi.abstracts.types.WithReplyMarkup
import dev.inmo.tgbotapi.bot.TelegramBot 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.edit.location.live.editLiveLocation
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
import dev.inmo.tgbotapi.extensions.api.send.send
import dev.inmo.tgbotapi.extensions.api.send.sendLiveLocation
import dev.inmo.tgbotapi.requests.send.SendLiveLocation import dev.inmo.tgbotapi.requests.send.SendLiveLocation
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.location.LiveLocation import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.location.StaticLocation import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.LocationContent import dev.inmo.tgbotapi.types.message.content.LocationContent
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import io.ktor.utils.io.core.Closeable import io.ktor.utils.io.core.Closeable
import korlibs.time.millisecondsLong import korlibs.time.millisecondsLong
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlin.js.JsName
import kotlin.jvm.JvmName
import kotlin.math.ceil import kotlin.math.ceil
val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L
@ -253,7 +238,7 @@ suspend fun TelegramBot.startLiveLocation(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.replyWithLiveLocation( suspend inline fun TelegramBot.replyWithLiveLocation(
to: Message, to: AccessibleMessage,
scope: CoroutineScope, scope: CoroutineScope,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
@ -288,7 +273,7 @@ suspend inline fun TelegramBot.replyWithLiveLocation(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.replyWithLiveLocation( suspend inline fun TelegramBot.replyWithLiveLocation(
to: Message, to: AccessibleMessage,
scope: CoroutineScope, scope: CoroutineScope,
location: StaticLocation, location: StaticLocation,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.StopPoll
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -35,7 +35,7 @@ suspend fun TelegramBot.stopPoll(
*/ */
suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chatId: IdChatIdentifier, chatId: IdChatIdentifier,
message: Message, message: AccessibleMessage,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chatId, message.messageId, replyMarkup) ) = stopPoll(chatId, message.messageId, replyMarkup)
@ -45,6 +45,6 @@ suspend fun TelegramBot.stopPoll(
*/ */
suspend fun TelegramBot.stopPoll( suspend fun TelegramBot.stopPoll(
chat: Chat, chat: Chat,
message: Message, message: AccessibleMessage,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = stopPoll(chat.id, message.messageId, replyMarkup) ) = stopPoll(chat.id, message.messageId, replyMarkup)

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.chat.modify.PinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -20,6 +20,6 @@ suspend fun TelegramBot.pinChatMessage(
) = pinChatMessage(chat.id, messageId, disableNotification) ) = pinChatMessage(chat.id, messageId, disableNotification)
suspend fun TelegramBot.pinChatMessage( suspend fun TelegramBot.pinChatMessage(
message: Message, message: AccessibleMessage,
disableNotification: Boolean = false disableNotification: Boolean = false
) = pinChatMessage(message.chat.id, message.messageId, disableNotification) ) = pinChatMessage(message.chat.id, message.messageId, disableNotification)

View File

@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.requests.chat.modify.UnpinChatMessage
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.unpinChatMessage( suspend fun TelegramBot.unpinChatMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -18,5 +18,5 @@ suspend fun TelegramBot.unpinChatMessage(
) = unpinChatMessage(chat.id, messageId) ) = unpinChatMessage(chat.id, messageId)
suspend fun TelegramBot.unpinChatMessage( suspend fun TelegramBot.unpinChatMessage(
message: Message message: AccessibleMessage
) = unpinChatMessage(message.chat.id, message.messageId) ) = unpinChatMessage(message.chat.id, message.messageId)

View File

@ -14,7 +14,7 @@ import dev.inmo.tgbotapi.types.location.LiveLocation
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramMedia
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@ -181,7 +181,7 @@ suspend fun TelegramBot.edit(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.edit( suspend fun TelegramBot.edit(
message: Message, message: AccessibleMessage,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(message, replyMarkup) ) = editMessageReplyMarkup(message, replyMarkup)

View File

@ -11,7 +11,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MediaContent import dev.inmo.tgbotapi.types.message.content.MediaContent
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
@ -98,7 +98,7 @@ suspend fun <T> TelegramBot.editMessageCaption(
*/ */
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception") @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not media message this method will throw an exception")
suspend fun <T> TelegramBot.editMessageCaption( suspend fun <T> TelegramBot.editMessageCaption(
message: Message, message: AccessibleMessage,
entities: List<TextSource>, entities: List<TextSource>,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent { ): ContentMessage<MediaContent> where T : TextedWithTextSources, T : MediaContent {

View File

@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
/** /**
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] * @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
@ -35,7 +35,7 @@ suspend fun TelegramBot.editMessageReplyMarkup(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.editMessageReplyMarkup( suspend fun TelegramBot.editMessageReplyMarkup(
message: Message, message: AccessibleMessage,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup) ) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)

View File

@ -10,7 +10,7 @@ import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.utils.* import dev.inmo.tgbotapi.utils.*
@ -174,7 +174,7 @@ suspend fun TelegramBot.editMessageText(
*/ */
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText(
message: Message, message: AccessibleMessage,
entities: TextSourcesList, entities: TextSourcesList,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
@ -186,7 +186,7 @@ suspend fun TelegramBot.editMessageText(
*/ */
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText(
message: Message, message: AccessibleMessage,
separator: TextSource? = null, separator: TextSource? = null,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,
@ -199,7 +199,7 @@ suspend fun TelegramBot.editMessageText(
*/ */
@RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception") @RiskFeature("This method is unsafe due to absence of any guaranties about the type of message. In case if message is not text message this method will throw an exception")
suspend fun TelegramBot.editMessageText( suspend fun TelegramBot.editMessageText(
message: Message, message: AccessibleMessage,
separator: String, separator: String,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
replyMarkup: InlineKeyboardMarkup? = null, replyMarkup: InlineKeyboardMarkup? = null,

View File

@ -9,7 +9,7 @@ import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.message.ParseMode import dev.inmo.tgbotapi.types.message.ParseMode
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.types.threadId
/** /**
@ -186,7 +186,7 @@ suspend inline fun TelegramBot.copyMessage(
*/ */
suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
message: Message, message: AccessibleMessage,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
@ -203,7 +203,7 @@ suspend inline fun TelegramBot.copyMessage(
*/ */
suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage(
toChat: Chat, toChat: Chat,
message: Message, message: AccessibleMessage,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
threadId: MessageThreadId? = toChat.id.threadId, threadId: MessageThreadId? = toChat.id.threadId,
@ -220,7 +220,7 @@ suspend inline fun TelegramBot.copyMessage(
*/ */
suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
message: Message, message: AccessibleMessage,
entities: TextSourcesList, entities: TextSourcesList,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -236,7 +236,7 @@ suspend inline fun TelegramBot.copyMessage(
*/ */
suspend inline fun TelegramBot.copyMessage( suspend inline fun TelegramBot.copyMessage(
toChat: Chat, toChat: Chat,
message: Message, message: AccessibleMessage,
entities: TextSourcesList, entities: TextSourcesList,
threadId: MessageThreadId? = toChat.id.threadId, threadId: MessageThreadId? = toChat.id.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,

View File

@ -3,7 +3,7 @@ package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.CopyMessages import dev.inmo.tgbotapi.requests.send.CopyMessages
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
suspend fun TelegramBot.copyMessages( suspend fun TelegramBot.copyMessages(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
@ -66,7 +66,7 @@ suspend fun TelegramBot.copyMessages(
suspend fun TelegramBot.copyMessages( suspend fun TelegramBot.copyMessages(
toChatId: ChatIdentifier, toChatId: ChatIdentifier,
messages: List<Message>, messages: List<AccessibleMessage>,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,

View File

@ -22,8 +22,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPrice
@ -44,7 +43,7 @@ import kotlin.jvm.JvmName
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
phoneNumber: String, phoneNumber: String,
firstName: String, firstName: String,
lastName: String? = null, lastName: String? = null,
@ -70,7 +69,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
contact: Contact, contact: Contact,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -95,7 +94,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.replyWithDice( suspend inline fun TelegramBot.replyWithDice(
to: Message, to: AccessibleMessage,
animationType: DiceAnimationType? = null, animationType: DiceAnimationType? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -108,7 +107,7 @@ suspend inline fun TelegramBot.replyWithDice(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
animationType: DiceAnimationType, animationType: DiceAnimationType,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -124,7 +123,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -148,7 +147,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
location: StaticLocation, location: StaticLocation,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -173,7 +172,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
text: String, text: String,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
@ -199,7 +198,7 @@ suspend inline fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
entities: TextSourcesList, entities: TextSourcesList,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -223,7 +222,7 @@ suspend inline fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
separator: TextSource? = null, separator: TextSource? = null,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -238,7 +237,7 @@ suspend fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
separator: String, separator: String,
linkPreviewOptions: LinkPreviewOptions? = null, linkPreviewOptions: LinkPreviewOptions? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -256,7 +255,7 @@ suspend fun TelegramBot.reply(
* [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param * [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard] as a builders for that param
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
latitude: Double, latitude: Double,
longitude: Double, longitude: Double,
title: String, title: String,
@ -288,7 +287,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
location: StaticLocation, location: StaticLocation,
title: String, title: String,
address: String, address: String,
@ -319,7 +318,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
venue: Venue, venue: Venue,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -340,7 +339,7 @@ suspend inline fun TelegramBot.reply(
// Game // Game
suspend inline fun TelegramBot.replyWithGame( suspend inline fun TelegramBot.replyWithGame(
to: Message, to: AccessibleMessage,
gameShortName: String, gameShortName: String,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -351,7 +350,7 @@ suspend inline fun TelegramBot.replyWithGame(
) )
suspend inline fun TelegramBot.replyWithGame( suspend inline fun TelegramBot.replyWithGame(
to: Message, to: AccessibleMessage,
game: Game, game: Game,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -362,7 +361,7 @@ suspend inline fun TelegramBot.replyWithGame(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
game: Game, game: Game,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -374,7 +373,7 @@ suspend inline fun TelegramBot.reply(
// Animation // Animation
suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation(
to: Message, to: AccessibleMessage,
animation: InputFile, animation: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
@ -406,7 +405,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
animation: AnimationFile, animation: AnimationFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -421,7 +420,7 @@ suspend inline fun TelegramBot.reply(
) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendAnimation(to.chat, animation, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation(
to: Message, to: AccessibleMessage,
animation: InputFile, animation: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -451,7 +450,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
animation: AnimationFile, animation: AnimationFile,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -468,7 +467,7 @@ suspend inline fun TelegramBot.reply(
// Audio // Audio
suspend inline fun TelegramBot.replyWithAudio( suspend inline fun TelegramBot.replyWithAudio(
to: Message, to: AccessibleMessage,
audio: InputFile, audio: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
@ -483,7 +482,7 @@ suspend inline fun TelegramBot.replyWithAudio(
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
audio: AudioFile, audio: AudioFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -495,7 +494,7 @@ suspend inline fun TelegramBot.reply(
) = sendAudio(to.chat, audio, text, parseMode, title, to.threadIdOrNull, 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( suspend inline fun TelegramBot.replyWithAudio(
to: Message, to: AccessibleMessage,
audio: InputFile, audio: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: TextSourcesList, entities: TextSourcesList,
@ -509,7 +508,7 @@ suspend inline fun TelegramBot.replyWithAudio(
) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
audio: AudioFile, audio: AudioFile,
entities: TextSourcesList, entities: TextSourcesList,
title: String? = null, title: String? = null,
@ -523,7 +522,7 @@ suspend inline fun TelegramBot.reply(
// Documents // Documents
suspend inline fun TelegramBot.replyWithDocument( suspend inline fun TelegramBot.replyWithDocument(
to: Message, to: AccessibleMessage,
document: InputFile, document: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
@ -536,7 +535,7 @@ suspend inline fun TelegramBot.replyWithDocument(
) = sendDocument(to.chat, document, thumb, text, parseMode, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
document: DocumentFile, document: DocumentFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -548,7 +547,7 @@ suspend inline fun TelegramBot.reply(
) = sendDocument(to.chat, document, text, parseMode, to.threadIdOrNull, 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( suspend inline fun TelegramBot.replyWithDocument(
to: Message, to: AccessibleMessage,
document: InputFile, document: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: TextSourcesList, entities: TextSourcesList,
@ -560,7 +559,7 @@ suspend inline fun TelegramBot.replyWithDocument(
) = sendDocument(to.chat, document, thumb, entities, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
document: DocumentFile, document: DocumentFile,
entities: TextSourcesList, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -575,7 +574,7 @@ suspend inline fun TelegramBot.reply(
@RiskFeature(rawSendingMediaGroupsWarning) @RiskFeature(rawSendingMediaGroupsWarning)
suspend inline fun TelegramBot.replyWithMediaGroup( suspend inline fun TelegramBot.replyWithMediaGroup(
to: Message, to: AccessibleMessage,
media: List<MediaGroupMemberTelegramMedia>, media: List<MediaGroupMemberTelegramMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -583,7 +582,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup(
) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) ) = sendMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithPlaylist( suspend inline fun TelegramBot.replyWithPlaylist(
to: Message, to: AccessibleMessage,
media: List<AudioMediaGroupMemberTelegramMedia>, media: List<AudioMediaGroupMemberTelegramMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -591,7 +590,7 @@ suspend inline fun TelegramBot.replyWithPlaylist(
) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) ) = sendPlaylist(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithDocuments( suspend inline fun TelegramBot.replyWithDocuments(
to: Message, to: AccessibleMessage,
media: List<DocumentMediaGroupMemberTelegramMedia>, media: List<DocumentMediaGroupMemberTelegramMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -599,7 +598,7 @@ suspend inline fun TelegramBot.replyWithDocuments(
) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) ) = sendDocumentsGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
suspend inline fun TelegramBot.replyWithGallery( suspend inline fun TelegramBot.replyWithGallery(
to: Message, to: AccessibleMessage,
media: List<VisualMediaGroupMemberTelegramMedia>, media: List<VisualMediaGroupMemberTelegramMedia>,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -610,7 +609,7 @@ suspend inline fun TelegramBot.replyWithGallery(
// Photo // Photo
suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto(
to: Message, to: AccessibleMessage,
fileId: InputFile, fileId: InputFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -622,7 +621,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, fileId, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
photo: Photo, photo: Photo,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -634,7 +633,7 @@ suspend inline fun TelegramBot.reply(
) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photo, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
photoSize: PhotoSize, photoSize: PhotoSize,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -647,7 +646,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto(
to: Message, to: AccessibleMessage,
fileId: InputFile, fileId: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -658,7 +657,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, fileId, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
photo: Photo, photo: Photo,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -669,7 +668,7 @@ suspend inline fun TelegramBot.reply(
) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photo, entities, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
photoSize: PhotoSize, photoSize: PhotoSize,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -683,7 +682,7 @@ suspend inline fun TelegramBot.reply(
// Sticker // Sticker
suspend inline fun TelegramBot.replyWithSticker( suspend inline fun TelegramBot.replyWithSticker(
to: Message, to: AccessibleMessage,
sticker: InputFile, sticker: InputFile,
emoji: String? = null, emoji: String? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -693,7 +692,7 @@ suspend inline fun TelegramBot.replyWithSticker(
) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendSticker(to.chat, sticker, to.threadIdOrNull, emoji, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
sticker: Sticker, sticker: Sticker,
emoji: String? = null, emoji: String? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -706,7 +705,7 @@ suspend inline fun TelegramBot.reply(
// Videos // Videos
suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo(
to: Message, to: AccessibleMessage,
video: InputFile, video: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
text: String? = null, text: String? = null,
@ -722,7 +721,7 @@ suspend inline fun TelegramBot.replyWithVideo(
) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, thumb, text, parseMode, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
video: VideoFile, video: VideoFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -734,7 +733,7 @@ suspend inline fun TelegramBot.reply(
) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, text, parseMode, spoilered, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo(
to: Message, to: AccessibleMessage,
video: InputFile, video: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
entities: TextSourcesList, entities: TextSourcesList,
@ -749,7 +748,7 @@ suspend inline fun TelegramBot.replyWithVideo(
) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, thumb, entities, spoilered, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
video: VideoFile, video: VideoFile,
entities: TextSourcesList, entities: TextSourcesList,
spoilered: Boolean = false, spoilered: Boolean = false,
@ -763,7 +762,7 @@ suspend inline fun TelegramBot.reply(
// VideoNotes // VideoNotes
suspend inline fun TelegramBot.replyWithVideoNote( suspend inline fun TelegramBot.replyWithVideoNote(
to: Message, to: AccessibleMessage,
videoNote: InputFile, videoNote: InputFile,
thumb: InputFile? = null, thumb: InputFile? = null,
duration: Long? = null, duration: Long? = null,
@ -775,7 +774,7 @@ suspend inline fun TelegramBot.replyWithVideoNote(
) = sendVideoNote(to.chat, videoNote, thumb, duration, size, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
videoNote: VideoNoteFile, videoNote: VideoNoteFile,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -787,7 +786,7 @@ suspend inline fun TelegramBot.reply(
// Voice // Voice
suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice(
to: Message, to: AccessibleMessage,
voice: InputFile, voice: InputFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -799,7 +798,7 @@ suspend inline fun TelegramBot.replyWithVoice(
) = sendVoice(to.chat, voice, text, parseMode, duration, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
voice: VoiceFile, voice: VoiceFile,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -811,7 +810,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice(
to: Message, to: AccessibleMessage,
voice: InputFile, voice: InputFile,
entities: TextSourcesList, entities: TextSourcesList,
duration: Long? = null, duration: Long? = null,
@ -822,7 +821,7 @@ suspend inline fun TelegramBot.replyWithVoice(
) = sendVoice(to.chat, voice, entities, duration, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
voice: VoiceFile, voice: VoiceFile,
entities: TextSourcesList, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -839,7 +838,7 @@ suspend inline fun TelegramBot.reply(
* as a builder for that * as a builder for that
*/ */
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
title: String, title: String,
description: String, description: String,
payload: String, payload: String,
@ -867,7 +866,7 @@ suspend inline fun TelegramBot.reply(
// Polls // Polls
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
question: String, question: String,
options: List<String>, options: List<String>,
isAnonymous: Boolean = true, isAnonymous: Boolean = true,
@ -881,7 +880,7 @@ suspend inline fun TelegramBot.reply(
) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
poll: RegularPoll, poll: RegularPoll,
isClosed: Boolean = false, isClosed: Boolean = false,
question: String = poll.question, question: String = poll.question,
@ -896,7 +895,7 @@ suspend inline fun TelegramBot.reply(
) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
question: String, question: String,
options: List<String>, options: List<String>,
correctOptionId: Int, correctOptionId: Int,
@ -912,7 +911,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
quizPoll: QuizPoll, quizPoll: QuizPoll,
isClosed: Boolean = false, isClosed: Boolean = false,
question: String = quizPoll.question, question: String = quizPoll.question,
@ -929,7 +928,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
question: String, question: String,
options: List<String>, options: List<String>,
correctOptionId: Int, correctOptionId: Int,
@ -944,7 +943,7 @@ suspend inline fun TelegramBot.reply(
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, to.threadIdOrNull, 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( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
quizPoll: QuizPoll, quizPoll: QuizPoll,
entities: TextSourcesList, entities: TextSourcesList,
isClosed: Boolean = false, isClosed: Boolean = false,
@ -961,7 +960,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
poll: Poll, poll: Poll,
isClosed: Boolean = false, isClosed: Boolean = false,
question: String = poll.question, question: String = poll.question,
@ -1006,7 +1005,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
fromChatId: ChatIdentifier, fromChatId: ChatIdentifier,
messageId: MessageId, messageId: MessageId,
text: String? = null, text: String? = null,
@ -1030,7 +1029,7 @@ suspend inline fun TelegramBot.reply(
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
fromChat: Chat, fromChat: Chat,
messageId: MessageId, messageId: MessageId,
text: String? = null, text: String? = null,
@ -1042,8 +1041,8 @@ suspend inline fun TelegramBot.reply(
) = reply(to, fromChat.id, messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) ) = reply(to, fromChat.id, messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
copy: Message, copy: AccessibleMessage,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -1053,13 +1052,13 @@ suspend inline fun TelegramBot.reply(
) = reply(to, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup) ) = reply(to, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
content: MessageContent, content: MessageContent,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Message = execute( ): AccessibleMessage = execute(
content.createResend( content.createResend(
to.chat.id, to.chat.id,
to.threadIdOrNull, to.threadIdOrNull,
@ -1077,7 +1076,7 @@ suspend fun TelegramBot.reply(
* @see handleLiveLocation * @see handleLiveLocation
*/ */
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
message: Message, message: AccessibleMessage,
locationsFlow: Flow<EditLiveLocationInfo>, locationsFlow: Flow<EditLiveLocationInfo>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -1102,7 +1101,7 @@ suspend fun TelegramBot.reply(
@JvmName("replyLiveLocationWithLocation") @JvmName("replyLiveLocationWithLocation")
@JsName("replyLiveLocationWithLocation") @JsName("replyLiveLocationWithLocation")
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
message: Message, message: AccessibleMessage,
locationsFlow: Flow<Location>, locationsFlow: Flow<Location>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -1129,7 +1128,7 @@ suspend fun TelegramBot.reply(
@JvmName("replyLiveLocationWithLatLong") @JvmName("replyLiveLocationWithLatLong")
@JsName("replyLiveLocationWithLatLong") @JsName("replyLiveLocationWithLatLong")
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
message: Message, message: AccessibleMessage,
locationsFlow: Flow<Pair<Double, Double>>, locationsFlow: Flow<Pair<Double, Double>>,
liveTimeMillis: Long = defaultLivePeriodDelayMillis, liveTimeMillis: Long = defaultLivePeriodDelayMillis,
disableNotification: Boolean = false, disableNotification: Boolean = false,
@ -1149,7 +1148,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
mediaFile: TelegramMediaFile, mediaFile: TelegramMediaFile,
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
@ -1233,7 +1232,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
content: TextedMediaContent, content: TextedMediaContent,
text: String?, text: String?,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
@ -1307,7 +1306,7 @@ suspend fun TelegramBot.reply(
} }
suspend fun TelegramBot.reply( suspend fun TelegramBot.reply(
to: Message, to: AccessibleMessage,
content: TextedMediaContent, content: TextedMediaContent,
entities: TextSourcesList, entities: TextSourcesList,
disableNotification: Boolean = false, disableNotification: Boolean = false,

View File

@ -23,7 +23,7 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.files.Sticker import dev.inmo.tgbotapi.types.files.Sticker
import dev.inmo.tgbotapi.types.games.Game import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.* import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.* import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.payments.LabeledPrice import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency import dev.inmo.tgbotapi.types.payments.abstracts.Currency
@ -1166,7 +1166,7 @@ suspend inline fun TelegramBot.reply(
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
toChatId: IdChatIdentifier, toChatId: IdChatIdentifier,
toMessageId: MessageId, toMessageId: MessageId,
copy: Message, copy: AccessibleMessage,
text: String? = null, text: String? = null,
parseMode: ParseMode? = null, parseMode: ParseMode? = null,
threadId: MessageThreadId? = toChatId.threadId, threadId: MessageThreadId? = toChatId.threadId,

View File

@ -1,16 +1,12 @@
package dev.inmo.tgbotapi.extensions.api.send package dev.inmo.tgbotapi.extensions.api.send
import dev.inmo.tgbotapi.bot.TelegramBot import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.requests.send.SendAction
import dev.inmo.tgbotapi.requests.send.SetMessageReactions import dev.inmo.tgbotapi.requests.send.SetMessageReactions
import dev.inmo.tgbotapi.types.ChatIdentifier import dev.inmo.tgbotapi.types.ChatIdentifier
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.actions.*
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.types.reactions.Reaction
import dev.inmo.tgbotapi.types.threadId
suspend fun TelegramBot.setMessageReactions( suspend fun TelegramBot.setMessageReactions(
chatId: ChatIdentifier, chatId: ChatIdentifier,
@ -43,13 +39,13 @@ suspend fun TelegramBot.setMessageReaction(
) = setMessageReaction(chat.id, messageId, reaction, big) ) = setMessageReaction(chat.id, messageId, reaction, big)
suspend fun TelegramBot.setMessageReactions( suspend fun TelegramBot.setMessageReactions(
message: Message, message: AccessibleMessage,
reactions: List<Reaction>, reactions: List<Reaction>,
big: Boolean = false big: Boolean = false
) = setMessageReactions(message.chat, message.messageId, reactions, big) ) = setMessageReactions(message.chat, message.messageId, reactions, big)
suspend fun TelegramBot.setMessageReaction( suspend fun TelegramBot.setMessageReaction(
message: Message, message: AccessibleMessage,
reaction: Reaction?, reaction: Reaction?,
big: Boolean = false big: Boolean = false
) = setMessageReaction(message.chat, message.messageId, reaction, big) ) = setMessageReaction(message.chat, message.messageId, reaction, big)

View File

@ -6,24 +6,24 @@ import dev.inmo.tgbotapi.extensions.utils.extensions.sourceUser
import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery import dev.inmo.tgbotapi.types.InlineQueries.query.InlineQuery
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated import dev.inmo.tgbotapi.types.chat.member.ChatMemberUpdated
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
import dev.inmo.tgbotapi.types.payments.ShippingQuery import dev.inmo.tgbotapi.types.payments.ShippingQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
/** /**
* Allow only events from the same chat as base [Message] * Allow only events from the same chat as base [AccessibleMessage]
*/ */
val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, Message, Update> = { message, update -> val MessageFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, AccessibleMessage, Update> = { message, update ->
update.sourceChat() ?.let { update.sourceChat() ?.let {
it.id == message.chat.id it.id == message.chat.id
} != false } != false
} }
/** /**
* Allow only events from the same chat as base [List] of [Message] * Allow only events from the same chat as base [List] of [AccessibleMessage]
*/ */
val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, List<Message>, Update> = { messages, update -> val MessagesFilterByChat: BehaviourContextAndTwoTypesReceiver<Boolean, List<AccessibleMessage>, Update> = { messages, update ->
val sourceChatId = update.sourceChat() ?.id val sourceChatId = update.sourceChat() ?.id
sourceChatId != null && messages.all { sourceChatId == it.chat.id } sourceChatId != null && messages.all { sourceChatId == it.chat.id }
} }

View File

@ -1,15 +1,13 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters 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.extensions.behaviour_builder.utils.SimpleFilter
import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.*
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
import dev.inmo.tgbotapi.types.message.content.MediaGroupMessage import dev.inmo.tgbotapi.types.message.content.MediaGroupMessage
import dev.inmo.tgbotapi.types.update.abstracts.Update
/** /**
* Allow only messages which are not [MediaGroupMessage] * Allow only messages which are not [MediaGroupMessage]
*/ */
val CommonMessageFilterExcludeMediaGroups = SimpleFilter<Message> { val CommonMessageFilterExcludeMediaGroups = SimpleFilter<AccessibleMessage> {
it !is CommonMessage<*> || it.content !is MediaGroupContent<*> it !is CommonMessage<*> || it.content !is MediaGroupContent<*>
} }

View File

@ -7,6 +7,6 @@ import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
/** /**
* Allow only messages which are not in some forum * Allow only messages which are not in some forum
*/ */
val MessageFilterForums = SimpleFilter<Message> { val MessageFilterForums = SimpleFilter<AccessibleMessage> {
it.threadIdOrNull == null it.threadIdOrNull == null
} }

View File

@ -2,12 +2,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories
import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.*
object ByChatMessageMarkerFactory : MarkerFactory<Message, Any> { object ByChatMessageMarkerFactory : MarkerFactory<AccessibleMessage, Any> {
override suspend fun invoke(data: Message) = data.chat override suspend fun invoke(data: AccessibleMessage) = data.chat
} }
object ByUserMessageMarkerFactory : MarkerFactory<Message, Any> { object ByUserMessageMarkerFactory : MarkerFactory<AccessibleMessage, Any> {
override suspend fun invoke(data: Message) = when (data) { override suspend fun invoke(data: AccessibleMessage) = when (data) {
is FromUserMessage -> data.user is FromUserMessage -> data.user
is FromChannelGroupContentMessage<*> -> data.channel is FromChannelGroupContentMessage<*> -> data.channel
else -> data.chat // including anonymous else -> data.chat // including anonymous

View File

@ -1,6 +1,5 @@
package dev.inmo.tgbotapi.requests package dev.inmo.tgbotapi.requests
import dev.inmo.tgbotapi.requests.abstracts.SimpleRequest
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.update.abstracts.Update import dev.inmo.tgbotapi.types.update.abstracts.Update
import dev.inmo.tgbotapi.types.update.abstracts.UpdateSerializerWithoutSerialization import dev.inmo.tgbotapi.types.update.abstracts.UpdateSerializerWithoutSerialization
@ -15,7 +14,7 @@ private val updatesListSerializer = ListSerializer(
* Request updates from Telegram Bot API system. It is important, that the result updates WILL NOT include * Request updates from Telegram Bot API system. It is important, that the result updates WILL NOT include
* [dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate] objects due to the fact, * [dev.inmo.tgbotapi.types.update.MediaGroupUpdates.MediaGroupUpdate] objects due to the fact,
* that it is internal abstraction and in fact any [dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage] * that it is internal abstraction and in fact any [dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage]
* is just a common [dev.inmo.tgbotapi.types.message.abstracts.Message] * is just a common [dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage]
* *
* @see dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation * @see dev.inmo.tgbotapi.extensions.utils.updates.retrieving.updateHandlerWithMediaGroupsAdaptation
* @see dev.inmo.tgbotapi.utils.convertWithMediaGroupUpdates * @see dev.inmo.tgbotapi.utils.convertWithMediaGroupUpdates

View File

@ -2,10 +2,10 @@ package dev.inmo.tgbotapi.types.chat
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.colors.ColorId import dev.inmo.tgbotapi.types.colors.ColorId
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer import dev.inmo.tgbotapi.types.message.abstracts.TelegramBotAPIMessageDeserializeOnlySerializer
import dev.inmo.tgbotapi.types.reactions.Reaction import dev.inmo.tgbotapi.types.reactions.Reaction
import korlibs.time.DateTime
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
@Serializable(ExtendedChatSerializer.Companion::class) @Serializable(ExtendedChatSerializer.Companion::class)

View File

@ -1,9 +1,7 @@
package dev.inmo.tgbotapi.types.giveaway package dev.inmo.tgbotapi.types.giveaway
import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChannelEvent import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
import dev.inmo.tgbotapi.types.message.abstracts.Message
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import kotlinx.serialization.Transient import kotlinx.serialization.Transient
@ -12,5 +10,5 @@ data class GiveawayPrivateResults(
override val chat: PreviewChat, override val chat: PreviewChat,
override val unclaimedCount: Int, override val unclaimedCount: Int,
@Transient // TODO::Add message serializer @Transient // TODO::Add message serializer
val message: Message? = null val message: AccessibleMessage? = null
) : GiveawayResults ) : GiveawayResults

View File

@ -3,7 +3,6 @@ package dev.inmo.tgbotapi.types.message
import korlibs.time.DateTime import korlibs.time.DateTime
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.ChannelChat
import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonBot
import dev.inmo.tgbotapi.types.chat.PreviewChannelChat import dev.inmo.tgbotapi.types.chat.PreviewChannelChat
import dev.inmo.tgbotapi.types.message.abstracts.* import dev.inmo.tgbotapi.types.message.abstracts.*
@ -17,7 +16,7 @@ data class ChannelContentMessageImpl<T: MessageContent>(
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val authorSignature: AuthorSignature?, override val authorSignature: AuthorSignature?,

View File

@ -1,6 +1,7 @@
package dev.inmo.tgbotapi.types.message.ChatEvents package dev.inmo.tgbotapi.types.message.ChatEvents
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.CommonEvent
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
data class PinnedMessage( data class PinnedMessage(

View File

@ -17,7 +17,7 @@ data class ConnectedFromChannelGroupContentMessageImpl<T : MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -33,7 +33,7 @@ data class UnconnectedFromChannelGroupContentMessageImpl<T: MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -48,7 +48,7 @@ data class AnonymousGroupContentMessageImpl<T : MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -64,7 +64,7 @@ data class CommonGroupContentMessageImpl<T : MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -80,7 +80,7 @@ data class FromChannelForumContentMessageImpl<T: MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -96,7 +96,7 @@ data class AnonymousForumContentMessageImpl<T : MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
@ -113,7 +113,7 @@ data class CommonForumContentMessageImpl<T : MessageContent>(
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val content: T, override val content: T,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,

View File

@ -3,10 +3,9 @@ package dev.inmo.tgbotapi.types.message
import korlibs.time.DateTime import korlibs.time.DateTime
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.passport.PassportData import dev.inmo.tgbotapi.types.passport.PassportData
data class PassportMessage( data class PassportMessage(
@ -15,4 +14,4 @@ data class PassportMessage(
override val from: User, override val from: User,
override val date: DateTime, override val date: DateTime,
val passportData: PassportData val passportData: PassportData
) : Message, FromUserMessage ) : AccessibleMessage, FromUserMessage

View File

@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.chat.CommonBot import dev.inmo.tgbotapi.types.chat.CommonBot
import dev.inmo.tgbotapi.types.chat.User import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage import dev.inmo.tgbotapi.types.message.abstracts.PrivateContentMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
@ -19,7 +19,7 @@ data class PrivateContentMessageImpl<T: MessageContent>(
override val editDate: DateTime?, override val editDate: DateTime?,
override val hasProtectedContent: Boolean, override val hasProtectedContent: Boolean,
override val forwardInfo: ForwardInfo?, override val forwardInfo: ForwardInfo?,
override val replyTo: Message?, override val replyTo: AccessibleMessage?,
override val replyMarkup: InlineKeyboardMarkup?, override val replyMarkup: InlineKeyboardMarkup?,
override val senderBot: CommonBot?, override val senderBot: CommonBot?,
override val mediaGroupId: MediaGroupIdentifier?, override val mediaGroupId: MediaGroupIdentifier?,

View File

@ -286,7 +286,7 @@ internal data class RawMessage(
} }
} }
val asMessage: Message by lazy { val asMessage: AccessibleMessage by lazy {
if (date.date == 0L) { if (date.date == 0L) {
return@lazy InaccessibleMessage( return@lazy InaccessibleMessage(
chat, chat,

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent import dev.inmo.tgbotapi.types.message.ChatEvents.abstracts.ChatEvent
interface ChatEventMessage<T : ChatEvent> : Message { interface ChatEventMessage<T : ChatEvent> : AccessibleMessage {
val chatEvent: T val chatEvent: T
} }

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
sealed interface CommonMessage<out T: MessageContent> : Message, sealed interface CommonMessage<out T: MessageContent> : AccessibleMessage,
PossiblyForwardedMessage, PossiblyForwardedMessage,
PossiblyEditedMessage, PossiblyEditedMessage,
PossiblyReplyMessage, PossiblyReplyMessage,

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
interface ContentMessage<out T: MessageContent>: Message { interface ContentMessage<out T: MessageContent>: AccessibleMessage {
val hasProtectedContent: Boolean val hasProtectedContent: Boolean
val content: T val content: T

View File

@ -2,4 +2,4 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.abstracts.FromUser import dev.inmo.tgbotapi.abstracts.FromUser
interface FromUserMessage : FromUser, Message interface FromUserMessage : FromUser, AccessibleMessage

View File

@ -1,12 +1,9 @@
package dev.inmo.tgbotapi.types.message.abstracts package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.abstracts.WithMessageId
import korlibs.time.DateTime import korlibs.time.DateTime
import dev.inmo.tgbotapi.abstracts.WithPreviewChat
import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId import dev.inmo.tgbotapi.abstracts.WithPreviewChatAndMessageId
import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded import dev.inmo.tgbotapi.utils.internal.ClassCastsIncluded
import dev.inmo.tgbotapi.types.MessageId import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.chat.PreviewChat import dev.inmo.tgbotapi.types.chat.PreviewChat
import dev.inmo.tgbotapi.types.message.RawMessage import dev.inmo.tgbotapi.types.message.RawMessage
import kotlinx.serialization.* import kotlinx.serialization.*
@ -19,11 +16,13 @@ interface Message : WithPreviewChatAndMessageId {
val date: DateTime val date: DateTime
} }
interface AccessibleMessage : Message
@Serializable @Serializable
data class InaccessibleMessage( data class InaccessibleMessage(
override val chat: PreviewChat, override val chat: PreviewChat,
override val messageId: MessageId, override val messageId: MessageId,
) : Message { ) : AccessibleMessage {
override val date: DateTime override val date: DateTime
get() = DateTime.invoke(0L) get() = DateTime.invoke(0L)
} }
@ -33,7 +32,7 @@ data class UnknownMessageType(
override val chat: PreviewChat, override val chat: PreviewChat,
override val date: DateTime, override val date: DateTime,
val insideException: Exception val insideException: Exception
) : Message ) : AccessibleMessage
internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> { internal class TelegramBotAPIMessageDeserializationStrategyClass<T> : DeserializationStrategy<T> {
@OptIn(InternalSerializationApi::class) @OptIn(InternalSerializationApi::class)

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import korlibs.time.DateTime import korlibs.time.DateTime
interface PossiblyEditedMessage : Message { interface PossiblyEditedMessage : AccessibleMessage {
val editDate: DateTime? val editDate: DateTime?
} }

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.ForwardInfo
interface PossiblyForwardedMessage : Message { interface PossiblyForwardedMessage : AccessibleMessage {
val forwardInfo: ForwardInfo? val forwardInfo: ForwardInfo?
} }

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo import dev.inmo.tgbotapi.types.message.payments.abstracts.PaymentInfo
interface PossiblyPaymentMessage : Message { interface PossiblyPaymentMessage : AccessibleMessage {
val paymentInfo: PaymentInfo? val paymentInfo: PaymentInfo?
} }

View File

@ -1,5 +1,5 @@
package dev.inmo.tgbotapi.types.message.abstracts package dev.inmo.tgbotapi.types.message.abstracts
interface PossiblyReplyMessage { interface PossiblyReplyMessage {
val replyTo: Message? val replyTo: AccessibleMessage?
} }

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
interface PossiblyTopicMessage : Message { interface PossiblyTopicMessage : AccessibleMessage {
val threadId: MessageThreadId? val threadId: MessageThreadId?
} }

View File

@ -2,6 +2,6 @@ package dev.inmo.tgbotapi.types.message.abstracts
import dev.inmo.tgbotapi.types.AuthorSignature import dev.inmo.tgbotapi.types.AuthorSignature
interface SignedMessage : Message { interface SignedMessage : AccessibleMessage {
val authorSignature: AuthorSignature? val authorSignature: AuthorSignature?
} }

View File

@ -165,5 +165,5 @@ sealed interface ResendableContent {
replyToMessageId: MessageId? = null, replyToMessageId: MessageId? = null,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
): Request<out Message> ): Request<out AccessibleMessage>
} }

View File

@ -10,7 +10,6 @@ import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.files.TelegramMediaFile import dev.inmo.tgbotapi.types.files.TelegramMediaFile
import dev.inmo.tgbotapi.types.media.TelegramMedia import dev.inmo.tgbotapi.types.media.TelegramMedia
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.textsources.TextSource import dev.inmo.tgbotapi.types.message.textsources.TextSource
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -7,8 +7,6 @@ import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
import dev.inmo.tgbotapi.types.stories.Story import dev.inmo.tgbotapi.types.stories.Story
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable

View File

@ -0,0 +1,9 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.MessageContent
sealed interface AbstractMessageCallbackQuery : CallbackQuery {
val message: Message
}

View File

@ -0,0 +1,7 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
sealed interface InaccessibleMessageCallbackQuery : AbstractMessageCallbackQuery {
override val message: InaccessibleMessage
}

View File

@ -0,0 +1,16 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent
data class InaccessibleMessageDataCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: CommonUser,
override val chatInstance: String,
override val message: InaccessibleMessage,
override val data: String
) : DataCallbackQuery, InaccessibleMessageCallbackQuery

View File

@ -0,0 +1,16 @@
package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.CallbackQueryIdentifier
import dev.inmo.tgbotapi.types.chat.CommonUser
import dev.inmo.tgbotapi.types.chat.User
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent
data class InaccessibleMessageGameShortNameCallbackQuery(
override val id: CallbackQueryIdentifier,
override val from: CommonUser,
override val chatInstance: String,
override val message: InaccessibleMessage,
override val gameShortName: String
) : GameShortNameCallbackQuery, InaccessibleMessageCallbackQuery

View File

@ -3,6 +3,6 @@ package dev.inmo.tgbotapi.types.queries.callback
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
import dev.inmo.tgbotapi.types.message.content.MessageContent import dev.inmo.tgbotapi.types.message.content.MessageContent
sealed interface MessageCallbackQuery : CallbackQuery { sealed interface MessageCallbackQuery : AbstractMessageCallbackQuery {
val message: ContentMessage<MessageContent> override val message: ContentMessage<MessageContent>
} }

View File

@ -16,7 +16,7 @@ internal data class RawCallbackQuery(
@SerialName(fromField) @SerialName(fromField)
val from: CommonUser, val from: CommonUser,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
val message: ContentMessage<MessageContent>? = null, val message: Message? = null,
@SerialName(inlineMessageIdField) @SerialName(inlineMessageIdField)
val inlineMessageId: InlineMessageIdentifier? = null, val inlineMessageId: InlineMessageIdentifier? = null,
@SerialName("chat_instance") @SerialName("chat_instance")
@ -28,8 +28,26 @@ internal data class RawCallbackQuery(
private var inited: CallbackQuery? = null private var inited: CallbackQuery? = null
fun asCallbackQuery(raw: String): CallbackQuery { fun asCallbackQuery(raw: String): CallbackQuery {
return inited ?: when { return inited ?: when {
message != null && data != null -> MessageDataCallbackQuery(id, from, chatInstance, message, data) message != null && data != null -> when {
message != null && gameShortName != null -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName) message is ContentMessage<*> -> MessageDataCallbackQuery(id, from, chatInstance, message, data)
message is InaccessibleMessage -> InaccessibleMessageDataCallbackQuery(id, from, chatInstance, message, data)
else -> UnknownCallbackQueryType(
id,
from,
chatInstance,
raw
)
}
message != null && gameShortName != null -> when {
message is ContentMessage<*> -> MessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName)
message is InaccessibleMessage -> InaccessibleMessageGameShortNameCallbackQuery(id, from, chatInstance, message, gameShortName)
else -> UnknownCallbackQueryType(
id,
from,
chatInstance,
raw
)
}
inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data) inlineMessageId != null && data != null -> InlineMessageIdDataCallbackQuery(id, from, chatInstance, inlineMessageId, data)
inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName) inlineMessageId != null && gameShortName != null -> InlineMessageIdGameShortNameCallbackQuery(id, from, chatInstance, inlineMessageId, gameShortName)
else -> UnknownCallbackQueryType( else -> UnknownCallbackQueryType(

View File

@ -1,12 +1,12 @@
package dev.inmo.tgbotapi.types.update package dev.inmo.tgbotapi.types.update
import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
data class ChannelPostUpdate( data class ChannelPostUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: AccessibleMessage
) : BaseSentMessageUpdate { ) : BaseSentMessageUpdate {
override fun copy(newData: Message): BaseSentMessageUpdate = copy(updateId, newData) override fun copy(newData: AccessibleMessage): BaseSentMessageUpdate = copy(updateId, newData)
} }

View File

@ -1,12 +1,12 @@
package dev.inmo.tgbotapi.types.update package dev.inmo.tgbotapi.types.update
import dev.inmo.tgbotapi.types.UpdateIdentifier import dev.inmo.tgbotapi.types.UpdateIdentifier
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
data class MessageUpdate( data class MessageUpdate(
override val updateId: UpdateIdentifier, override val updateId: UpdateIdentifier,
override val data: Message override val data: AccessibleMessage
) : BaseSentMessageUpdate { ) : BaseSentMessageUpdate {
override fun copy(newData: Message) = copy(updateId, newData) override fun copy(newData: AccessibleMessage) = copy(updateId, newData)
} }

View File

@ -28,11 +28,11 @@ internal data class RawUpdate constructor(
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val edited_message: CommonMessage<*>? = null, private val edited_message: CommonMessage<*>? = null,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val message: Message? = null, private val message: AccessibleMessage? = null,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val edited_channel_post: CommonMessage<*>? = null, private val edited_channel_post: CommonMessage<*>? = null,
@Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class) @Serializable(TelegramBotAPIMessageDeserializeOnlySerializer::class)
private val channel_post: Message? = null, private val channel_post: AccessibleMessage? = null,
private val inline_query: RawInlineQuery? = null, private val inline_query: RawInlineQuery? = null,
private val chosen_inline_result: RawChosenInlineResult? = null, private val chosen_inline_result: RawChosenInlineResult? = null,
private val callback_query: RawCallbackQuery? = null, private val callback_query: RawCallbackQuery? = null,

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.update.abstracts package dev.inmo.tgbotapi.types.update.abstracts
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
interface BaseMessageUpdate : Update { interface BaseMessageUpdate : Update {
override val data: Message override val data: AccessibleMessage
} }

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.types.update.abstracts package dev.inmo.tgbotapi.types.update.abstracts
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
interface BaseSentMessageUpdate : BaseMessageUpdate { interface BaseSentMessageUpdate : BaseMessageUpdate {
fun copy(newData: Message): BaseSentMessageUpdate fun copy(newData: AccessibleMessage): BaseSentMessageUpdate
} }

View File

@ -1,7 +1,7 @@
package dev.inmo.tgbotapi.utils.extensions package dev.inmo.tgbotapi.utils.extensions
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyTopicMessage
val Message.threadIdOrNull val AccessibleMessage.threadIdOrNull
get() = (this as? PossiblyTopicMessage) ?.threadId get() = (this as? PossiblyTopicMessage) ?.threadId

View File

@ -978,346 +978,346 @@ inline fun SecureValue.requireSecureValueWithTranslations(): SecureValueWithTran
this as SecureValueWithTranslations this as SecureValueWithTranslations
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenAnonymousGroupContentMessageImpl(block: (AnonymousGroupContentMessageImpl<MessageContent>) -> T) =
asAnonymousGroupContentMessageImpl()?.let(block) asAnonymousGroupContentMessageImpl()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl<MessageContent>? = inline fun AccessibleMessage.asAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl<MessageContent>? =
this as? AnonymousGroupContentMessageImpl<MessageContent> this as? AnonymousGroupContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl<MessageContent> = inline fun AccessibleMessage.requireAnonymousGroupContentMessageImpl(): AnonymousGroupContentMessageImpl<MessageContent> =
this as AnonymousGroupContentMessageImpl<MessageContent> this as AnonymousGroupContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenChannelContentMessageImpl(block: (UnconnectedFromChannelGroupContentMessageImpl<MessageContent>) -> T) =
asChannelContentMessageImpl()?.let(block) asChannelContentMessageImpl()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl<MessageContent>? = inline fun AccessibleMessage.asChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl<MessageContent>? =
this as? UnconnectedFromChannelGroupContentMessageImpl<MessageContent> this as? UnconnectedFromChannelGroupContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl<MessageContent> = inline fun AccessibleMessage.requireChannelContentMessageImpl(): UnconnectedFromChannelGroupContentMessageImpl<MessageContent> =
this as UnconnectedFromChannelGroupContentMessageImpl<MessageContent> this as UnconnectedFromChannelGroupContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block) inline fun <T> AccessibleMessage.whenPassportMessage(block: (PassportMessage) -> T) = asPassportMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPassportMessage(): PassportMessage? = this as? PassportMessage inline fun AccessibleMessage.asPassportMessage(): PassportMessage? = this as? PassportMessage
@PreviewFeature @PreviewFeature
inline fun Message.requirePassportMessage(): PassportMessage = this as PassportMessage inline fun AccessibleMessage.requirePassportMessage(): PassportMessage = this as PassportMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenPrivateContentMessageImpl(block: (PrivateContentMessageImpl<MessageContent>) -> T) =
asPrivateContentMessageImpl()?.let(block) asPrivateContentMessageImpl()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPrivateContentMessageImpl(): PrivateContentMessageImpl<MessageContent>? = inline fun AccessibleMessage.asPrivateContentMessageImpl(): PrivateContentMessageImpl<MessageContent>? =
this as? PrivateContentMessageImpl<MessageContent> this as? PrivateContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requirePrivateContentMessageImpl(): PrivateContentMessageImpl<MessageContent> = inline fun AccessibleMessage.requirePrivateContentMessageImpl(): PrivateContentMessageImpl<MessageContent> =
this as PrivateContentMessageImpl<MessageContent> this as PrivateContentMessageImpl<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenChannelEventMessage(block: (ChannelEventMessage<ChannelEvent>) -> T) = inline fun <T> AccessibleMessage.whenChannelEventMessage(block: (ChannelEventMessage<ChannelEvent>) -> T) =
asChannelEventMessage()?.let(block) asChannelEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asChannelEventMessage(): ChannelEventMessage<ChannelEvent>? = inline fun AccessibleMessage.asChannelEventMessage(): ChannelEventMessage<ChannelEvent>? =
this as? ChannelEventMessage<ChannelEvent> this as? ChannelEventMessage<ChannelEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireChannelEventMessage(): ChannelEventMessage<ChannelEvent> = inline fun AccessibleMessage.requireChannelEventMessage(): ChannelEventMessage<ChannelEvent> =
this as ChannelEventMessage<ChannelEvent> this as ChannelEventMessage<ChannelEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenCommonGroupEventMessage(block: (CommonGroupEventMessage<GroupEvent>) -> T) = inline fun <T> AccessibleMessage.whenCommonGroupEventMessage(block: (CommonGroupEventMessage<GroupEvent>) -> T) =
asCommonGroupEventMessage()?.let(block) asCommonGroupEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asCommonGroupEventMessage(): CommonGroupEventMessage<GroupEvent>? = inline fun AccessibleMessage.asCommonGroupEventMessage(): CommonGroupEventMessage<GroupEvent>? =
this as? CommonGroupEventMessage<GroupEvent> this as? CommonGroupEventMessage<GroupEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireCommonGroupEventMessage(): CommonGroupEventMessage<GroupEvent> = inline fun AccessibleMessage.requireCommonGroupEventMessage(): CommonGroupEventMessage<GroupEvent> =
this as CommonGroupEventMessage<GroupEvent> this as CommonGroupEventMessage<GroupEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T) = inline fun <T> AccessibleMessage.whenCommonSupergroupEventMessage(block: (CommonSupergroupEventMessage<SupergroupEvent>) -> T) =
asCommonSupergroupEventMessage()?.let(block) asCommonSupergroupEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage<SupergroupEvent>? = inline fun AccessibleMessage.asCommonSupergroupEventMessage(): CommonSupergroupEventMessage<SupergroupEvent>? =
this as? CommonSupergroupEventMessage<SupergroupEvent> this as? CommonSupergroupEventMessage<SupergroupEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage<SupergroupEvent> = inline fun AccessibleMessage.requireCommonSupergroupEventMessage(): CommonSupergroupEventMessage<SupergroupEvent> =
this as CommonSupergroupEventMessage<SupergroupEvent> this as CommonSupergroupEventMessage<SupergroupEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenAnonymousGroupContentMessage(block: (AnonymousGroupContentMessage<MessageContent>) -> T) =
asAnonymousGroupContentMessage()?.let(block) asAnonymousGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asAnonymousGroupContentMessage(): AnonymousGroupContentMessage<MessageContent>? =
this as? AnonymousGroupContentMessage<MessageContent> this as? AnonymousGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireAnonymousGroupContentMessage(): AnonymousGroupContentMessage<MessageContent> =
this as AnonymousGroupContentMessage<MessageContent> this as AnonymousGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenChannelContentMessage(block: (ChannelContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenChannelContentMessage(block: (ChannelContentMessage<MessageContent>) -> T) =
asChannelContentMessage()?.let(block) asChannelContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asChannelContentMessage(): ChannelContentMessage<MessageContent>? = inline fun AccessibleMessage.asChannelContentMessage(): ChannelContentMessage<MessageContent>? =
this as? ChannelContentMessage<MessageContent> this as? ChannelContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireChannelContentMessage(): ChannelContentMessage<MessageContent> = inline fun AccessibleMessage.requireChannelContentMessage(): ChannelContentMessage<MessageContent> =
this as ChannelContentMessage<MessageContent> this as ChannelContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenConnectedFromChannelGroupContentMessage(block: (ConnectedFromChannelGroupContentMessage<MessageContent>) -> T) =
asConnectedFromChannelGroupContentMessage()?.let(block) asConnectedFromChannelGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage<MessageContent>? =
this as? ConnectedFromChannelGroupContentMessage<MessageContent> this as? ConnectedFromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireConnectedFromChannelGroupContentMessage(): ConnectedFromChannelGroupContentMessage<MessageContent> =
this as ConnectedFromChannelGroupContentMessage<MessageContent> this as ConnectedFromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenUnconnectedFromChannelGroupContentMessage(block: (UnconnectedFromChannelGroupContentMessage<MessageContent>) -> T) =
asUnconnectedFromChannelGroupContentMessage()?.let(block) asUnconnectedFromChannelGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage<MessageContent>? =
this as? UnconnectedFromChannelGroupContentMessage<MessageContent> this as? UnconnectedFromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireUnconnectedFromChannelGroupContentMessage(): UnconnectedFromChannelGroupContentMessage<MessageContent> =
this as UnconnectedFromChannelGroupContentMessage<MessageContent> this as UnconnectedFromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenChatEventMessage(block: (ChatEventMessage<ChatEvent>) -> T) = inline fun <T> AccessibleMessage.whenChatEventMessage(block: (ChatEventMessage<ChatEvent>) -> T) =
asChatEventMessage()?.let(block) asChatEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asChatEventMessage(): ChatEventMessage<ChatEvent>? = this as? ChatEventMessage<ChatEvent> inline fun AccessibleMessage.asChatEventMessage(): ChatEventMessage<ChatEvent>? = this as? ChatEventMessage<ChatEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireChatEventMessage(): ChatEventMessage<ChatEvent> = this as ChatEventMessage<ChatEvent> inline fun AccessibleMessage.requireChatEventMessage(): ChatEventMessage<ChatEvent> = this as ChatEventMessage<ChatEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenCommonGroupContentMessage(block: (CommonGroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenCommonGroupContentMessage(block: (CommonGroupContentMessage<MessageContent>) -> T) =
asCommonGroupContentMessage()?.let(block) asCommonGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asCommonGroupContentMessage(): CommonGroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asCommonGroupContentMessage(): CommonGroupContentMessage<MessageContent>? =
this as? CommonGroupContentMessage<MessageContent> this as? CommonGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireCommonGroupContentMessage(): CommonGroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireCommonGroupContentMessage(): CommonGroupContentMessage<MessageContent> =
this as CommonGroupContentMessage<MessageContent> this as CommonGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenCommonMessage(block: (CommonMessage<MessageContent>) -> T) = asCommonMessage()?.let(block) inline fun <T> AccessibleMessage.whenCommonMessage(block: (CommonMessage<MessageContent>) -> T) = asCommonMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asCommonMessage(): CommonMessage<MessageContent>? = this as? CommonMessage<MessageContent> inline fun AccessibleMessage.asCommonMessage(): CommonMessage<MessageContent>? = this as? CommonMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireCommonMessage(): CommonMessage<MessageContent> = this as CommonMessage<MessageContent> inline fun AccessibleMessage.requireCommonMessage(): CommonMessage<MessageContent> = this as CommonMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenContentMessage(block: (ContentMessage<MessageContent>) -> T) = asContentMessage()?.let(block) inline fun <T> AccessibleMessage.whenContentMessage(block: (ContentMessage<MessageContent>) -> T) = asContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asContentMessage(): ContentMessage<MessageContent>? = this as? ContentMessage<MessageContent> inline fun AccessibleMessage.asContentMessage(): ContentMessage<MessageContent>? = this as? ContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireContentMessage(): ContentMessage<MessageContent> = this as ContentMessage<MessageContent> inline fun AccessibleMessage.requireContentMessage(): ContentMessage<MessageContent> = this as ContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenFromChannelGroupContentMessage(block: (FromChannelGroupContentMessage<MessageContent>) -> T) =
asFromChannelGroupContentMessage()?.let(block) asFromChannelGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asFromChannelGroupContentMessage(): FromChannelGroupContentMessage<MessageContent>? =
this as? FromChannelGroupContentMessage<MessageContent> this as? FromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireFromChannelGroupContentMessage(): FromChannelGroupContentMessage<MessageContent> =
this as FromChannelGroupContentMessage<MessageContent> this as FromChannelGroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenGroupEventMessage(block: (GroupEventMessage<GroupEvent>) -> T) = inline fun <T> AccessibleMessage.whenGroupEventMessage(block: (GroupEventMessage<GroupEvent>) -> T) =
asGroupEventMessage()?.let(block) asGroupEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asGroupEventMessage(): GroupEventMessage<GroupEvent>? = this as? GroupEventMessage<GroupEvent> inline fun AccessibleMessage.asGroupEventMessage(): GroupEventMessage<GroupEvent>? = this as? GroupEventMessage<GroupEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireGroupEventMessage(): GroupEventMessage<GroupEvent> = this as GroupEventMessage<GroupEvent> inline fun AccessibleMessage.requireGroupEventMessage(): GroupEventMessage<GroupEvent> = this as GroupEventMessage<GroupEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPrivateEventMessage(block: (PrivateEventMessage<PrivateEvent>) -> T) = inline fun <T> AccessibleMessage.whenPrivateEventMessage(block: (PrivateEventMessage<PrivateEvent>) -> T) =
asPrivateEventMessage()?.let(block) asPrivateEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPrivateEventMessage(): PrivateEventMessage<PrivateEvent>? = inline fun AccessibleMessage.asPrivateEventMessage(): PrivateEventMessage<PrivateEvent>? =
this as? PrivateEventMessage<PrivateEvent> this as? PrivateEventMessage<PrivateEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requirePrivateEventMessage(): PrivateEventMessage<PrivateEvent> = inline fun AccessibleMessage.requirePrivateEventMessage(): PrivateEventMessage<PrivateEvent> =
this as PrivateEventMessage<PrivateEvent> this as PrivateEventMessage<PrivateEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenGroupContentMessage(block: (GroupContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenGroupContentMessage(block: (GroupContentMessage<MessageContent>) -> T) =
asGroupContentMessage()?.let(block) asGroupContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asGroupContentMessage(): GroupContentMessage<MessageContent>? = inline fun AccessibleMessage.asGroupContentMessage(): GroupContentMessage<MessageContent>? =
this as? GroupContentMessage<MessageContent> this as? GroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireGroupContentMessage(): GroupContentMessage<MessageContent> = inline fun AccessibleMessage.requireGroupContentMessage(): GroupContentMessage<MessageContent> =
this as GroupContentMessage<MessageContent> this as GroupContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenMediaGroupMessage(block: (MediaGroupMessage<MediaGroupPartContent>) -> T) = inline fun <T> AccessibleMessage.whenMediaGroupMessage(block: (MediaGroupMessage<MediaGroupPartContent>) -> T) =
asMediaGroupMessage()?.let(block) asMediaGroupMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asMediaGroupMessage(): MediaGroupMessage<MediaGroupPartContent>? = inline fun AccessibleMessage.asMediaGroupMessage(): MediaGroupMessage<MediaGroupPartContent>? =
this as? MediaGroupMessage<MediaGroupPartContent> this as? MediaGroupMessage<MediaGroupPartContent>
@PreviewFeature @PreviewFeature
inline fun Message.requireMediaGroupMessage(): MediaGroupMessage<MediaGroupPartContent> = inline fun AccessibleMessage.requireMediaGroupMessage(): MediaGroupMessage<MediaGroupPartContent> =
this as MediaGroupMessage<MediaGroupPartContent> this as MediaGroupMessage<MediaGroupPartContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) = inline fun <T> AccessibleMessage.whenPossiblyEditedMessage(block: (PossiblyEditedMessage) -> T) =
asPossiblyEditedMessage()?.let(block) asPossiblyEditedMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage inline fun AccessibleMessage.asPossiblyEditedMessage(): PossiblyEditedMessage? = this as? PossiblyEditedMessage
@PreviewFeature @PreviewFeature
inline fun Message.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage inline fun AccessibleMessage.requirePossiblyEditedMessage(): PossiblyEditedMessage = this as PossiblyEditedMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) = inline fun <T> AccessibleMessage.whenPossiblyReplyMessage(block: (PossiblyReplyMessage) -> T) =
asPossiblyReplyMessage()?.let(block) asPossiblyReplyMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage inline fun AccessibleMessage.asPossiblyReplyMessage(): PossiblyReplyMessage? = this as? PossiblyReplyMessage
@PreviewFeature @PreviewFeature
inline fun Message.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage inline fun AccessibleMessage.requirePossiblyReplyMessage(): PossiblyReplyMessage = this as PossiblyReplyMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) = inline fun <T> AccessibleMessage.whenPossiblyForwardedMessage(block: (PossiblyForwardedMessage) -> T) =
asPossiblyForwardedMessage()?.let(block) asPossiblyForwardedMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage inline fun AccessibleMessage.asPossiblyForwardedMessage(): PossiblyForwardedMessage? = this as? PossiblyForwardedMessage
@PreviewFeature @PreviewFeature
inline fun Message.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage inline fun AccessibleMessage.requirePossiblyForwardedMessage(): PossiblyForwardedMessage = this as PossiblyForwardedMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) = inline fun <T> AccessibleMessage.whenPossiblyPaymentMessage(block: (PossiblyPaymentMessage) -> T) =
asPossiblyPaymentMessage()?.let(block) asPossiblyPaymentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage inline fun AccessibleMessage.asPossiblyPaymentMessage(): PossiblyPaymentMessage? = this as? PossiblyPaymentMessage
@PreviewFeature @PreviewFeature
inline fun Message.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage inline fun AccessibleMessage.requirePossiblyPaymentMessage(): PossiblyPaymentMessage = this as PossiblyPaymentMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPrivateContentMessage(block: (PrivateContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenPrivateContentMessage(block: (PrivateContentMessage<MessageContent>) -> T) =
asPrivateContentMessage()?.let(block) asPrivateContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPrivateContentMessage(): PrivateContentMessage<MessageContent>? = inline fun AccessibleMessage.asPrivateContentMessage(): PrivateContentMessage<MessageContent>? =
this as? PrivateContentMessage<MessageContent> this as? PrivateContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requirePrivateContentMessage(): PrivateContentMessage<MessageContent> = inline fun AccessibleMessage.requirePrivateContentMessage(): PrivateContentMessage<MessageContent> =
this as PrivateContentMessage<MessageContent> this as PrivateContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPublicContentMessage(block: (PublicContentMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenPublicContentMessage(block: (PublicContentMessage<MessageContent>) -> T) =
asPublicContentMessage()?.let(block) asPublicContentMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPublicContentMessage(): PublicContentMessage<MessageContent>? = inline fun AccessibleMessage.asPublicContentMessage(): PublicContentMessage<MessageContent>? =
this as? PublicContentMessage<MessageContent> this as? PublicContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requirePublicContentMessage(): PublicContentMessage<MessageContent> = inline fun AccessibleMessage.requirePublicContentMessage(): PublicContentMessage<MessageContent> =
this as PublicContentMessage<MessageContent> this as PublicContentMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block) inline fun <T> AccessibleMessage.whenSignedMessage(block: (SignedMessage) -> T) = asSignedMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asSignedMessage(): SignedMessage? = this as? SignedMessage inline fun AccessibleMessage.asSignedMessage(): SignedMessage? = this as? SignedMessage
@PreviewFeature @PreviewFeature
inline fun Message.requireSignedMessage(): SignedMessage = this as SignedMessage inline fun AccessibleMessage.requireSignedMessage(): SignedMessage = this as SignedMessage
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenSupergroupEventMessage(block: (SupergroupEventMessage<SupergroupEvent>) -> T) = inline fun <T> AccessibleMessage.whenSupergroupEventMessage(block: (SupergroupEventMessage<SupergroupEvent>) -> T) =
asSupergroupEventMessage()?.let(block) asSupergroupEventMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asSupergroupEventMessage(): SupergroupEventMessage<SupergroupEvent>? = inline fun AccessibleMessage.asSupergroupEventMessage(): SupergroupEventMessage<SupergroupEvent>? =
this as? SupergroupEventMessage<SupergroupEvent> this as? SupergroupEventMessage<SupergroupEvent>
@PreviewFeature @PreviewFeature
inline fun Message.requireSupergroupEventMessage(): SupergroupEventMessage<SupergroupEvent> = inline fun AccessibleMessage.requireSupergroupEventMessage(): SupergroupEventMessage<SupergroupEvent> =
this as SupergroupEventMessage<SupergroupEvent> this as SupergroupEventMessage<SupergroupEvent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block) inline fun <T> AccessibleMessage.whenUnknownMessageType(block: (UnknownMessageType) -> T) = asUnknownMessageType()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType inline fun AccessibleMessage.asUnknownMessageType(): UnknownMessageType? = this as? UnknownMessageType
@PreviewFeature @PreviewFeature
inline fun Message.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType inline fun AccessibleMessage.requireUnknownMessageType(): UnknownMessageType = this as UnknownMessageType
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage<MessageContent>) -> T) = inline fun <T> AccessibleMessage.whenPossiblySentViaBotCommonMessage(block: (PossiblySentViaBotCommonMessage<MessageContent>) -> T) =
asPossiblySentViaBotCommonMessage()?.let(block) asPossiblySentViaBotCommonMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage<MessageContent>? = inline fun AccessibleMessage.asPossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage<MessageContent>? =
this as? PossiblySentViaBotCommonMessage<MessageContent> this as? PossiblySentViaBotCommonMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun Message.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage<MessageContent> = inline fun AccessibleMessage.requirePossiblySentViaBotCommonMessage(): PossiblySentViaBotCommonMessage<MessageContent> =
this as PossiblySentViaBotCommonMessage<MessageContent> this as PossiblySentViaBotCommonMessage<MessageContent>
@PreviewFeature @PreviewFeature
inline fun <T> Message.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block) inline fun <T> AccessibleMessage.whenFromUserMessage(block: (FromUserMessage) -> T) = asFromUserMessage()?.let(block)
@PreviewFeature @PreviewFeature
inline fun Message.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage inline fun AccessibleMessage.asFromUserMessage(): FromUserMessage? = this as? FromUserMessage
@PreviewFeature @PreviewFeature
inline fun Message.requireFromUserMessage(): FromUserMessage = this as FromUserMessage inline fun AccessibleMessage.requireFromUserMessage(): FromUserMessage = this as FromUserMessage
@PreviewFeature @PreviewFeature
inline fun <T> BotAction.whenFindLocationAction(block: (FindLocationAction) -> T) = asFindLocationAction()?.let(block) inline fun <T> BotAction.whenFindLocationAction(block: (FindLocationAction) -> T) = asFindLocationAction()?.let(block)

View File

@ -260,6 +260,7 @@ import dev.inmo.tgbotapi.types.message.CommonSupergroupEventMessage
import dev.inmo.tgbotapi.types.message.ForwardInfo import dev.inmo.tgbotapi.types.message.ForwardInfo
import dev.inmo.tgbotapi.types.message.PassportMessage import dev.inmo.tgbotapi.types.message.PassportMessage
import dev.inmo.tgbotapi.types.message.PrivateEventMessage import dev.inmo.tgbotapi.types.message.PrivateEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousForumContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.AnonymousGroupContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ChannelContentMessage
@ -275,6 +276,7 @@ import dev.inmo.tgbotapi.types.message.abstracts.FromChannelGroupContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage import dev.inmo.tgbotapi.types.message.abstracts.FromUserMessage
import dev.inmo.tgbotapi.types.message.abstracts.GroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.GroupContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage import dev.inmo.tgbotapi.types.message.abstracts.GroupEventMessage
import dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyEditedMessage
import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage import dev.inmo.tgbotapi.types.message.abstracts.PossiblyForwardedMessage
@ -414,9 +416,13 @@ import dev.inmo.tgbotapi.types.polls.QuizPoll
import dev.inmo.tgbotapi.types.polls.RegularPoll import dev.inmo.tgbotapi.types.polls.RegularPoll
import dev.inmo.tgbotapi.types.polls.ScheduledCloseInfo import dev.inmo.tgbotapi.types.polls.ScheduledCloseInfo
import dev.inmo.tgbotapi.types.polls.UnknownPollType import dev.inmo.tgbotapi.types.polls.UnknownPollType
import dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery import dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.GameShortNameCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdDataCallbackQuery
import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery import dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdGameShortNameCallbackQuery
@ -841,6 +847,16 @@ public inline fun WithUser.pollAnswerOrThrow(): PollAnswer = this as
public inline fun <T> WithUser.ifPollAnswer(block: (PollAnswer) -> T): T? = pollAnswerOrNull() public inline fun <T> WithUser.ifPollAnswer(block: (PollAnswer) -> T): T? = pollAnswerOrNull()
?.let(block) ?.let(block)
public inline fun WithUser.abstractMessageCallbackQueryOrNull(): AbstractMessageCallbackQuery? =
this as? dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery
public inline fun WithUser.abstractMessageCallbackQueryOrThrow(): AbstractMessageCallbackQuery =
this as dev.inmo.tgbotapi.types.queries.callback.AbstractMessageCallbackQuery
public inline fun <T>
WithUser.ifAbstractMessageCallbackQuery(block: (AbstractMessageCallbackQuery) -> T): T? =
abstractMessageCallbackQueryOrNull() ?.let(block)
public inline fun WithUser.callbackQueryOrNull(): CallbackQuery? = this as? public inline fun WithUser.callbackQueryOrNull(): CallbackQuery? = this as?
dev.inmo.tgbotapi.types.queries.callback.CallbackQuery dev.inmo.tgbotapi.types.queries.callback.CallbackQuery
@ -878,6 +894,42 @@ public inline fun <T>
WithUser.ifGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T): T? = WithUser.ifGameShortNameCallbackQuery(block: (GameShortNameCallbackQuery) -> T): T? =
gameShortNameCallbackQueryOrNull() ?.let(block) gameShortNameCallbackQueryOrNull() ?.let(block)
public inline fun WithUser.inaccessibleMessageCallbackQueryOrNull():
InaccessibleMessageCallbackQuery? = this as?
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery
public inline fun WithUser.inaccessibleMessageCallbackQueryOrThrow():
InaccessibleMessageCallbackQuery = this as
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageCallbackQuery
public inline fun <T>
WithUser.ifInaccessibleMessageCallbackQuery(block: (InaccessibleMessageCallbackQuery) -> T): T?
= inaccessibleMessageCallbackQueryOrNull() ?.let(block)
public inline fun WithUser.inaccessibleMessageDataCallbackQueryOrNull():
InaccessibleMessageDataCallbackQuery? = this as?
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery
public inline fun WithUser.inaccessibleMessageDataCallbackQueryOrThrow():
InaccessibleMessageDataCallbackQuery = this as
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageDataCallbackQuery
public inline fun <T>
WithUser.ifInaccessibleMessageDataCallbackQuery(block: (InaccessibleMessageDataCallbackQuery) -> T):
T? = inaccessibleMessageDataCallbackQueryOrNull() ?.let(block)
public inline fun WithUser.inaccessibleMessageGameShortNameCallbackQueryOrNull():
InaccessibleMessageGameShortNameCallbackQuery? = this as?
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery
public inline fun WithUser.inaccessibleMessageGameShortNameCallbackQueryOrThrow():
InaccessibleMessageGameShortNameCallbackQuery = this as
dev.inmo.tgbotapi.types.queries.callback.InaccessibleMessageGameShortNameCallbackQuery
public inline fun <T>
WithUser.ifInaccessibleMessageGameShortNameCallbackQuery(block: (InaccessibleMessageGameShortNameCallbackQuery) -> T):
T? = inaccessibleMessageGameShortNameCallbackQueryOrNull() ?.let(block)
public inline fun WithUser.inlineMessageIdCallbackQueryOrNull(): InlineMessageIdCallbackQuery? = public inline fun WithUser.inlineMessageIdCallbackQueryOrNull(): InlineMessageIdCallbackQuery? =
this as? dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery this as? dev.inmo.tgbotapi.types.queries.callback.InlineMessageIdCallbackQuery
@ -3396,6 +3448,24 @@ public inline fun <T>
Message.ifCommonForumContentMessage(block: (CommonForumContentMessage<MessageContent>) -> T): T? Message.ifCommonForumContentMessage(block: (CommonForumContentMessage<MessageContent>) -> T): T?
= commonForumContentMessageOrNull() ?.let(block) = commonForumContentMessageOrNull() ?.let(block)
public inline fun Message.accessibleMessageOrNull(): AccessibleMessage? = this as?
dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
public inline fun Message.accessibleMessageOrThrow(): AccessibleMessage = this as
dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
public inline fun <T> Message.ifAccessibleMessage(block: (AccessibleMessage) -> T): T? =
accessibleMessageOrNull() ?.let(block)
public inline fun Message.inaccessibleMessageOrNull(): InaccessibleMessage? = this as?
dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
public inline fun Message.inaccessibleMessageOrThrow(): InaccessibleMessage = this as
dev.inmo.tgbotapi.types.message.abstracts.InaccessibleMessage
public inline fun <T> Message.ifInaccessibleMessage(block: (InaccessibleMessage) -> T): T? =
inaccessibleMessageOrNull() ?.let(block)
public inline fun Message.unknownMessageTypeOrNull(): UnknownMessageType? = this as? public inline fun Message.unknownMessageTypeOrNull(): UnknownMessageType? = this as?
dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType dev.inmo.tgbotapi.types.message.abstracts.UnknownMessageType

View File

@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.MessageId
import dev.inmo.tgbotapi.types.MessageThreadId import dev.inmo.tgbotapi.types.MessageThreadId
import dev.inmo.tgbotapi.types.Username import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.types.chat.Chat import dev.inmo.tgbotapi.types.chat.Chat
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.threadId import dev.inmo.tgbotapi.types.threadId
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
@ -32,43 +32,43 @@ inline fun WithPreviewChat.sameChat(chat: Chat) =
* @return true in case if [this] message is placed in the same chat that [other] * @return true in case if [this] message is placed in the same chat that [other]
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun WithPreviewChat.sameChat(other: Message) = sameChat(other.chat) inline fun WithPreviewChat.sameChat(other: AccessibleMessage) = sameChat(other.chat)
/** /**
* @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [Message.messageId] * @return true in case if [this] message is from the same chat (with id == [chatId]) and [this] [AccessibleMessage.messageId]
* equal [messageId] identifier * equal [messageId] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameMessage( inline fun AccessibleMessage.sameMessage(
chatId: ChatIdentifier, chatId: ChatIdentifier,
messageId: MessageId messageId: MessageId
) = sameChat(chatId) && this.messageId == messageId ) = sameChat(chatId) && this.messageId == messageId
/** /**
* @return true in case if [this] message is from the same [chat] and [this] [Message.messageId] equal [messageId] * @return true in case if [this] message is from the same [chat] and [this] [AccessibleMessage.messageId] equal [messageId]
* identifier * identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameMessage( inline fun AccessibleMessage.sameMessage(
chat: Chat, chat: Chat,
messageId: MessageId messageId: MessageId
) = sameChat(chat) && this.messageId == messageId ) = sameChat(chat) && this.messageId == messageId
/** /**
* @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat * @return true in case if [this] message is the same as [other]. The same here means that these messages from one chat
* and have equal [Message.messageId] identifier * and have equal [AccessibleMessage.messageId] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameMessage(other: Message) = sameMessage(other.chat, other.messageId) inline fun AccessibleMessage.sameMessage(other: AccessibleMessage) = sameMessage(other.chat, other.messageId)
/** /**
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these
* messages from one chat and have equal [Message.threadIdOrNull] identifier * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameTopic( inline fun AccessibleMessage.sameTopic(
chatId: ChatIdentifier, chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId threadId: MessageThreadId? = chatId.threadId
) = sameChat(chatId) && threadIdOrNull == threadId ) = sameChat(chatId) && threadIdOrNull == threadId
@ -77,10 +77,10 @@ inline fun Message.sameTopic(
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these * @return true in case if [this] message is in the chat [chatId] and topic [threadId]. The same here means that these
* messages from one chat and have equal [Message.threadIdOrNull] identifier * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameThread( inline fun AccessibleMessage.sameThread(
chatId: ChatIdentifier, chatId: ChatIdentifier,
threadId: MessageThreadId? = chatId.threadId threadId: MessageThreadId? = chatId.threadId
) = sameTopic(chatId, threadId) ) = sameTopic(chatId, threadId)
@ -89,10 +89,10 @@ inline fun Message.sameThread(
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these
* messages from one chat and have equal [Message.threadIdOrNull] identifier * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameTopic( inline fun AccessibleMessage.sameTopic(
chat: Chat, chat: Chat,
threadId: MessageThreadId? = chat.id.threadId threadId: MessageThreadId? = chat.id.threadId
) = sameTopic(chat.id, threadId) ) = sameTopic(chat.id, threadId)
@ -101,10 +101,10 @@ inline fun Message.sameTopic(
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these * @return true in case if [this] message is from the [chat] and topic [threadId]. The same here means that these
* messages from one chat and have equal [Message.threadIdOrNull] identifier * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameThread( inline fun AccessibleMessage.sameThread(
chat: Chat, chat: Chat,
threadId: MessageThreadId? = chat.id.threadId threadId: MessageThreadId? = chat.id.threadId
) = sameThread(chat.id, threadId) ) = sameThread(chat.id, threadId)
@ -113,16 +113,16 @@ inline fun Message.sameThread(
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is from the same chat and topic as [other]. The same here means that these * @return true in case if [this] message is from the same chat and topic as [other]. The same here means that these
* messages from one chat and have equal [Message.threadIdOrNull] identifier * messages from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameTopic(other: Message) = sameTopic(other.chat, other.threadIdOrNull) inline fun AccessibleMessage.sameTopic(other: AccessibleMessage) = sameTopic(other.chat, other.threadIdOrNull)
/** /**
* Thread is the same thing that topic * Thread is the same thing that topic
* *
* @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages * @return true in case if [this] message is in the same topic as the [other]. The same here means that these messages
* from one chat and have equal [Message.threadIdOrNull] identifier * from one chat and have equal [AccessibleMessage.threadIdOrNull] identifier
*/ */
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun Message.sameThread(other: Message) = sameTopic(other) inline fun AccessibleMessage.sameThread(other: AccessibleMessage) = sameTopic(other)

View File

@ -18,9 +18,8 @@ import dev.inmo.tgbotapi.utils.PreviewFeature
fun CallbackQuery.sourceChat() = when (this) { fun CallbackQuery.sourceChat() = when (this) {
is InlineMessageIdDataCallbackQuery -> null is InlineMessageIdDataCallbackQuery -> null
is MessageDataCallbackQuery -> message.chat is AbstractMessageCallbackQuery -> message.chat
is InlineMessageIdGameShortNameCallbackQuery -> null is InlineMessageIdGameShortNameCallbackQuery -> null
is MessageGameShortNameCallbackQuery -> message.chat
is UnknownCallbackQueryType -> null is UnknownCallbackQueryType -> null
} }

View File

@ -11,6 +11,7 @@ import dev.inmo.tgbotapi.types.location.Location
import dev.inmo.tgbotapi.types.message.ChatEvents.* import dev.inmo.tgbotapi.types.message.ChatEvents.*
import dev.inmo.tgbotapi.types.message.ChatEvents.voice.* import dev.inmo.tgbotapi.types.message.ChatEvents.voice.*
import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage import dev.inmo.tgbotapi.types.message.abstracts.ConnectedFromChannelGroupContentMessage
import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
@ -22,58 +23,58 @@ import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.from: User? inline val AccessibleMessage.from: User?
get() = asFromUser() ?.from get() = asFromUser() ?.from
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.sender_chat: PublicChat? inline val AccessibleMessage.sender_chat: PublicChat?
get() = asFromChannelGroupContentMessage() ?.senderChat get() = asFromChannelGroupContentMessage() ?.senderChat
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_from: User? inline val AccessibleMessage.forward_from: User?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asUserForwardInfo() ?.from
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_from_chat: Chat? inline val AccessibleMessage.forward_from_chat: Chat?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asForwardFromPublicChatInfo() ?.chat
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_from_message_id: MessageId? inline val AccessibleMessage.forward_from_message_id: MessageId?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.messageId
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_signature: ForwardSignature? inline val AccessibleMessage.forward_signature: ForwardSignature?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature get() = asPossiblyForwardedMessage() ?.forwardInfo ?.fromChannelOrNull() ?.signature
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_sender_name: ForwardSenderName? inline val AccessibleMessage.forward_sender_name: ForwardSenderName?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName get() = asPossiblyForwardedMessage() ?.forwardInfo ?.asAnonymousForwardInfo() ?.senderName
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.forward_date: TelegramDate? inline val AccessibleMessage.forward_date: TelegramDate?
get() = asPossiblyForwardedMessage() ?.forwardInfo ?.dateOfOriginal get() = asPossiblyForwardedMessage() ?.forwardInfo ?.dateOfOriginal
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.is_automatic_forward: Boolean? inline val AccessibleMessage.is_automatic_forward: Boolean?
get() = this is ConnectedFromChannelGroupContentMessage<*> get() = this is ConnectedFromChannelGroupContentMessage<*>
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.reply_to_message: Message? inline val AccessibleMessage.reply_to_message: AccessibleMessage?
get() = asPossiblyReplyMessage() ?.replyTo get() = asPossiblyReplyMessage() ?.replyTo
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.via_bot: CommonBot? inline val AccessibleMessage.via_bot: CommonBot?
get() = asPossiblySentViaBotCommonMessage() ?.senderBot get() = asPossiblySentViaBotCommonMessage() ?.senderBot
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.edit_date: TelegramDate? inline val AccessibleMessage.edit_date: TelegramDate?
get() = asPossiblyEditedMessage() ?.editDate ?.toTelegramDate() get() = asPossiblyEditedMessage() ?.editDate ?.toTelegramDate()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.has_protected_content: Boolean? inline val AccessibleMessage.has_protected_content: Boolean?
get() = asContentMessage() ?.hasProtectedContent get() = asContentMessage() ?.hasProtectedContent
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.media_group_id: MediaGroupIdentifier? inline val AccessibleMessage.media_group_id: MediaGroupIdentifier?
get() = asMediaGroupMessage() ?.mediaGroupId get() = asMediaGroupMessage() ?.mediaGroupId
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.author_signature: AuthorSignature? inline val AccessibleMessage.author_signature: AuthorSignature?
get() = asSignedMessage() ?.authorSignature get() = asSignedMessage() ?.authorSignature
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.text: String? inline val AccessibleMessage.text: String?
get() = asContentMessage() ?.content ?.asTextContent() ?.text get() = asContentMessage() ?.content ?.asTextContent() ?.text
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.entities: TextSourcesList? inline val AccessibleMessage.entities: TextSourcesList?
get() = asContentMessage() ?.content ?.asTextContent() ?.textSources get() = asContentMessage() ?.content ?.asTextContent() ?.textSources
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.caption: String? inline val AccessibleMessage.caption: String?
get() = whenContentMessage { get() = whenContentMessage {
if (it.content !is TextContent) { if (it.content !is TextContent) {
it.content.asTextedInput() ?.text it.content.asTextedInput() ?.text
@ -82,7 +83,7 @@ inline val Message.caption: String?
} }
} }
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.caption_entities: TextSourcesList? inline val AccessibleMessage.caption_entities: TextSourcesList?
get() = whenContentMessage { get() = whenContentMessage {
if (it.content !is TextContent) { if (it.content !is TextContent) {
it.content.asTextedInput() ?.textSources it.content.asTextedInput() ?.textSources
@ -91,117 +92,117 @@ inline val Message.caption_entities: TextSourcesList?
} }
} }
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.audio: AudioFile? inline val AccessibleMessage.audio: AudioFile?
get() = asContentMessage() ?.content ?.asAudioContent() ?.media get() = asContentMessage() ?.content ?.asAudioContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.document: DocumentFile? inline val AccessibleMessage.document: DocumentFile?
get() = asContentMessage() ?.content ?.asDocumentContent() ?.media get() = asContentMessage() ?.content ?.asDocumentContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.animation: AnimationFile? inline val AccessibleMessage.animation: AnimationFile?
get() = asContentMessage() ?.content ?.asAnimationContent() ?.media get() = asContentMessage() ?.content ?.asAnimationContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.game: Game? inline val AccessibleMessage.game: Game?
get() = asContentMessage() ?.content ?.asGameContent() ?.game get() = asContentMessage() ?.content ?.asGameContent() ?.game
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.photo: Photo? inline val AccessibleMessage.photo: Photo?
get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection get() = asContentMessage() ?.content ?.asPhotoContent() ?.mediaCollection
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.sticker: Sticker? inline val AccessibleMessage.sticker: Sticker?
get() = asContentMessage() ?.content ?.asStickerContent() ?.media get() = asContentMessage() ?.content ?.asStickerContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video: VideoFile? inline val AccessibleMessage.video: VideoFile?
get() = asContentMessage() ?.content ?.asVideoContent() ?.media get() = asContentMessage() ?.content ?.asVideoContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.voice: VoiceFile? inline val AccessibleMessage.voice: VoiceFile?
get() = asContentMessage() ?.content ?.asVoiceContent() ?.media get() = asContentMessage() ?.content ?.asVoiceContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video_note: VideoNoteFile? inline val AccessibleMessage.video_note: VideoNoteFile?
get() = asContentMessage() ?.content ?.asVideoNoteContent() ?.media get() = asContentMessage() ?.content ?.asVideoNoteContent() ?.media
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.contact: Contact? inline val AccessibleMessage.contact: Contact?
get() = asContentMessage() ?.content ?.asContactContent() ?.contact get() = asContentMessage() ?.content ?.asContactContent() ?.contact
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.location: Location? inline val AccessibleMessage.location: Location?
get() = asContentMessage() ?.content ?.asLocationContent() ?.location get() = asContentMessage() ?.content ?.asLocationContent() ?.location
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.venue: Venue? inline val AccessibleMessage.venue: Venue?
get() = asContentMessage() ?.content ?.asVenueContent() ?.venue get() = asContentMessage() ?.content ?.asVenueContent() ?.venue
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.poll: Poll? inline val AccessibleMessage.poll: Poll?
get() = asContentMessage() ?.content ?.asPollContent() ?.poll get() = asContentMessage() ?.content ?.asPollContent() ?.poll
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.invoice: Invoice? inline val AccessibleMessage.invoice: Invoice?
get() = asContentMessage() ?.content ?.asInvoiceContent() ?.invoice get() = asContentMessage() ?.content ?.asInvoiceContent() ?.invoice
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.dice: Dice? inline val AccessibleMessage.dice: Dice?
get() = asContentMessage() ?.content ?.asDiceContent() ?.dice get() = asContentMessage() ?.content ?.asDiceContent() ?.dice
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.new_chat_members: List<User>? inline val AccessibleMessage.new_chat_members: List<User>?
get() = asChatEventMessage() ?.chatEvent ?.asNewChatMembers() ?.members get() = asChatEventMessage() ?.chatEvent ?.asNewChatMembers() ?.members
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.left_chat_member: User? inline val AccessibleMessage.left_chat_member: User?
get() = asChatEventMessage() ?.chatEvent ?.asLeftChatMember() ?.user get() = asChatEventMessage() ?.chatEvent ?.asLeftChatMember() ?.user
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.new_chat_title: String? inline val AccessibleMessage.new_chat_title: String?
get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title get() = asChatEventMessage() ?.chatEvent ?.asNewChatTitle() ?.title
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.new_chat_photo: Photo? inline val AccessibleMessage.new_chat_photo: Photo?
get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo get() = asChatEventMessage() ?.chatEvent ?.asNewChatPhoto() ?.photo
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.delete_chat_photo: Boolean inline val AccessibleMessage.delete_chat_photo: Boolean
get() = asChatEventMessage() ?.chatEvent is DeleteChatPhoto get() = asChatEventMessage() ?.chatEvent is DeleteChatPhoto
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.group_chat_created: Boolean inline val AccessibleMessage.group_chat_created: Boolean
get() = asChatEventMessage() ?.chatEvent is GroupChatCreated get() = asChatEventMessage() ?.chatEvent is GroupChatCreated
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.supergroup_chat_created: Boolean inline val AccessibleMessage.supergroup_chat_created: Boolean
get() = asChatEventMessage() ?.chatEvent is SupergroupChatCreated get() = asChatEventMessage() ?.chatEvent is SupergroupChatCreated
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.channel_chat_created: Boolean inline val AccessibleMessage.channel_chat_created: Boolean
get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated get() = asChatEventMessage() ?.chatEvent is ChannelChatCreated
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.migrate_to_chat_id: IdChatIdentifier? inline val AccessibleMessage.migrate_to_chat_id: IdChatIdentifier?
get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo get() = asChatEventMessage() ?.chatEvent ?.asGroupChatCreated() ?.migratedTo
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.migrate_from_chat_id: IdChatIdentifier? inline val AccessibleMessage.migrate_from_chat_id: IdChatIdentifier?
get() = asChatEventMessage() ?.chatEvent ?.let { get() = asChatEventMessage() ?.chatEvent ?.let {
it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom it ?.asSupergroupChatCreated() ?.migratedFrom ?: it ?.asMigratedToSupergroup() ?.migratedFrom
} }
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.pinned_message: Message? inline val AccessibleMessage.pinned_message: Message?
get() = asChatEventMessage() ?.chatEvent ?.asPinnedMessage() ?.message get() = asChatEventMessage() ?.chatEvent ?.asPinnedMessage() ?.message
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.successful_payment: SuccessfulPayment? inline val AccessibleMessage.successful_payment: SuccessfulPayment?
get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment get() = asChatEventMessage() ?.chatEvent ?.asSuccessfulPaymentEvent() ?.payment
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video_chat_scheduled: VideoChatScheduled? inline val AccessibleMessage.video_chat_scheduled: VideoChatScheduled?
get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled() get() = asChatEventMessage() ?.chatEvent ?.asVideoChatScheduled()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video_chat_started: VideoChatStarted? inline val AccessibleMessage.video_chat_started: VideoChatStarted?
get() = asChatEventMessage() ?.chatEvent ?.asVideoChatStarted() get() = asChatEventMessage() ?.chatEvent ?.asVideoChatStarted()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video_chat_ended: VideoChatEnded? inline val AccessibleMessage.video_chat_ended: VideoChatEnded?
get() = asChatEventMessage() ?.chatEvent ?.asVideoChatEnded() get() = asChatEventMessage() ?.chatEvent ?.asVideoChatEnded()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.video_chat_participants_invited: VideoChatParticipantsInvited? inline val AccessibleMessage.video_chat_participants_invited: VideoChatParticipantsInvited?
get() = asChatEventMessage() ?.chatEvent ?.asVideoChatParticipantsInvited() get() = asChatEventMessage() ?.chatEvent ?.asVideoChatParticipantsInvited()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged? inline val AccessibleMessage.message_auto_delete_timer_changed: MessageAutoDeleteTimerChanged?
get() = asChatEventMessage() ?.chatEvent ?.asMessageAutoDeleteTimerChanged() get() = asChatEventMessage() ?.chatEvent ?.asMessageAutoDeleteTimerChanged()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.connected_website: String? inline val AccessibleMessage.connected_website: String?
get() = asChatEventMessage() ?.chatEvent ?.asUserLoggedIn() ?.domain get() = asChatEventMessage() ?.chatEvent ?.asUserLoggedIn() ?.domain
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.proximity_alert_triggered: ProximityAlertTriggered? inline val AccessibleMessage.proximity_alert_triggered: ProximityAlertTriggered?
get() = asChatEventMessage() ?.chatEvent ?.asProximityAlertTriggered() get() = asChatEventMessage() ?.chatEvent ?.asProximityAlertTriggered()
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.passport_data: PassportData? inline val AccessibleMessage.passport_data: PassportData?
get() = asPassportMessage() ?.passportData get() = asPassportMessage() ?.passportData
@RiskFeature(RawFieldsUsageWarning) @RiskFeature(RawFieldsUsageWarning)
inline val Message.reply_markup: InlineKeyboardMarkup? inline val AccessibleMessage.reply_markup: InlineKeyboardMarkup?
get() = asCommonMessage() ?.replyMarkup get() = asCommonMessage() ?.replyMarkup

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.formatting
import dev.inmo.tgbotapi.types.* import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.chat.* import dev.inmo.tgbotapi.types.chat.*
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.textsources.link import dev.inmo.tgbotapi.types.message.textsources.link
import io.ktor.http.encodeURLQueryComponent import io.ktor.http.encodeURLQueryComponent
@ -69,7 +69,7 @@ fun makeLinkToMessage(
): String = makeLinkToMessage(chatId.chatId, messageId, chatId.threadId) ): String = makeLinkToMessage(chatId.chatId, messageId, chatId.threadId)
/** /**
* Link which can be used as by any user to get access to [Message]. Returns null in case when there are no * Link which can be used as by any user to get access to [AccessibleMessage]. Returns null in case when there are no
* known way to build link (for [PrivateChat]s, for example) * known way to build link (for [PrivateChat]s, for example)
*/ */
fun makeLinkToMessage( fun makeLinkToMessage(
@ -88,7 +88,7 @@ fun makeLinkToMessage(
/** /**
* @see makeLinkToMessage * @see makeLinkToMessage
*/ */
val Message.messageLink: String? val AccessibleMessage.messageLink: String?
get() = makeLinkToMessage( get() = makeLinkToMessage(
chat, chat,
messageId messageId

View File

@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.utils.updates
import dev.inmo.tgbotapi.extensions.utils.* import dev.inmo.tgbotapi.extensions.utils.*
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
import dev.inmo.tgbotapi.types.message.abstracts.Message import dev.inmo.tgbotapi.types.message.abstracts.AccessibleMessage
import dev.inmo.tgbotapi.types.message.content.TextContent import dev.inmo.tgbotapi.types.message.content.TextContent
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
@ -58,10 +58,10 @@ fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands()
* } * }
* ``` * ```
* *
* @return true if this [Message] is from forum ([threadIdOrNull] is not null). False otherwise. * @return true if this [AccessibleMessage] is from forum ([threadIdOrNull] is not null). False otherwise.
* @see notForumMessage * @see notForumMessage
*/ */
fun Message.forumMessage(): Boolean = threadIdOrNull != null fun AccessibleMessage.forumMessage(): Boolean = threadIdOrNull != null
/** /**
* A predicate to test that message has not been sent in the forum. * A predicate to test that message has not been sent in the forum.
@ -76,7 +76,7 @@ fun Message.forumMessage(): Boolean = threadIdOrNull != null
* } * }
* ``` * ```
* *
* @return true if this [Message] is not from forum ([threadIdOrNull] is not null). False otherwise. * @return true if this [AccessibleMessage] is not from forum ([threadIdOrNull] is not null). False otherwise.
* @see forumMessage * @see forumMessage
*/ */
fun Message.notForumMessage(): Boolean = !forumMessage() fun AccessibleMessage.notForumMessage(): Boolean = !forumMessage()