From 8337da34caf39c661880fd0c2bbce5d1c7486d3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Sun, 4 Oct 2020 16:47:30 +0600 Subject: [PATCH] fix of #144 plus several other changes --- CHANGELOG.md | 8 +- .../requests/send/media/SendVoice.kt | 11 +-- .../extensions/api/LiveLocation.kt | 30 ++++++-- .../extensions/api/send/SendContact.kt | 31 ++++++++ .../extensions/api/send/SendDice.kt | 8 ++ .../extensions/api/send/SendLocation.kt | 29 +++++++ .../extensions/api/send/SendMessage.kt | 18 +++++ .../extensions/api/send/SendVenue.kt | 35 +++++++++ .../extensions/api/send/games/SendGame.kt | 26 +++++++ .../api/send/media/SendAnimation.kt | 77 +++++++++++++++++++ .../extensions/api/send/media/SendAudio.kt | 65 +++++++++++++++- .../extensions/api/send/media/SendDocument.kt | 51 ++++++++++++ .../api/send/media/SendMediaGroup.kt | 13 ++++ .../extensions/api/send/media/SendPhoto.kt | 61 +++++++++++++++ .../extensions/api/send/media/SendSticker.kt | 48 ++++++++++++ .../extensions/api/send/media/SendVideo.kt | 62 ++++++++++++++- .../api/send/media/SendVideoNote.kt | 58 +++++++++++++- .../extensions/api/send/media/SendVoice.kt | 58 +++++++++++++- .../api/send/payments/SendInvoice.kt | 22 ++++++ .../extensions/api/send/polls/SendPoll.kt | 68 +++++++++++++--- 20 files changed, 744 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05937b3055..aaffec0ff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,9 +46,15 @@ * `TelegramBotAPI-core`: * Now in forward info you can get `ForwardFromSupergroupInfo` + * **BREAKING CHANGE** `SendVoice` factory function has changed its signature: now it have now `thumb` + (according to the [documentation](https://core.telegram.org/bots/api#sendvoice)) * `TelegramBotAPI-extensions-api`: * ALL REQUESTS EXECUTOR USAGES WERE REPLACED WITH `TelegramBot` TYPEALIAS. It should not bring any break changes - + * Internal changes of `sendRegularPoll` and `sendQuizPoll` extensions + * Variable `defaultLivePeriodDelayMillis` now is public + * All `send` extensions for `TelegramBot` got their `reply` variations (issue [#144](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/144)) + * A lot of `send` extensions for `TelegramBot` got their variation with `Chat` instead of `ChatIdentifier` + ### 0.28.4 * `Common`: diff --git a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt index 24272364fd..be510619b3 100644 --- a/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt +++ b/TelegramBotAPI-core/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/requests/send/media/SendVoice.kt @@ -17,7 +17,6 @@ import kotlinx.serialization.* fun SendVoice( chatId: ChatIdentifier, voice: InputFile, - thumb: InputFile? = null, caption: String? = null, parseMode: ParseMode? = null, duration: Long? = null, @@ -27,13 +26,10 @@ fun SendVoice( ): Request> { val voiceAsFileId = (voice as? FileId) ?.fileId val voiceAsFile = voice as? MultipartFile - val thumbAsFileId = (thumb as? FileId) ?.fileId - val thumbAsFile = thumb as? MultipartFile val data = SendVoiceData( chatId, voiceAsFileId, - thumbAsFileId, caption, parseMode, duration, @@ -42,12 +38,12 @@ fun SendVoice( replyMarkup ) - return if (voiceAsFile == null && thumbAsFile == null) { + return if (voiceAsFile == null) { data } else { MultipartRequestImpl( data, - SendVoiceFiles(voiceAsFile, thumbAsFile) + SendVoiceFiles(voiceAsFile) ) } } @@ -61,8 +57,6 @@ data class SendVoiceData internal constructor( override val chatId: ChatIdentifier, @SerialName(voiceField) val voice: String? = null, - @SerialName(thumbField) - override val thumb: String? = null, @SerialName(captionField) override val text: String? = null, @SerialName(parseModeField) @@ -79,7 +73,6 @@ data class SendVoiceData internal constructor( SendMessageRequest>, ReplyingMarkupSendMessageRequest>, TextableSendMessageRequest>, - ThumbedSendMessageRequest>, DuratedSendMessageRequest> { init { diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/LiveLocation.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/LiveLocation.kt index b57ec1254e..f66f460c89 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/LiveLocation.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/LiveLocation.kt @@ -9,6 +9,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMa import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.ContentMessage +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.LocationContent import com.soywiz.klock.DateTime import com.soywiz.klock.TimeSpan @@ -17,7 +18,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlin.math.ceil -private val livePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L +val defaultLivePeriodDelayMillis = (livePeriodLimit.last - 60L) * 1000L class LiveLocation internal constructor( private val requestsExecutor: TelegramBot, scope: CoroutineScope, @@ -71,7 +72,7 @@ suspend fun TelegramBot.startLiveLocation( chatId: ChatIdentifier, latitude: Double, longitude: Double, - liveTimeMillis: Long = livePeriodDelayMillis, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null @@ -102,7 +103,7 @@ suspend fun TelegramBot.startLiveLocation( chat: Chat, latitude: Double, longitude: Double, - liveTimeMillis: Long = livePeriodDelayMillis, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null @@ -114,7 +115,7 @@ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chatId: ChatId, location: Location, - liveTimeMillis: Long = livePeriodDelayMillis, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null @@ -126,10 +127,29 @@ suspend fun TelegramBot.startLiveLocation( scope: CoroutineScope, chat: Chat, location: Location, - liveTimeMillis: Long = livePeriodDelayMillis, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ): LiveLocation = startLiveLocation( scope, chat.id, location.latitude, location.longitude, liveTimeMillis, disableNotification, replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.replyWithLiveLocation( + to: Message, + scope: CoroutineScope, + latitude: Double, + longitude: Double, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = startLiveLocation(scope, to.chat, latitude, longitude, liveTimeMillis, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithLiveLocation( + to: Message, + scope: CoroutineScope, + location: Location, + liveTimeMillis: Long = defaultLivePeriodDelayMillis, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = startLiveLocation(scope, to.chat, location, liveTimeMillis, disableNotification, to.messageId, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendContact.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendContact.kt index 17a8f48921..854432f1d2 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendContact.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendContact.kt @@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendContact import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendContact( chatId: ChatIdentifier, @@ -53,3 +54,33 @@ suspend fun TelegramBot.sendContact( ) = sendContact( chat.id, contact, disableNotification, replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.reply( + to: Message, + phoneNumber: String, + firstName: String, + lastName: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendContact( + to.chat, + phoneNumber, + firstName, + lastName, + disableNotification, + to.messageId, + replyMarkup +) + +suspend inline fun TelegramBot.reply( + to: Message, + contact: Contact, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendContact( + to.chat, + contact, + disableNotification, + to.messageId, + replyMarkup +) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt index f29ba0a86a..9093d6fcf2 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendDice.kt @@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.dice.DiceAnimationType +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendDice( chatId: ChatIdentifier, @@ -25,3 +26,10 @@ suspend fun TelegramBot.sendDice( replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendDice(chat.id, animationType, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + animationType: DiceAnimationType? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendDice(to.chat, animationType, disableNotification, to.messageId, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendLocation.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendLocation.kt index 7b285b4154..04781a8a11 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendLocation.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendLocation.kt @@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendLocation import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendLocation( chatId: ChatIdentifier, @@ -69,3 +70,31 @@ suspend fun TelegramBot.sendLocation( replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.reply( + to: Message, + latitude: Double, + longitude: Double, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendLocation( + to.chat, + latitude, + longitude, + disableNotification, + to.messageId, + replyMarkup +) + +suspend inline fun TelegramBot.reply( + to: Message, + location: Location, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendLocation( + to.chat, + location, + disableNotification, + to.messageId, + replyMarkup +) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendMessage.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendMessage.kt index 3167cd1023..bb97f4b745 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendMessage.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendMessage.kt @@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendMessage( chatId: ChatIdentifier, @@ -52,3 +53,20 @@ suspend fun TelegramBot.sendTextMessage( replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendTextMessage(chat.id, text, parseMode, disableWebPagePreview, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + text: String, + parseMode: ParseMode? = null, + disableWebPagePreview: Boolean? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendTextMessage( + to.chat, + text, + parseMode, + disableWebPagePreview, + disableNotification, + to.messageId, + replyMarkup +) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt index 931e788370..ac763ea6ba 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/SendVenue.kt @@ -5,6 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendVenue import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.venue.Venue suspend fun TelegramBot.sendVenue( @@ -84,3 +85,37 @@ suspend fun TelegramBot.sendVenue( ) = sendVenue( chat.id, venue, disableNotification, replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.reply( + to: Message, + latitude: Double, + longitude: Double, + title: String, + address: String, + foursquareId: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVenue( + to.chat, latitude, longitude, title, address, foursquareId, disableNotification, to.messageId, replyMarkup +) + +suspend inline fun TelegramBot.reply( + to: Message, + location: Location, + title: String, + address: String, + foursquareId: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVenue( + to.chat, location, title, address, foursquareId, disableNotification, to.messageId, replyMarkup +) + +suspend inline fun TelegramBot.reply( + to: Message, + venue: Venue, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVenue( + to.chat, venue, disableNotification, to.messageId, replyMarkup +) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/games/SendGame.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/games/SendGame.kt index 709c02d955..9bcf6eea4f 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/games/SendGame.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/games/SendGame.kt @@ -7,6 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.games.Game +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendGame( chatId: ChatIdentifier, @@ -49,3 +50,28 @@ suspend fun TelegramBot.sendGame( ) = sendGame( chat.id, game.title, disableNotification, replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.replyWithGame( + to: Message, + gameShortName: String, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendGame( + to.chat, gameShortName, disableNotification, to.messageId, replyMarkup +) + +suspend inline fun TelegramBot.replyWithGame( + to: Message, + game: Game, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendGame( + to.chat, game.title, disableNotification, to.messageId, replyMarkup +) + +suspend inline fun TelegramBot.reply( + to: Message, + game: Game, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithGame(to, game, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt index 6f0b1e69a3..6eb0f4a70e 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAnimation.kt @@ -7,7 +7,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendAnimation( chatId: ChatIdentifier, @@ -52,3 +54,78 @@ suspend fun TelegramBot.sendAnimation( chatId, animation.fileId, animation.thumb ?.fileId, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup ) +suspend fun TelegramBot.sendAnimation( + chat: Chat, + animation: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation(chat.id, animation, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendAnimation( + chat: Chat, + animation: AnimationFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation(chat.id, animation, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithAnimation( + to: Message, + animation: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation( + to.chat, + animation, + thumb, + text, + parseMode, + duration, + width, + height, + disableNotification, + to.messageId, + replyMarkup +) + +suspend inline fun TelegramBot.replyWithAnimation( + to: Message, + animation: AnimationFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendAnimation(to.chat, animation, text, parseMode, duration, width, height, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + animation: AnimationFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithAnimation(to, animation, text, parseMode, duration, width, height, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt index 8a3cbe82fa..cf367922c7 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendAudio.kt @@ -7,7 +7,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.files.AnimationFile import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendAudio( chatId: ChatIdentifier, @@ -37,6 +40,20 @@ suspend fun TelegramBot.sendAudio( ) ) +suspend fun TelegramBot.sendAudio( + chat: Chat, + audio: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + performer: String? = null, + title: String? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAudio(chat.id, audio, thumb, text, parseMode, duration, performer, title, disableNotification, replyToMessageId, replyMarkup) + suspend fun TelegramBot.sendAudio( chatId: ChatIdentifier, audio: AudioFile, @@ -46,6 +63,48 @@ suspend fun TelegramBot.sendAudio( disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = sendAudio( - chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup -) +) = sendAudio(chatId, audio.fileId, audio.thumb ?.fileId, text, parseMode, audio.duration, audio.performer, title, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendAudio( + chat: Chat, + audio: AudioFile, + text: String? = null, + parseMode: ParseMode? = null, + title: String? = audio.title, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendAudio(chat.id, audio, text, parseMode, title, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithAudio( + to: Message, + audio: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + performer: String? = null, + title: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendAudio(to.chat, audio, thumb, text, parseMode, duration, performer, title, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithAudio( + to: Message, + audio: AudioFile, + text: String? = null, + parseMode: ParseMode? = null, + title: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendAudio(to.chat, audio, text, parseMode, title, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + audio: AudioFile, + text: String? = null, + parseMode: ParseMode? = null, + title: String? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithAudio(to, audio, text, parseMode, title, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt index c55b49997d..0cdf814ad4 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendDocument.kt @@ -7,7 +7,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendDocument( chatId: ChatIdentifier, @@ -31,6 +33,17 @@ suspend fun TelegramBot.sendDocument( ) ) +suspend fun TelegramBot.sendDocument( + chat: Chat, + document: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendDocument(chat.id, document, thumb, text, parseMode, disableNotification, replyToMessageId, replyMarkup) + suspend fun TelegramBot.sendDocument( chatId: ChatIdentifier, document: DocumentFile, @@ -42,3 +55,41 @@ suspend fun TelegramBot.sendDocument( ) = sendDocument( chatId, document.fileId, document.thumb ?.fileId, text, parseMode, disableNotification, replyToMessageId, replyMarkup ) + +suspend fun TelegramBot.sendDocument( + chat: Chat, + document: DocumentFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendDocument(chat.id, document, text, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithDocument( + to: Message, + document: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendDocument(to.chat, document, thumb, text, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithDocument( + to: Message, + document: DocumentFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendDocument(to.chat, document, text, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + document: DocumentFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithDocument(to, document, text, parseMode, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendMediaGroup.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendMediaGroup.kt index 5d13876d44..52bcd4fd76 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendMediaGroup.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendMediaGroup.kt @@ -6,6 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendMediaGroup( chatId: ChatIdentifier, @@ -26,3 +27,15 @@ suspend fun TelegramBot.sendMediaGroup( ) = sendMediaGroup( chat.id, media, disableNotification, replyToMessageId ) + +suspend inline fun TelegramBot.replyWithMediaGroup( + to: Message, + media: List, + disableNotification: Boolean = false +) = sendMediaGroup(to.chat, media, disableNotification, to.messageId) + +suspend inline fun TelegramBot.reply( + to: Message, + media: List, + disableNotification: Boolean = false +) = replyWithMediaGroup(to, media, disableNotification) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt index 355930cfc2..2756b16213 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendPhoto.kt @@ -7,6 +7,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.files.Photo +import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendPhoto( chatId: ChatIdentifier, @@ -27,3 +31,60 @@ suspend fun TelegramBot.sendPhoto( replyMarkup ) ) + +suspend fun TelegramBot.sendPhoto( + chat: Chat, + fileId: InputFile, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendPhoto(chat.id, fileId, caption, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendPhoto( + chatId: ChatIdentifier, + photo: Photo, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendPhoto(chatId, photo.biggest() ?.fileId ?: error("Photo content must not be empty"), caption, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendPhoto( + chat: Chat, + photo: Photo, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendPhoto(chat.id, photo, caption, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithPhoto( + to: Message, + fileId: InputFile, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendPhoto(to.chat, fileId, caption, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithPhoto( + to: Message, + photo: Photo, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendPhoto(to.chat, photo, caption, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + photo: Photo, + caption: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithPhoto(to, photo, caption, parseMode, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt index 8a3936231f..668a51868c 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendSticker.kt @@ -6,6 +6,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendSticke import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.files.Sticker +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendSticker( chatId: ChatIdentifier, @@ -16,3 +19,48 @@ suspend fun TelegramBot.sendSticker( ) = execute( SendSticker(chatId, sticker, disableNotification, replyToMessageId, replyMarkup) ) + +suspend fun TelegramBot.sendSticker( + chat: Chat, + sticker: InputFile, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendSticker(chat.id, sticker, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendSticker( + chatId: ChatIdentifier, + sticker: Sticker, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendSticker(chatId, sticker.fileId, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendSticker( + chat: Chat, + sticker: Sticker, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendSticker(chat, sticker.fileId, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithSticker( + to: Message, + sticker: InputFile, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendSticker(to.chat, sticker, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithSticker( + to: Message, + sticker: Sticker, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendSticker(to.chat, sticker, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + sticker: Sticker, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithSticker(to, sticker, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt index eb2897ee17..b62ff99500 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideo.kt @@ -7,7 +7,9 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendVideo( chatId: ChatIdentifier, @@ -46,6 +48,60 @@ suspend fun TelegramBot.sendVideo( disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = sendVideo( - chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup -) +) = sendVideo(chatId, video.fileId, video.thumb ?.fileId, text, parseMode, video.duration, video.width, video.height, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendVideo( + chat: Chat, + video: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVideo(chat.id, video, thumb, text, parseMode, duration, width, height, disableNotification, replyToMessageId, replyMarkup) + + +suspend fun TelegramBot.sendVideo( + chat: Chat, + video: VideoFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVideo(chat.id, video, text, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVideo( + to: Message, + video: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + width: Int? = null, + height: Int? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVideo(to.chat, video, thumb, text, parseMode, duration, width, height, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVideo( + to: Message, + video: VideoFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVideo(to.chat, video, text, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + video: VideoFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithVideo(to, video, text, parseMode, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt index 3bcf4ae43c..96bd8cf6a8 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVideoNote.kt @@ -7,7 +7,10 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile +import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoNoteFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, @@ -37,7 +40,7 @@ suspend fun TelegramBot.sendVideoNote( suspend fun TelegramBot.sendVideoNote( chatId: ChatIdentifier, - videoNote: VideoFile, + videoNote: VideoNoteFile, text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, @@ -46,3 +49,56 @@ suspend fun TelegramBot.sendVideoNote( ) = sendVideoNote( chatId, videoNote.fileId, videoNote.thumb ?.fileId, text, parseMode, videoNote.duration, videoNote.width, disableNotification, replyToMessageId, replyMarkup ) + +suspend fun TelegramBot.sendVideoNote( + chat: Chat, + videoNote: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + size: Int? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVideoNote(chat.id, videoNote, thumb, text, parseMode, duration, size, disableNotification, replyToMessageId, replyMarkup) + +suspend fun TelegramBot.sendVideoNote( + chat: Chat, + videoNote: VideoNoteFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVideoNote(chat.id, videoNote, text, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVideoNote( + to: Message, + videoNote: InputFile, + thumb: InputFile? = null, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + size: Int? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVideoNote(to.chat, videoNote, thumb, text, parseMode, duration, size, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVideoNote( + to: Message, + videoNote: VideoNoteFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVideoNote(to.chat, videoNote, text, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + videoNote: VideoNoteFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithVideoNote(to, videoNote, text, parseMode, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt index 0eadf6c2ae..028a0ca735 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/media/SendVoice.kt @@ -7,12 +7,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile +import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message suspend fun TelegramBot.sendVoice( chatId: ChatIdentifier, voice: InputFile, - thumb: InputFile? = null, text: String? = null, parseMode: ParseMode? = null, duration: Long? = null, @@ -23,7 +25,6 @@ suspend fun TelegramBot.sendVoice( SendVoice( chatId, voice, - thumb, text, parseMode, duration, @@ -33,14 +34,63 @@ suspend fun TelegramBot.sendVoice( ) ) +suspend fun TelegramBot.sendVoice( + chat: Chat, + voice: InputFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVoice(chat.id, voice, text, parseMode, duration, disableNotification, replyToMessageId, replyMarkup) + suspend fun TelegramBot.sendVoice( chatId: ChatIdentifier, - voice: AudioFile, + voice: VoiceFile, text: String? = null, parseMode: ParseMode? = null, disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null ) = sendVoice( - chatId, voice.fileId, voice.thumb ?.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup + chatId, voice.fileId, text, parseMode, voice.duration, disableNotification, replyToMessageId, replyMarkup ) + +suspend fun TelegramBot.sendVoice( + chat: Chat, + voice: VoiceFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyToMessageId: MessageIdentifier? = null, + replyMarkup: KeyboardMarkup? = null +) = sendVoice(chat.id, voice, text, parseMode, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVoice( + to: Message, + voice: InputFile, + text: String? = null, + parseMode: ParseMode? = null, + duration: Long? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVoice(to.chat, voice, text, parseMode, duration, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithVoice( + to: Message, + voice: VoiceFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendVoice(to.chat, voice, text, parseMode, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.reply( + to: Message, + voice: VoiceFile, + text: String? = null, + parseMode: ParseMode? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = replyWithVoice(to, voice, text, parseMode, disableNotification, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/payments/SendInvoice.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/payments/SendInvoice.kt index 221cb013c5..e669bc546b 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/payments/SendInvoice.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/payments/SendInvoice.kt @@ -4,6 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.bot.TelegramBot import com.github.insanusmokrassar.TelegramBotAPI.requests.send.payments.SendInvoice import com.github.insanusmokrassar.TelegramBotAPI.types.* import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.InlineKeyboardMarkup +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.payments.LabeledPrice import com.github.insanusmokrassar.TelegramBotAPI.types.payments.abstracts.Currency @@ -52,3 +53,24 @@ suspend fun TelegramBot.sendInvoice( replyToMessageId: MessageIdentifier? = null, replyMarkup: InlineKeyboardMarkup? = null ) = sendInvoice(user.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, replyToMessageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithInvoice( + to: Message, + title: String, + description: String, + payload: String, + providerToken: String, + startParameter: StartParameter, + currency: Currency, + prices: List, + providerData: String? = null, + requireName: Boolean = false, + requirePhoneNumber: Boolean = false, + requireEmail: Boolean = false, + requireShippingAddress: Boolean = false, + shouldSendPhoneNumberToProvider: Boolean = false, + shouldSendEmailToProvider: Boolean = false, + priceDependOnShipAddress: Boolean = false, + disableNotification: Boolean = false, + replyMarkup: InlineKeyboardMarkup? = null +) = sendInvoice(to.chat.id, title, description, payload, providerToken, startParameter, currency, prices, providerData, requireName, requirePhoneNumber, requireEmail, requireShippingAddress, shouldSendPhoneNumberToProvider, shouldSendEmailToProvider, priceDependOnShipAddress, disableNotification, to.messageId, replyMarkup) diff --git a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt index 4e00309ee5..fde58e4ce2 100644 --- a/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt +++ b/TelegramBotAPI-extensions-api/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/api/send/polls/SendPoll.kt @@ -8,6 +8,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.ParseMode import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.Chat +import com.github.insanusmokrassar.TelegramBotAPI.types.message.abstracts.Message import com.github.insanusmokrassar.TelegramBotAPI.types.polls.* suspend fun TelegramBot.sendRegularPoll( @@ -38,11 +39,7 @@ suspend fun TelegramBot.sendRegularPoll( disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = execute( - SendRegularPoll( - chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup - ) -) +) = sendRegularPoll(chatId, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, replyToMessageId, replyMarkup) suspend fun TelegramBot.sendRegularPoll( chat: Chat, @@ -126,10 +123,8 @@ suspend fun TelegramBot.sendQuizPoll( disableNotification: Boolean = false, replyToMessageId: MessageIdentifier? = null, replyMarkup: KeyboardMarkup? = null -) = execute( - SendQuizPoll( - chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup - ) +) = sendQuizPoll( + chatId, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) suspend fun TelegramBot.sendQuizPoll( @@ -149,3 +144,58 @@ suspend fun TelegramBot.sendQuizPoll( ) = sendQuizPoll( chat.id, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, replyToMessageId, replyMarkup ) + +suspend inline fun TelegramBot.replyWithRegularPoll( + to: Message, + question: String, + options: List, + isAnonymous: Boolean = true, + isClosed: Boolean = false, + allowMultipleAnswers: Boolean = false, + closeInfo: ScheduledCloseInfo? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendRegularPoll(to.chat, question, options, isAnonymous, isClosed, allowMultipleAnswers, closeInfo, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithRegularPoll( + to: Message, + poll: RegularPoll, + isClosed: Boolean = false, + question: String = poll.question, + options: List = poll.options.map { it.text }, + isAnonymous: Boolean = poll.isAnonymous, + allowMultipleAnswers: Boolean = poll.allowMultipleAnswers, + closeInfo: ScheduledCloseInfo? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendRegularPoll(to.chat, poll, isClosed, question, options, isAnonymous, allowMultipleAnswers, closeInfo, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithQuizPoll( + to: Message, + question: String, + options: List, + correctOptionId: Int, + isAnonymous: Boolean = true, + isClosed: Boolean = false, + explanation: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendQuizPoll(to.chat, question, options, correctOptionId, isAnonymous, isClosed, explanation, parseMode, closeInfo, disableNotification, to.messageId, replyMarkup) + +suspend inline fun TelegramBot.replyWithQuizPoll( + to: Message, + isClosed: Boolean = false, + quizPoll: QuizPoll, + question: String = quizPoll.question, + options: List = quizPoll.options.map { it.text }, + correctOptionId: Int = quizPoll.correctOptionId ?: error("Correct option ID must be provided by income QuizPoll or by developer"), + isAnonymous: Boolean = quizPoll.isAnonymous, + explanation: String? = null, + parseMode: ParseMode? = null, + closeInfo: ScheduledCloseInfo? = null, + disableNotification: Boolean = false, + replyMarkup: KeyboardMarkup? = null +) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, explanation, parseMode, closeInfo, disableNotification, to.messageId, replyMarkup) +