mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-26 03:58:44 +00:00
TextSource analogues of MessageEntities
This commit is contained in:
parent
6f1f5e640a
commit
6dd701d33c
@ -19,6 +19,8 @@
|
|||||||
* `createFormattedText` method now accept `List<TextSource>`
|
* `createFormattedText` method now accept `List<TextSource>`
|
||||||
* `createHtmlText` method now accept `List<TextSource>`
|
* `createHtmlText` method now accept `List<TextSource>`
|
||||||
* `createMarkdownText` method now accept `List<TextSource>`
|
* `createMarkdownText` method now accept `List<TextSource>`
|
||||||
|
* A lot of `TextSource` implementors was added. More info [here](src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/)
|
||||||
|
* All `MessageEntity` implementations now are using new `TextSource` analogues as delegates
|
||||||
|
|
||||||
## 0.19.0 ImplicitReflection removing
|
## 0.19.0 ImplicitReflection removing
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.BoldTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class BoldTextMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by BoldTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.boldMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.boldHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.BotCommandTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandMarkdown
|
||||||
|
|
||||||
private val commandRegex = Regex("[/!][^@\\s]*")
|
|
||||||
|
|
||||||
data class BotCommandMessageEntity(
|
data class BotCommandMessageEntity(
|
||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String,
|
||||||
) : MessageEntity {
|
private val botCommandTextSource: BotCommandTextSource = BotCommandTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.commandMarkdown()
|
) : MessageEntity, TextSource by botCommandTextSource {
|
||||||
override val asHtmlSource: String = sourceString.commandHTML()
|
val command: String
|
||||||
|
get() = botCommandTextSource.command
|
||||||
val command: String by lazy {
|
|
||||||
commandRegex.find(sourceString) ?.value ?.substring(1) ?: sourceString.substring(1)// skip first symbol like "/" or "!"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.CodeTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class CodeTextMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by CodeTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.codeMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.codeHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.EMailTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailMarkdown
|
||||||
|
|
||||||
class EMailMessageEntity(
|
data class EMailMessageEntity(
|
||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by EMailTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.emailMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.emailHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.HashTagTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class HashTagMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by HashTagTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.hashTagMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.hashTagHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.ItalicTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class ItalicTextMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by ItalicTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.italicMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.italicHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.MentionTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ class MentionMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by MentionTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.mentionMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.mentionHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.PhoneNumberTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class PhoneNumberMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by PhoneNumberTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.phoneMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.phoneHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.PreTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.preHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.preHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.preMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.preMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class PreTextMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by PreTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.preMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.preHTML()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.RegularTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toHtml
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toHtml
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
|
||||||
|
|
||||||
@ -7,7 +9,4 @@ data class RegularTextMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by RegularTextSource(sourceString)
|
||||||
override val asMarkdownSource: String = sourceString.toMarkdown()
|
|
||||||
override val asHtmlSource: String = sourceString.toHtml()
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.TextLinkTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
||||||
|
|
||||||
@ -8,7 +10,4 @@ data class TextLinkMessageEntity(
|
|||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String,
|
override val sourceString: String,
|
||||||
val url: String
|
val url: String
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by TextLinkTextSource(sourceString, url)
|
||||||
override val asMarkdownSource: String = sourceString.linkMarkdown(url)
|
|
||||||
override val asHtmlSource: String = sourceString.linkHTML(url)
|
|
||||||
}
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.TextMentionTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
||||||
@ -10,7 +12,7 @@ class TextMentionMessageEntity(
|
|||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String,
|
override val sourceString: String,
|
||||||
val privateChat: PrivateChat
|
val privateChat: PrivateChat
|
||||||
) : MessageEntity {
|
) : MessageEntity, TextSource by TextMentionTextSource(sourceString, privateChat) {
|
||||||
@Deprecated("Deprecated due to the fact that there is more common constructor")
|
@Deprecated("Deprecated due to the fact that there is more common constructor")
|
||||||
constructor(
|
constructor(
|
||||||
offset: Int,
|
offset: Int,
|
||||||
@ -18,7 +20,4 @@ class TextMentionMessageEntity(
|
|||||||
sourceString: String,
|
sourceString: String,
|
||||||
user: User
|
user: User
|
||||||
) : this(offset, length, sourceString, user as PrivateChat)
|
) : this(offset, length, sourceString, user as PrivateChat)
|
||||||
|
|
||||||
override val asMarkdownSource: String = sourceString.mentionMarkdown(privateChat.id)
|
|
||||||
override val asHtmlSource: String = sourceString.mentionHTML(privateChat.id)
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources.URLTextSource
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
||||||
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
||||||
|
|
||||||
@ -7,9 +9,6 @@ data class URLMessageEntity(
|
|||||||
override val offset: Int,
|
override val offset: Int,
|
||||||
override val length: Int,
|
override val length: Int,
|
||||||
override val sourceString: String
|
override val sourceString: String
|
||||||
) : MessageEntity{
|
) : MessageEntity, TextSource by URLTextSource(sourceString) {
|
||||||
val url: String = sourceString
|
val url: String = sourceString
|
||||||
|
|
||||||
override val asMarkdownSource: String = sourceString.linkMarkdown(url)
|
|
||||||
override val asHtmlSource: String = sourceString.linkHTML(url)
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.boldMarkdown
|
||||||
|
|
||||||
|
class BoldTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.boldMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.boldHTML()
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.commandMarkdown
|
||||||
|
|
||||||
|
private val commandRegex = Regex("[/!][^@\\s]*")
|
||||||
|
|
||||||
|
class BotCommandTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.commandMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.commandHTML()
|
||||||
|
|
||||||
|
val command: String by lazy {
|
||||||
|
commandRegex.find(sourceString) ?.value ?.substring(1) ?: sourceString.substring(1)// skip first symbol like "/" or "!"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.codeMarkdown
|
||||||
|
|
||||||
|
class CodeTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.codeMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.codeHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.emailMarkdown
|
||||||
|
|
||||||
|
class EMailTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.emailMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.emailHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.hashTagMarkdown
|
||||||
|
|
||||||
|
class HashTagTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.hashTagMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.hashTagHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.italicMarkdown
|
||||||
|
|
||||||
|
class ItalicTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.italicMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.italicHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionMarkdown
|
||||||
|
|
||||||
|
class MentionTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.mentionMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.mentionHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.phoneMarkdown
|
||||||
|
|
||||||
|
class PhoneNumberTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.phoneMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.phoneHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.preHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.preMarkdown
|
||||||
|
|
||||||
|
class PreTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.preMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.preHTML()
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toHtml
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.extensions.toMarkdown
|
||||||
|
|
||||||
|
class RegularTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.toMarkdown()
|
||||||
|
override val asHtmlSource: String = sourceString.toHtml()
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
||||||
|
|
||||||
|
class TextLinkTextSource(
|
||||||
|
sourceString: String,
|
||||||
|
url: String
|
||||||
|
) : TextSource {
|
||||||
|
override val asMarkdownSource: String = sourceString.linkMarkdown(url)
|
||||||
|
override val asHtmlSource: String = sourceString.linkHTML(url)
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.User
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateChat
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.mentionMarkdown
|
||||||
|
|
||||||
|
class TextMentionTextSource(
|
||||||
|
sourceString: String,
|
||||||
|
privateChat: PrivateChat
|
||||||
|
) : TextSource {
|
||||||
|
@Deprecated("Deprecated due to the fact that there is more common constructor")
|
||||||
|
constructor(
|
||||||
|
sourceString: String,
|
||||||
|
user: User
|
||||||
|
) : this(sourceString, user as PrivateChat)
|
||||||
|
|
||||||
|
override val asMarkdownSource: String = sourceString.mentionMarkdown(privateChat.id)
|
||||||
|
override val asHtmlSource: String = sourceString.mentionHTML(privateChat.id)
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity.textsources
|
||||||
|
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkHTML
|
||||||
|
import com.github.insanusmokrassar.TelegramBotAPI.utils.linkMarkdown
|
||||||
|
|
||||||
|
class URLTextSource(
|
||||||
|
sourceString: String
|
||||||
|
) : TextSource{
|
||||||
|
override val asMarkdownSource: String = sourceString.linkMarkdown(sourceString)
|
||||||
|
override val asHtmlSource: String = sourceString.linkHTML(sourceString)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user