mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +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 `CommonLimiter`
|
||||||
* Add `MessageEntity#asHtmlSource` and `String#toHtml`
|
* Add `MessageEntity#asHtmlSource` and `String#toHtml`
|
||||||
* Add tools for work with html captions and texts
|
* 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
|
## 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.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MessageContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlTexts
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownTexts
|
||||||
|
|
||||||
data class TextContent(
|
data class TextContent(
|
||||||
@ -22,8 +23,8 @@ data class TextContent(
|
|||||||
replyMarkup: KeyboardMarkup?
|
replyMarkup: KeyboardMarkup?
|
||||||
): Request<RawMessage> = SendMessage(
|
): Request<RawMessage> = SendMessage(
|
||||||
chatId,
|
chatId,
|
||||||
toMarkdownTexts().first(),
|
toHtmlTexts().first(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
false,
|
false,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
@ -35,11 +36,28 @@ data class TextContent(
|
|||||||
disableNotification: Boolean,
|
disableNotification: Boolean,
|
||||||
replyToMessageId: MessageIdentifier?,
|
replyToMessageId: MessageIdentifier?,
|
||||||
replyMarkup: KeyboardMarkup?
|
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(
|
SendMessage(
|
||||||
chatId,
|
chatId,
|
||||||
it,
|
it,
|
||||||
MarkdownParseMode,
|
parseMode,
|
||||||
false,
|
false,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
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.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.ParseMode.MarkdownParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.AudioFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
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.CaptionedMediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||||
|
|
||||||
data class AudioContent(
|
data class AudioContent(
|
||||||
@ -27,8 +29,8 @@ data class AudioContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
media.duration,
|
media.duration,
|
||||||
media.performer,
|
media.performer,
|
||||||
media.title,
|
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.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.ParseMode.MarkdownParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.DocumentFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
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.CaptionedMediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||||
|
|
||||||
data class DocumentContent(
|
data class DocumentContent(
|
||||||
@ -27,8 +29,8 @@ data class DocumentContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
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.InputMedia.MediaGroupMemberInputMedia
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.ParseMode.MarkdownParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.PhotoSize
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.biggest
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||||
|
|
||||||
data class PhotoContent(
|
data class PhotoContent(
|
||||||
@ -30,8 +32,8 @@ data class PhotoContent(
|
|||||||
): Request<RawMessage> = SendPhoto(
|
): Request<RawMessage> = SendPhoto(
|
||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
replyMarkup
|
replyMarkup
|
||||||
@ -39,7 +41,7 @@ data class PhotoContent(
|
|||||||
|
|
||||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto(
|
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaPhoto(
|
||||||
media.fileId,
|
media.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode
|
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.InputMedia.MediaGroupMemberInputMedia
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.ParseMode.MarkdownParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VideoFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.*
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||||
|
|
||||||
data class VideoContent(
|
data class VideoContent(
|
||||||
@ -28,8 +30,8 @@ data class VideoContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
media.thumb ?.fileId,
|
media.thumb ?.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
media.duration,
|
media.duration,
|
||||||
media.width,
|
media.width,
|
||||||
media.height,
|
media.height,
|
||||||
@ -41,8 +43,8 @@ data class VideoContent(
|
|||||||
|
|
||||||
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo(
|
override fun toMediaGroupMemberInputMedia(): MediaGroupMemberInputMedia = InputMediaVideo(
|
||||||
media.fileId,
|
media.fileId,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
media.width,
|
media.width,
|
||||||
media.height,
|
media.height,
|
||||||
media.duration,
|
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.ChatIdentifier
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageIdentifier
|
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.ParseMode.MarkdownParseMode
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
import com.github.insanusmokrassar.TelegramBotAPI.types.buttons.KeyboardMarkup
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
|
import com.github.insanusmokrassar.TelegramBotAPI.types.files.VoiceFile
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.RawMessage
|
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.CaptionedMediaContent
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.MediaContent
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toHtmlCaptions
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.toMarkdownCaptions
|
||||||
|
|
||||||
data class VoiceContent(
|
data class VoiceContent(
|
||||||
@ -27,8 +29,8 @@ data class VoiceContent(
|
|||||||
chatId,
|
chatId,
|
||||||
media.fileId,
|
media.fileId,
|
||||||
null,
|
null,
|
||||||
toMarkdownCaptions().firstOrNull(),
|
toHtmlCaptions().firstOrNull(),
|
||||||
MarkdownParseMode,
|
HTMLParseMode,
|
||||||
media.duration,
|
media.duration,
|
||||||
disableNotification,
|
disableNotification,
|
||||||
replyToMessageId,
|
replyToMessageId,
|
||||||
|
Loading…
Reference in New Issue
Block a user