1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-12-26 10:37:13 +00:00

reply with content

This commit is contained in:
InsanusMokrassar 2022-03-29 12:20:52 +06:00
parent b9bffbb71b
commit 94e5f74a90
3 changed files with 92 additions and 5 deletions

View File

@ -8,6 +8,9 @@
* `Klock`: `2.6.3` -> `2.7.0`
* `Core`:
* Fixes in `TextSourcesList` creating in from `RawMessageEntities`
* `API`:
* Add opportunity to `reply` with `Poll`
* Add opportunity to `reply` with any `MessageContent`
## 0.38.10

View File

@ -19,8 +19,10 @@ import dev.inmo.tgbotapi.types.dice.DiceAnimationType
import dev.inmo.tgbotapi.types.files.*
import dev.inmo.tgbotapi.types.files.sticker.Sticker
import dev.inmo.tgbotapi.types.games.Game
import dev.inmo.tgbotapi.types.location.StaticLocation
import dev.inmo.tgbotapi.types.location.*
import dev.inmo.tgbotapi.types.message.abstracts.Message
import dev.inmo.tgbotapi.types.message.content.*
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
import dev.inmo.tgbotapi.types.payments.LabeledPrice
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
import dev.inmo.tgbotapi.types.polls.*
@ -118,6 +120,7 @@ suspend inline fun TelegramBot.reply(
longitude: Double,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
to.chat,
@ -125,6 +128,7 @@ suspend inline fun TelegramBot.reply(
longitude,
disableNotification,
protectContent,
allowSendingWithoutReply,
to.messageId,
replyMarkup
)
@ -138,12 +142,14 @@ suspend inline fun TelegramBot.reply(
location: StaticLocation,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
to.chat,
location,
disableNotification,
protectContent,
allowSendingWithoutReply,
to.messageId,
replyMarkup
)
@ -887,6 +893,52 @@ suspend inline fun TelegramBot.reply(
replyMarkup: KeyboardMarkup? = null
) = sendQuizPoll(to.chat, isClosed, quizPoll, question, options, correctOptionId, isAnonymous, entities, closeInfo, disableNotification, protectContent, to.messageId, allowSendingWithoutReply, replyMarkup)
suspend inline fun TelegramBot.reply(
to: Message,
poll: Poll,
isClosed: Boolean = false,
question: String = poll.question,
options: List<String> = poll.options.map { it.text },
isAnonymous: Boolean = poll.isAnonymous,
closeInfo: ScheduledCloseInfo? = null,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = when (poll) {
is RegularPoll -> reply(
to = to,
poll = poll,
isClosed = isClosed,
question = question,
options = options,
isAnonymous = isAnonymous,
allowMultipleAnswers = isAnonymous,
closeInfo = closeInfo,
disableNotification = disableNotification,
protectContent = protectContent,
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
is UnknownPollType -> error("Unable to send poll with unknown type ($poll)")
is QuizPoll -> reply(
to = to,
quizPoll = poll,
entities = poll.textSources,
isClosed = isClosed,
question = question,
options = options,
isAnonymous = isAnonymous,
closeInfo = closeInfo,
disableNotification = disableNotification,
protectContent = protectContent,
allowSendingWithoutReply = allowSendingWithoutReply,
replyMarkup = replyMarkup
)
}
suspend inline fun TelegramBot.reply(
to: Message,
fromChatId: ChatIdentifier,
@ -921,3 +973,23 @@ suspend inline fun TelegramBot.reply(
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) = reply(to, copy.chat.id, copy.messageId, text, parseMode, disableNotification, protectContent, allowSendingWithoutReply, replyMarkup)
suspend fun TelegramBot.reply(
to: Message,
content: MessageContent,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyMarkup: KeyboardMarkup? = null
) {
execute(
content.createResend(
to.chat.id,
disableNotification,
protectContent,
to.messageId,
allowSendingWithoutReply,
replyMarkup
)
)
}

View File

@ -18,6 +18,7 @@ suspend fun TelegramBot.sendLocation(
longitude: Double,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = execute(
@ -27,6 +28,7 @@ suspend fun TelegramBot.sendLocation(
longitude,
disableNotification = disableNotification,
protectContent = protectContent,
allowSendingWithoutReply = allowSendingWithoutReply,
replyToMessageId = replyToMessageId,
replyMarkup = replyMarkup
)
@ -41,6 +43,7 @@ suspend fun TelegramBot.sendLocation(
location: StaticLocation,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
@ -49,6 +52,7 @@ suspend fun TelegramBot.sendLocation(
location.longitude,
disableNotification,
protectContent,
allowSendingWithoutReply,
replyToMessageId,
replyMarkup
)
@ -63,6 +67,7 @@ suspend fun TelegramBot.sendLocation(
longitude: Double,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
@ -71,6 +76,7 @@ suspend fun TelegramBot.sendLocation(
longitude,
disableNotification,
protectContent,
allowSendingWithoutReply,
replyToMessageId,
replyMarkup
)
@ -84,6 +90,7 @@ suspend fun TelegramBot.sendLocation(
location: StaticLocation,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(
@ -92,6 +99,7 @@ suspend fun TelegramBot.sendLocation(
location.longitude,
disableNotification,
protectContent,
allowSendingWithoutReply,
replyToMessageId,
replyMarkup
)
@ -106,9 +114,10 @@ suspend fun TelegramBot.sendStaticLocation(
longitude: Double,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, replyToMessageId, replyMarkup)
) = sendLocation(chatId, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -119,9 +128,10 @@ suspend fun TelegramBot.sendStaticLocation(
location: StaticLocation,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, replyToMessageId, replyMarkup)
) = sendLocation(chatId, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -133,9 +143,10 @@ suspend fun TelegramBot.sendStaticLocation(
longitude: Double,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, replyToMessageId, replyMarkup)
) = sendLocation(chat.id, latitude, longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)
/**
* @param replyMarkup Some of [KeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.replyKeyboard] or
@ -146,6 +157,7 @@ suspend fun TelegramBot.sendStaticLocation(
location: StaticLocation,
disableNotification: Boolean = false,
protectContent: Boolean = false,
allowSendingWithoutReply: Boolean? = null,
replyToMessageId: MessageIdentifier? = null,
replyMarkup: KeyboardMarkup? = null
) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, replyToMessageId, replyMarkup)
) = sendLocation(chat.id, location.latitude, location.longitude, disableNotification, protectContent, allowSendingWithoutReply, replyToMessageId, replyMarkup)