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

add threadIdOrNull extension

This commit is contained in:
InsanusMokrassar 2022-11-08 13:07:16 +06:00
parent a80ed2ec57
commit 6a899f1217
2 changed files with 75 additions and 69 deletions

View File

@ -31,6 +31,7 @@ import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.* import dev.inmo.tgbotapi.types.polls.*
import dev.inmo.tgbotapi.types.venue.Venue import dev.inmo.tgbotapi.types.venue.Venue
import dev.inmo.tgbotapi.utils.* import dev.inmo.tgbotapi.utils.*
import dev.inmo.tgbotapi.utils.extensions.threadIdOrNull
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlin.js.JsName import kotlin.js.JsName
import kotlin.jvm.JvmName import kotlin.jvm.JvmName
@ -56,7 +57,7 @@ suspend inline fun TelegramBot.reply(
phoneNumber, phoneNumber,
firstName, firstName,
lastName, lastName,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -78,7 +79,7 @@ suspend inline fun TelegramBot.reply(
) = sendContact( ) = sendContact(
to.chat, to.chat,
contact, contact,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -100,7 +101,7 @@ suspend inline fun TelegramBot.replyWithDice(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendDice(to.chat, animationType, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendDice(to.chat, animationType, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
/** /**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or * @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -134,7 +135,7 @@ suspend inline fun TelegramBot.reply(
to.chat, to.chat,
latitude, latitude,
longitude, longitude,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
allowSendingWithoutReply, allowSendingWithoutReply,
@ -156,7 +157,7 @@ suspend inline fun TelegramBot.reply(
) = sendLocation( ) = sendLocation(
to.chat, to.chat,
location, location,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
allowSendingWithoutReply, allowSendingWithoutReply,
@ -185,7 +186,7 @@ suspend inline fun TelegramBot.reply(
text, text,
parseMode, parseMode,
disableWebPagePreview, disableWebPagePreview,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -209,7 +210,7 @@ suspend inline fun TelegramBot.reply(
to.chat, to.chat,
entities, entities,
disableWebPagePreview, disableWebPagePreview,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -278,7 +279,7 @@ suspend inline fun TelegramBot.reply(
foursquareType = foursquareType, foursquareType = foursquareType,
googlePlaceId = googlePlaceId, googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType, googlePlaceType = googlePlaceType,
threadId = (to as? PossiblyTopicMessage) ?.threadId, threadId = to.threadIdOrNull,
disableNotification = disableNotification, disableNotification = disableNotification,
protectContent = protectContent, protectContent = protectContent,
replyToMessageId = to.messageId, replyToMessageId = to.messageId,
@ -309,7 +310,7 @@ suspend inline fun TelegramBot.reply(
foursquareType = foursquareType, foursquareType = foursquareType,
googlePlaceId = googlePlaceId, googlePlaceId = googlePlaceId,
googlePlaceType = googlePlaceType, googlePlaceType = googlePlaceType,
threadId = (to as? PossiblyTopicMessage) ?.threadId, threadId = to.threadIdOrNull,
disableNotification = disableNotification, disableNotification = disableNotification,
protectContent = protectContent, protectContent = protectContent,
replyToMessageId = to.messageId, replyToMessageId = to.messageId,
@ -327,7 +328,7 @@ suspend inline fun TelegramBot.reply(
) = sendVenue( ) = sendVenue(
chat = to.chat, chat = to.chat,
venue = venue, venue = venue,
threadId = (to as? PossiblyTopicMessage) ?.threadId, threadId = to.threadIdOrNull,
disableNotification = disableNotification, disableNotification = disableNotification,
protectContent = protectContent, protectContent = protectContent,
replyToMessageId = to.messageId, replyToMessageId = to.messageId,
@ -346,7 +347,7 @@ suspend inline fun TelegramBot.replyWithGame(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendGame( ) = sendGame(
to.chat, gameShortName, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup to.chat, gameShortName, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
) )
suspend inline fun TelegramBot.replyWithGame( suspend inline fun TelegramBot.replyWithGame(
@ -357,7 +358,7 @@ suspend inline fun TelegramBot.replyWithGame(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendGame( ) = sendGame(
to.chat, game.title, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup to.chat, game.title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup
) )
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
@ -394,7 +395,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
duration, duration,
width, width,
height, height,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -414,7 +415,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithAnimation( suspend inline fun TelegramBot.replyWithAnimation(
to: Message, to: Message,
@ -436,7 +437,7 @@ suspend inline fun TelegramBot.replyWithAnimation(
duration, duration,
width, width,
height, height,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -455,7 +456,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAnimation(to.chat, animation, entities, duration, width, height, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendAnimation(to.chat, animation, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Audio // Audio
@ -473,7 +474,7 @@ suspend inline fun TelegramBot.replyWithAudio(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -485,7 +486,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, text, parseMode, title, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -499,7 +500,7 @@ suspend inline fun TelegramBot.replyWithAudio(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, thumb, entities, duration, performer, title, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -510,7 +511,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendAudio(to.chat, audio, entities, title, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendAudio(to.chat, audio, entities, title, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Documents // Documents
@ -526,7 +527,7 @@ suspend inline fun TelegramBot.replyWithDocument(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null, replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, thumb, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -538,7 +539,7 @@ suspend inline fun TelegramBot.reply(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null, replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -550,7 +551,7 @@ suspend inline fun TelegramBot.replyWithDocument(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null, replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, thumb, entities, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -561,7 +562,7 @@ suspend inline fun TelegramBot.reply(
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null, replyMarkup: KeyboardMarkup? = null,
disableContentTypeDetection: Boolean? = null disableContentTypeDetection: Boolean? = null
) = sendDocument(to.chat, document, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection) ) = sendDocument(to.chat, document, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup, disableContentTypeDetection)
// Media Group // Media Group
@ -573,7 +574,7 @@ suspend inline fun TelegramBot.replyWithMediaGroup(
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null allowSendingWithoutReply: Boolean? = null
) = sendMediaGroup(to.chat, media, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -581,7 +582,7 @@ suspend inline fun TelegramBot.replyWithPlaylist(
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null allowSendingWithoutReply: Boolean? = null
) = sendPlaylist(to.chat, media, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -589,7 +590,7 @@ suspend inline fun TelegramBot.replyWithDocuments(
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null allowSendingWithoutReply: Boolean? = null
) = sendDocumentsGroup(to.chat, media, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -597,7 +598,7 @@ suspend inline fun TelegramBot.replyWithGallery(
disableNotification: Boolean = false, disableNotification: Boolean = false,
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null allowSendingWithoutReply: Boolean? = null
) = sendVisualMediaGroup(to.chat, media, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply) ) = sendVisualMediaGroup(to.chat, media, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply)
// Photo // Photo
@ -611,7 +612,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, fileId, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -622,7 +623,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photo, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -633,7 +634,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photoSize, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithPhoto( suspend inline fun TelegramBot.replyWithPhoto(
@ -644,7 +645,7 @@ suspend inline fun TelegramBot.replyWithPhoto(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, fileId, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, fileId, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -654,7 +655,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photo, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photo, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -664,7 +665,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendPhoto(to.chat, photoSize, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendPhoto(to.chat, photoSize, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Sticker // Sticker
@ -676,7 +677,7 @@ suspend inline fun TelegramBot.replyWithSticker(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendSticker(to.chat, sticker, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -685,7 +686,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendSticker(to.chat, sticker, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendSticker(to.chat, sticker, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Videos // Videos
@ -703,7 +704,7 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -714,7 +715,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVideo( suspend inline fun TelegramBot.replyWithVideo(
to: Message, to: Message,
@ -728,7 +729,7 @@ suspend inline fun TelegramBot.replyWithVideo(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, thumb, entities, duration, width, height, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, thumb, entities, duration, width, height, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
to: Message, to: Message,
@ -738,7 +739,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideo(to.chat, video, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideo(to.chat, video, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// VideoNotes // VideoNotes
@ -753,7 +754,7 @@ suspend inline fun TelegramBot.replyWithVideoNote(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(to.chat, videoNote, thumb, duration, size, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -762,7 +763,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVideoNote(to.chat, videoNote, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVideoNote(to.chat, videoNote, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Voice // Voice
@ -777,7 +778,7 @@ suspend inline fun TelegramBot.replyWithVoice(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, text, parseMode, duration, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -788,7 +789,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, text, parseMode, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVoice(to.chat, voice, text, parseMode, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.replyWithVoice( suspend inline fun TelegramBot.replyWithVoice(
@ -800,7 +801,7 @@ suspend inline fun TelegramBot.replyWithVoice(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, entities, duration, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -810,7 +811,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendVoice(to.chat, voice, entities, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendVoice(to.chat, voice, entities, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Invoice // Invoice
@ -842,7 +843,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: InlineKeyboardMarkup? = null replyMarkup: InlineKeyboardMarkup? = null
) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendInvoice(to.chat.id, title, description, payload, providerToken, currency, prices, maxTipAmount, suggestedTipAmounts, startParameter, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
// Polls // Polls
@ -859,7 +860,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -874,7 +875,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -890,7 +891,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -907,7 +908,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -922,7 +923,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, entities, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, 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: Message,
@ -938,7 +939,7 @@ suspend inline fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, (to as? PossiblyTopicMessage) ?.threadId, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup) ) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, to.threadIdOrNull, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply( suspend inline fun TelegramBot.reply(
@ -1002,7 +1003,7 @@ suspend inline fun TelegramBot.reply(
messageId, messageId,
text, text,
parseMode, parseMode,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
@ -1040,19 +1041,17 @@ suspend fun TelegramBot.reply(
protectContent: Boolean = false, protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null, allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null replyMarkup: KeyboardMarkup? = null
) { ): Message = execute(
execute(
content.createResend( content.createResend(
to.chat.id, to.chat.id,
(to as? PossiblyTopicMessage) ?.threadId, to.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
to.messageId, to.messageId,
allowSendingWithoutReply, allowSendingWithoutReply,
replyMarkup replyMarkup
) )
) )
}
/** /**
* Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update * Will use [handleLiveLocation] with replying to [message] each time new message will be sent by live location update
@ -1070,7 +1069,7 @@ suspend fun TelegramBot.reply(
message.chat.id, message.chat.id,
locationsFlow, locationsFlow,
liveTimeMillis, liveTimeMillis,
(message as? PossiblyTopicMessage) ?.threadId, message.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
message.messageId, message.messageId,
@ -1096,7 +1095,7 @@ suspend fun TelegramBot.reply(
message.chat.id, message.chat.id,
locationsFlow, locationsFlow,
liveTimeMillis, liveTimeMillis,
(message as? PossiblyTopicMessage) ?.threadId, message.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
message.messageId, message.messageId,
@ -1123,7 +1122,7 @@ suspend fun TelegramBot.reply(
message.chat.id, message.chat.id,
locationsFlow, locationsFlow,
liveTimeMillis, liveTimeMillis,
(message as? PossiblyTopicMessage) ?.threadId, message.threadIdOrNull,
disableNotification, disableNotification,
protectContent, protectContent,
message.messageId, message.messageId,

View File

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