mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 16:23:48 +00:00
bot command entity command extracting fix
This commit is contained in:
parent
647d1e79f7
commit
7f7e82bbb0
@ -24,6 +24,8 @@ Other important changes:
|
|||||||
|
|
||||||
* Totally reworked chats hierarchy. `Extended` abstractions was added for cases when called `GetChat` request
|
* Totally reworked chats hierarchy. `Extended` abstractions was added for cases when called `GetChat` request
|
||||||
* `RawChat` boilerplate was removed and replaced by serializers
|
* `RawChat` boilerplate was removed and replaced by serializers
|
||||||
|
* `BotCommandMessageEntity#command` will not contain `/`/`!` parts and also will cut outside of command begin token (`/`
|
||||||
|
or `!`) and username token (`@`) or end of command (any space character)
|
||||||
* `RequestsExecutor` now is `Closeable`
|
* `RequestsExecutor` now is `Closeable`
|
||||||
* `TelegramAPIUrlsKeeper` was added to provide more comfortable work with file urls and other things
|
* `TelegramAPIUrlsKeeper` was added to provide more comfortable work with file urls and other things
|
||||||
like this
|
like this
|
||||||
|
@ -3,6 +3,8 @@ package com.github.insanusmokrassar.TelegramBotAPI.types.MessageEntity
|
|||||||
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,
|
||||||
@ -12,6 +14,6 @@ data class BotCommandMessageEntity(
|
|||||||
override val asHtmlSource: String = sourceString.commandHTML()
|
override val asHtmlSource: String = sourceString.commandHTML()
|
||||||
|
|
||||||
val command: String by lazy {
|
val command: String by lazy {
|
||||||
sourceString.substring(1)// skip first symbol like "/" or "!"
|
commandRegex.find(sourceString) ?.value ?.substring(1) ?: sourceString.substring(1)// skip first symbol like "/" or "!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user