From 7183634fd6374d214a8f4eab400d92d09db751a4 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 8 Apr 2020 15:17:13 +0600 Subject: [PATCH] experimentally make source string available inside of text sources --- CHANGELOG.md | 1 + .../TelegramBotAPI/CommonAbstracts/TextSource.kt | 1 + .../types/MessageEntity/textsources/BoldTextSource.kt | 2 +- .../types/MessageEntity/textsources/BotCommandTextSource.kt | 2 +- .../types/MessageEntity/textsources/CashTagTextSource.kt | 2 +- .../types/MessageEntity/textsources/CodeTextSource.kt | 2 +- .../types/MessageEntity/textsources/EMailTextSource.kt | 2 +- .../types/MessageEntity/textsources/HashTagTextSource.kt | 2 +- .../types/MessageEntity/textsources/ItalicTextSource.kt | 2 +- .../types/MessageEntity/textsources/MentionTextSource.kt | 2 +- .../types/MessageEntity/textsources/PhoneNumberTextSource.kt | 2 +- .../types/MessageEntity/textsources/PreTextSource.kt | 2 +- .../types/MessageEntity/textsources/RegularTextSource.kt | 2 +- .../types/MessageEntity/textsources/StrikethroughTextSource.kt | 2 +- .../types/MessageEntity/textsources/TextLinkTextSource.kt | 2 +- .../types/MessageEntity/textsources/TextMentionTextSource.kt | 2 +- .../types/MessageEntity/textsources/URLTextSource.kt | 2 +- .../types/MessageEntity/textsources/UnderlineTextSource.kt | 2 +- 18 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ed0b4ffd..7380bee314 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`: diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/TextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/TextSource.kt index be70f1032e..2a084edbe3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/TextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/CommonAbstracts/TextSource.kt @@ -4,6 +4,7 @@ interface TextSource { val asMarkdownSource: String val asMarkdownV2Source: String val asHtmlSource: String + val source: String } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BoldTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BoldTextSource.kt index a491b5953f..7d3f83497a 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BoldTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BoldTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BotCommandTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BotCommandTextSource.kt index a8dfaa4c52..b0fa9a1fa6 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BotCommandTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/BotCommandTextSource.kt @@ -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 ) : MultilevelTextSource { val command: String by lazy { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CashTagTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CashTagTextSource.kt index f0fb0d8a44..0186c60e9d 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CashTagTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CashTagTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CodeTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CodeTextSource.kt index 5b2359a458..66616d090d 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CodeTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/CodeTextSource.kt @@ -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() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/EMailTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/EMailTextSource.kt index f87d899953..c6704af3ed 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/EMailTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/EMailTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/HashTagTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/HashTagTextSource.kt index 1daabab4d7..ed3887ea59 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/HashTagTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/HashTagTextSource.kt @@ -12,7 +12,7 @@ private val String.withoutSharp } class HashTagTextSource( - source: String, + override val source: String, textParts: List ) : MultilevelTextSource { override val textParts: List by lazy { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/ItalicTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/ItalicTextSource.kt index 5043cd19d8..49ae39363f 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/ItalicTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/ItalicTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/MentionTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/MentionTextSource.kt index 398ae8c388..d8f29065fe 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/MentionTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/MentionTextSource.kt @@ -12,7 +12,7 @@ private val String.withoutCommercialAt } class MentionTextSource( - source: String, + override val source: String, textParts: List ) : MultilevelTextSource { override val textParts: List by lazy { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PhoneNumberTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PhoneNumberTextSource.kt index f83e41be12..f7f4735e6f 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PhoneNumberTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PhoneNumberTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PreTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PreTextSource.kt index d83896ba3f..53fbafca59 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PreTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/PreTextSource.kt @@ -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) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/RegularTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/RegularTextSource.kt index dca8f5aedc..a3fefb0de3 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/RegularTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/RegularTextSource.kt @@ -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() } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/StrikethroughTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/StrikethroughTextSource.kt index 17c79618bf..4fb9156f74 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/StrikethroughTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/StrikethroughTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextLinkTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextLinkTextSource.kt index 73d3ff8803..a4ba378bad 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextLinkTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextLinkTextSource.kt @@ -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) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextMentionTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextMentionTextSource.kt index b335806c6f..061b5f1fb8 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextMentionTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/TextMentionTextSource.kt @@ -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 ) : MultilevelTextSource { diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/URLTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/URLTextSource.kt index bd572b097b..dfa2cfeca0 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/URLTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/URLTextSource.kt @@ -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) } diff --git a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/UnderlineTextSource.kt b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/UnderlineTextSource.kt index 6cc142ec25..13f4c87395 100644 --- a/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/UnderlineTextSource.kt +++ b/TelegramBotAPI/src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/types/MessageEntity/textsources/UnderlineTextSource.kt @@ -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 ) : MultilevelTextSource { override val textParts: List by lazy { source.fullListOfSubSource(textParts) }