1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 08:13:47 +00:00

MentionTextSource#username

This commit is contained in:
InsanusMokrassar 2022-02-19 23:02:58 +06:00
parent 10c52c695c
commit 4f0de376ab
2 changed files with 8 additions and 0 deletions

View File

@ -2,6 +2,9 @@
## 0.38.6 ## 0.38.6
* `Core`:
* New member of `MentionTextSource` - `username`
## 0.38.5 ## 0.38.5
* `Common`: * `Common`:

View File

@ -1,5 +1,6 @@
package dev.inmo.tgbotapi.types.MessageEntity.textsources package dev.inmo.tgbotapi.types.MessageEntity.textsources
import dev.inmo.tgbotapi.types.Username
import dev.inmo.tgbotapi.utils.RiskFeature import dev.inmo.tgbotapi.utils.RiskFeature
import dev.inmo.tgbotapi.utils.extensions.makeString import dev.inmo.tgbotapi.utils.extensions.makeString
import dev.inmo.tgbotapi.utils.internal.* import dev.inmo.tgbotapi.utils.internal.*
@ -23,6 +24,7 @@ data class MentionTextSource @RiskFeature(DirectInvocationOfTextSourceConstructo
override val markdown: String by lazy { source.mentionMarkdown() } override val markdown: String by lazy { source.mentionMarkdown() }
override val markdownV2: String by lazy { mentionMarkdownV2() } override val markdownV2: String by lazy { mentionMarkdownV2() }
override val html: String by lazy { mentionHTML() } override val html: String by lazy { mentionHTML() }
val username: Username = Username(source)
init { init {
if (!source.startsWith("@")) { if (!source.startsWith("@")) {
@ -42,3 +44,6 @@ inline fun mention(vararg parts: TextSource) = mention(parts.toList())
@Suppress("NOTHING_TO_INLINE") @Suppress("NOTHING_TO_INLINE")
inline fun mention(whoToMention: String) = mention(regular(whoToMention)) inline fun mention(whoToMention: String) = mention(regular(whoToMention))
@Suppress("NOTHING_TO_INLINE")
inline fun mention(whoToMention: Username) = mention(whoToMention.username.dropWhile { it == '@' })