mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 00:03:48 +00:00
0.8.5
This commit is contained in:
parent
c6e7111ff5
commit
a0a93646e4
14
CHANGELOG
14
CHANGELOG
@ -1,22 +1,22 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 0.8.1
|
||||
### 0.8.1
|
||||
|
||||
* Update `MediaGroupMessage` interface
|
||||
* Add implementation of `MediaGroupMessage`
|
||||
* Add generating of `MediaGroupMessage` in `RawMessage`
|
||||
|
||||
## 0.8.2
|
||||
### 0.8.2
|
||||
|
||||
* Add `FromUserMessage` which must be implemented in all messages realisations which have `user` field
|
||||
* Add `CommonMediaGroupMessage` which in fact extension of `MediaGroupMessage` with implementation of `FromUserMessage`
|
||||
* `CommonMessageImpl` now implementing `FromUserMessage`
|
||||
|
||||
## 0.8.3
|
||||
### 0.8.3
|
||||
|
||||
* Now `ForwardedMessage` contains nullable `from`
|
||||
|
||||
## 0.8.4
|
||||
### 0.8.4
|
||||
|
||||
* Added `createMarkdownText` and extensions for `CaptionedMediaContent` and `TextContent`
|
||||
* Added `ResendableContent` and realize in different contents
|
||||
@ -36,3 +36,9 @@
|
||||
* Now `Update` is untyped and data is `Any`
|
||||
* Media groups now are separated type of updates and you can subscribe on that receiving directly
|
||||
* Now `AdministratorChatMember` is interface and `CreatorChatMember` implement it
|
||||
|
||||
### 0.8.5
|
||||
|
||||
* Add extension `String#toMarkdown`
|
||||
* Fix of inserting of text when create Markdown-adapted text from text and text entities
|
||||
* Fix default realisation of MessageEntity#asMarkdownSource
|
||||
|
@ -1,4 +1,4 @@
|
||||
project.version = "0.8.4"
|
||||
project.version = "0.8.5"
|
||||
project.group = "com.github.insanusmokrassar"
|
||||
|
||||
buildscript {
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
|
||||
|
||||
interface MessageEntity {
|
||||
val offset: Int
|
||||
val length: Int
|
||||
val sourceString: String
|
||||
|
||||
val asMarkdownSource: String
|
||||
get() = sourceString
|
||||
get() = sourceString.toMarkdown()
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.github.insanusmokrassar.TelegramBotAPI.utils
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.MessageEntity
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.TextContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.types.message.content.abstracts.CaptionedMediaContent
|
||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
|
||||
|
||||
fun createMarkdownText(
|
||||
text: String,
|
||||
@ -12,7 +13,7 @@ fun createMarkdownText(
|
||||
var offset = 0
|
||||
for (entity in messageEntities) {
|
||||
builder.append(
|
||||
text.substring(offset until entity.offset)
|
||||
text.substring(offset until entity.offset).toMarkdown()
|
||||
)
|
||||
builder.append(
|
||||
entity.asMarkdownSource
|
||||
@ -20,7 +21,7 @@ fun createMarkdownText(
|
||||
offset += entity.length
|
||||
}
|
||||
builder.append(
|
||||
text.substring(offset)
|
||||
text.substring(offset).toMarkdown()
|
||||
)
|
||||
return builder.toString()
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.github.insanusmokrassar.TelegramBotAPI.utils.extensions
|
||||
|
||||
fun String.toMarkdown(): String {
|
||||
return replace(
|
||||
"*",
|
||||
"\\*"
|
||||
).replace(
|
||||
"_",
|
||||
"\\_"
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue
Block a user