1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2024-11-22 16:23:48 +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`: * `TelegramBotAPI`:
* Now `EditMediaGroupUpdate` also extends `BaseEditMessageUpdate` * Now `EditMediaGroupUpdate` also extends `BaseEditMessageUpdate`
* **EXPERIMENTALLY** Now all `TextSource` realisations will contain `source` field as a property inside of them
* `TelegramBotAPI-extensions-api`: * `TelegramBotAPI-extensions-api`:
* `startGettingFlowsUpdates` extension which do not require filter (but return a new one) was added * `startGettingFlowsUpdates` extension which do not require filter (but return a new one) was added
* `TelegramBotAPI-extensions-utils`: * `TelegramBotAPI-extensions-utils`:

View File

@ -4,6 +4,7 @@ interface TextSource {
val asMarkdownSource: String val asMarkdownSource: String
val asMarkdownV2Source: String val asMarkdownV2Source: String
val asHtmlSource: 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class BoldTextSource( class BoldTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } 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]*") private val commandRegex = Regex("[/!][^@\\s]*")
class BotCommandTextSource( class BotCommandTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
val command: String by lazy { val command: String by lazy {

View File

@ -5,7 +5,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextPart
import com.github.insanusmokrassar.TelegramBotAPI.utils.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class CashTagTextSource( class CashTagTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class CodeTextSource( class CodeTextSource(
source: String override val source: String
) : TextSource { ) : TextSource {
override val asMarkdownSource: String by lazy { source.codeMarkdown() } override val asMarkdownSource: String by lazy { source.codeMarkdown() }
override val asMarkdownV2Source: String by lazy { source.codeMarkdownV2() } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class EMailTextSource( class EMailTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -12,7 +12,7 @@ private val String.withoutSharp
} }
class HashTagTextSource( class HashTagTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class ItalicTextSource( class ItalicTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }

View File

@ -12,7 +12,7 @@ private val String.withoutCommercialAt
} }
class MentionTextSource( class MentionTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class PhoneNumberTextSource( class PhoneNumberTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class PreTextSource( class PreTextSource(
source: String, override val source: String,
val language: String? = null val language: String? = null
) : TextSource { ) : TextSource {
override val asMarkdownSource: String by lazy { source.preMarkdown(language) } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class RegularTextSource( class RegularTextSource(
source: String override val source: String
) : TextSource { ) : TextSource {
override val asMarkdownSource: String by lazy { source.regularMarkdown() } override val asMarkdownSource: String by lazy { source.regularMarkdown() }
override val asMarkdownV2Source: String by lazy { source.regularMarkdownV2() } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class StrikethroughTextSource( class StrikethroughTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class TextLinkTextSource( class TextLinkTextSource(
source: String, override val source: String,
url: String url: String
) : TextSource { ) : TextSource {
override val asMarkdownSource: String by lazy { source.linkMarkdown(url) } 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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class TextMentionTextSource( class TextMentionTextSource(
source: String, override val source: String,
privateChat: PrivateChat, privateChat: PrivateChat,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {

View File

@ -4,7 +4,7 @@ import com.github.insanusmokrassar.TelegramBotAPI.CommonAbstracts.TextSource
import com.github.insanusmokrassar.TelegramBotAPI.utils.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class URLTextSource( class URLTextSource(
source: String override val source: String
) : TextSource { ) : TextSource {
override val asMarkdownSource: String by lazy { source.linkMarkdown(source) } override val asMarkdownSource: String by lazy { source.linkMarkdown(source) }
override val asMarkdownV2Source: String by lazy { source.linkMarkdownV2(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.* import com.github.insanusmokrassar.TelegramBotAPI.utils.*
class UnderlineTextSource( class UnderlineTextSource(
source: String, override val source: String,
textParts: List<TextPart> textParts: List<TextPart>
) : MultilevelTextSource { ) : MultilevelTextSource {
override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) } override val textParts: List<TextPart> by lazy { source.fullListOfSubSource(textParts) }