mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
message content resend by default using HTMLParseMode
This commit is contained in:
parent
e26741d882
commit
997f9ce411
@ -55,6 +55,8 @@ media for present out)
|
||||
* Add `CommonLimiter`
|
||||
* Add `MessageEntity#asHtmlSource` and `String#toHtml`
|
||||
* Add tools for work with html captions and texts
|
||||
* `MessageContent` which using captions or text now have default parse mode `HTMLParseMode` due to issue with escaping
|
||||
of `]` in links titles
|
||||
|
||||
## 0.11.0
|
||||
|
||||
|
@ -5,10 +5,11 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.SendMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
||||
|
||||
data class TextContent(
|
||||
@ -22,8 +23,8 @@ data class TextContent(
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): Request<RawMessage> = SendMessage(
|
||||
chatId,
|
||||
toMarkdownTexts().first(),
|
||||
MarkdownParseMode,
|
||||
toHtmlTexts().first(),
|
||||
HTMLParseMode,
|
||||
false,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
@ -35,11 +36,28 @@ data class TextContent(
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?
|
||||
): List<Request<RawMessage>> = toMarkdownTexts().map {
|
||||
): List<Request<RawMessage>> = createResends(
|
||||
chatId,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup,
|
||||
HTMLParseMode
|
||||
)
|
||||
|
||||
fun createResends(
|
||||
chatId: ChatIdentifier,
|
||||
disableNotification: Boolean,
|
||||
replyToMessageId: MessageIdentifier?,
|
||||
replyMarkup: KeyboardMarkup?,
|
||||
parseMode: ParseMode = HTMLParseMode
|
||||
): List<Request<RawMessage>> = when (parseMode) {
|
||||
is MarkdownParseMode -> toMarkdownTexts()
|
||||
is HTMLParseMode -> toHtmlTexts()
|
||||
}.map {
|
||||
SendMessage(
|
||||
chatId,
|
||||
it,
|
||||
MarkdownParseMode,
|
||||
parseMode,
|
||||
false,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
|
@ -5,12 +5,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendAudio
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class AudioContent(
|
||||
@ -27,8 +29,8 @@ data class AudioContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
media.duration,
|
||||
media.performer,
|
||||
media.title,
|
||||
|
@ -5,12 +5,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendDocume
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class DocumentContent(
|
||||
@ -27,8 +29,8 @@ data class DocumentContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
|
@ -7,12 +7,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMediaPho
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class PhotoContent(
|
||||
@ -30,8 +32,8 @@ data class PhotoContent(
|
||||
): Request<RawMessage> = SendPhoto(
|
||||
chatId,
|
||||
media.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
replyMarkup
|
||||
@ -39,7 +41,7 @@ data class PhotoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto(
|
||||
media.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode
|
||||
)
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.InputMediaVid
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.InputMedia.MediaGroupMemberInputMedia
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class VideoContent(
|
||||
@ -28,8 +30,8 @@ data class VideoContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
media.thumb ?.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
media.duration,
|
||||
media.width,
|
||||
media.height,
|
||||
@ -41,8 +43,8 @@ data class VideoContent(
|
||||
|
||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo(
|
||||
media.fileId,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
media.width,
|
||||
media.height,
|
||||
media.duration,
|
||||
|
@ -5,12 +5,14 @@ import com.github.insanusmokrassar.TelegramBotAPI.requests.send.media.SendVoice
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ChatIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.HTMLParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.ParseMode.MarkdownParseMode
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||
|
||||
data class VoiceContent(
|
||||
@ -27,8 +29,8 @@ data class VoiceContent(
|
||||
chatId,
|
||||
media.fileId,
|
||||
null,
|
||||
toMarkdownCaptions().firstOrNull(),
|
||||
MarkdownParseMode,
|
||||
toHtmlCaptions().firstOrNull(),
|
||||
HTMLParseMode,
|
||||
media.duration,
|
||||
disableNotification,
|
||||
replyToMessageId,
|
||||
|
Loading…
Reference in New Issue
Block a user