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

experimentally make source string available inside of text sources

This commit is contained in:
InsanusMokrassar 2020-04-08 15:17:13 +06:00
parent cf9f270651
commit 7183634fd6
18 changed files with 18 additions and 16 deletions

View File

@ -42,6 +42,7 @@
* `TelegramBotAPI`:
* Now `EditMediaGroupUpdate` also extends `BaseEditMessageUpdate`
* **EXPERIMENTALLY** Now all `TextSource` realisations will contain `source` field as a property inside of them
* `TelegramBotAPI-extensions-api`:
* `startGettingFlowsUpdates` extension which do not require filter (but return a new one) was added
* `TelegramBotAPI-extensions-utils`:

View File

@ -4,6 +4,7 @@ interface TextSource {
val asMarkdownSource: String
val asMarkdownV2Source: String
val asHtmlSource: String
val source: String
}

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class BoldTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -7,7 +7,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.utils.*
private val commandRegex = Regex("[/!][^@\\s]*")
class BotCommandTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
val command: String by lazy {

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class CashTagTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class CodeTextSource(
source: String
override val source: String
) : TextSource {
override val asMarkdownSource: String by lazy { source.codeMarkdown() }
override val asMarkdownV2Source: String by lazy { source.codeMarkdownV2() }

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class EMailTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -12,7 +12,7 @@ private val String.withoutSharp
}
class HashTagTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy {

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class ItalicTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -12,7 +12,7 @@ private val String.withoutCommercialAt
}
class MentionTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy {

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class PhoneNumberTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class PreTextSource(
source: String,
override val source: String,
val language: String? = null
) : TextSource {
override val asMarkdownSource: String by lazy { source.preMarkdown(language) }

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class RegularTextSource(
source: String
override val source: String
) : TextSource {
override val asMarkdownSource: String by lazy { source.regularMarkdown() }
override val asMarkdownV2Source: String by lazy { source.regularMarkdownV2() }

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class StrikethroughTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class TextLinkTextSource(
source: String,
override val source: String,
url: String
) : TextSource {
override val asMarkdownSource: String by lazy { source.linkMarkdown(url) }

View File

@ -6,7 +6,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.types.chat.abstracts.PrivateCh
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class TextMentionTextSource(
source: String,
override val source: String,
privateChat: PrivateChat,
textParts: List<TextPart>
) : MultilevelTextSource {

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class URLTextSource(
source: String
override val source: String
) : TextSource {
override val asMarkdownSource: String by lazy { source.linkMarkdown(source) }
override val asMarkdownV2Source: String by lazy { source.linkMarkdownV2(source) }

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class UnderlineTextSource(
source: String,
override val source: String,
textParts: List<TextPart>
) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }