mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-04-18 07:52:39 +00:00
Compare commits
22 Commits
63ceec70ca
...
v3.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 8b15296ee7 | |||
| 0fcc717269 | |||
| 2ce26b4f1e | |||
| b5d499b623 | |||
| 102515dc8a | |||
| 777a58ce9a | |||
| 7471da4ff0 | |||
| e753db0e71 | |||
| 70984424e3 | |||
| c8354a330e | |||
| 037ad8b87c | |||
|
|
89550107d6 | ||
|
|
86cc7cfb3d | ||
|
|
858586e608 | ||
| d9846f27c9 | |||
| c10da2a10a | |||
| 8ed216619d | |||
| 62a9c687d5 | |||
| c2918c308f | |||
|
|
81fbff0bf5 | ||
| 54fb58de81 | |||
| 94ed4fed10 |
24
CHANGELOG.md
24
CHANGELOG.md
@@ -1,9 +1,31 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 3.3.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Ktor`: `2.1.2` -> `2.1.3`
|
||||||
|
* `Klock`: `3.2.0` -> `3.3.1`
|
||||||
|
* `MicroUtils`: `0.13.1` -> `0.13.2`
|
||||||
|
* `Utils`:
|
||||||
|
* New extensions on `CommonMessage`: `hasCommands` and `hasNoCommands`. Useful for the `initialFilter` parameter in behaviour builder triggers.
|
||||||
|
|
||||||
## 3.3.0
|
## 3.3.0
|
||||||
|
|
||||||
|
**THIS VERSION CONTAINS UPGRADE KOTLIN (AND ALL RELATED LIBRARIES) UP TO 1.7.20**
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
* `MicroUtils`: `0.12.17` -> `0.13.0`
|
* `Kotlin`: `1.7.10` -> `1.7.20`
|
||||||
|
* `Kotlin Serialization`: `1.4.0` -> `1.4.1`
|
||||||
|
* `Korlibs`: `3.1.0` -> `3.2.0`
|
||||||
|
* `MicroUtils`: `0.12.17` -> `0.13.1`
|
||||||
|
* `Core`:
|
||||||
|
* Add opportunity to create command text source and add command in entities builder
|
||||||
|
via `BotCommamd` (thanks to [d1shin](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/664))
|
||||||
|
* `API`:
|
||||||
|
* New extensions `TelegramBot#getStickerSetOrNull` and `TelegramBot#getStickerSetOrThrow`
|
||||||
|
* Old `TelegramBot#getStickerSet` has been deprecated
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Add opportunity to use triggers and waiters with `BotCommand` (thanks to [d1shin](https://github.com/InsanusMokrassar/TelegramBotAPI/pull/664))
|
||||||
|
|
||||||
## 3.2.7
|
## 3.2.7
|
||||||
|
|
||||||
|
|||||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
|||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=3.3.0
|
library_version=3.3.1
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kotlin = "1.7.10"
|
kotlin = "1.7.20"
|
||||||
kotlin-serialization = "1.4.0"
|
kotlin-serialization = "1.4.1"
|
||||||
kotlin-coroutines = "1.6.4"
|
kotlin-coroutines = "1.6.4"
|
||||||
|
|
||||||
javax-activation = "1.1.1"
|
javax-activation = "1.1.1"
|
||||||
|
|
||||||
korlibs = "3.1.0"
|
korlibs = "3.3.1"
|
||||||
uuid = "0.5.0"
|
uuid = "0.5.0"
|
||||||
ktor = "2.1.2"
|
ktor = "2.1.3"
|
||||||
|
|
||||||
ksp = "1.7.10-1.0.6"
|
ksp = "1.7.20-1.0.7"
|
||||||
kotlin-poet = "1.12.0"
|
kotlin-poet = "1.12.0"
|
||||||
|
|
||||||
microutils = "0.13.0"
|
microutils = "0.13.2"
|
||||||
|
|
||||||
github-release-plugin = "2.4.1"
|
github-release-plugin = "2.4.1"
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,21 @@ suspend fun TelegramBot.getStickerSet(
|
|||||||
GetStickerSet(name)
|
GetStickerSet(name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@Deprecated("Renamed", ReplaceWith("getStickerSetOrThrow(sticker)", "dev.inmo.tgbotapi.extensions.api.get.getStickerSetOrThrow"))
|
||||||
suspend fun TelegramBot.getStickerSet(
|
suspend fun TelegramBot.getStickerSet(
|
||||||
sticker: Sticker
|
sticker: Sticker
|
||||||
) = getStickerSet(
|
) = getStickerSet(
|
||||||
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getStickerSetOrNull(
|
||||||
|
sticker: Sticker
|
||||||
|
) = sticker.stickerSetName ?.let {
|
||||||
|
getStickerSet(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun TelegramBot.getStickerSetOrThrow(
|
||||||
|
sticker: Sticker
|
||||||
|
) = getStickerSet(
|
||||||
|
sticker.stickerSetName ?: error("Sticker must contains stickerSetName to be correctly used in getStickerSet method")
|
||||||
|
)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.doWithRegistration
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
|
import dev.inmo.tgbotapi.types.BotCommand
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.TextContent
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||||
@@ -39,6 +40,12 @@ suspend fun BehaviourContext.waitCommandMessage(
|
|||||||
errorFactory: NullableRequestBuilder<*> = { null }
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
) = waitCommandMessage(Regex(command), initRequest, errorFactory)
|
) = waitCommandMessage(Regex(command), initRequest, errorFactory)
|
||||||
|
|
||||||
|
suspend fun BehaviourContext.waitCommandMessage(
|
||||||
|
botCommand: BotCommand,
|
||||||
|
initRequest: Request<*>? = null,
|
||||||
|
errorFactory: NullableRequestBuilder<*> = { null }
|
||||||
|
) = waitCommandMessage(botCommand.command, initRequest, errorFactory)
|
||||||
|
|
||||||
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
|
fun Flow<CommonMessage<TextContent>>.requireCommandAtStart() = filter {
|
||||||
it.content.textSources.firstOrNull() is BotCommandTextSource
|
it.content.textSources.firstOrNull() is BotCommandTextSource
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
|
|||||||
): Any? = (request as? MultipartRequest) ?.let { castedRequest ->
|
): Any? = (request as? MultipartRequest) ?.let { castedRequest ->
|
||||||
MultiPartFormDataContent(
|
MultiPartFormDataContent(
|
||||||
formData {
|
formData {
|
||||||
val params = castedRequest.paramsJson.mapWithCommonValues()
|
val params = castedRequest.paramsJson.mapWithCommonValues() - castedRequest.mediaMap.keys
|
||||||
for ((key, value) in castedRequest.mediaMap + params) {
|
for ((key, value) in castedRequest.mediaMap + params) {
|
||||||
when (value) {
|
when (value) {
|
||||||
is MultipartFile -> appendInput(
|
is MultipartFile -> appendInput(
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import kotlinx.serialization.json.JsonObject
|
|||||||
data class SetChatPhoto (
|
data class SetChatPhoto (
|
||||||
@SerialName(chatIdField)
|
@SerialName(chatIdField)
|
||||||
override val chatId: ChatIdentifier,
|
override val chatId: ChatIdentifier,
|
||||||
|
@Transient
|
||||||
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
|
||||||
): ChatRequest, MultipartRequest<Boolean> {
|
): ChatRequest, MultipartRequest<Boolean> {
|
||||||
override fun method(): String = "setChatPhoto"
|
override fun method(): String = "setChatPhoto"
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.utils.updates
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.*
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A predicate to test whether a message contains any commands in its body.
|
||||||
|
* Use it as the `initialFilter` parameter in behaviour builder triggers.
|
||||||
|
* E.g.
|
||||||
|
*
|
||||||
|
* ```kotlin
|
||||||
|
* onContentMessage(
|
||||||
|
* initialFilter = CommonMessage<MessageContent>::hasCommands
|
||||||
|
* ) {
|
||||||
|
* // the message contains at least one command here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @return true if this [CommonMessage] contains any commands. False otherwise.
|
||||||
|
* @see hasNoCommands
|
||||||
|
*/
|
||||||
|
fun CommonMessage<*>.hasCommands(): Boolean = withContentOrNull<TextContent>() ?.content ?.textSources ?.any {
|
||||||
|
it is BotCommandTextSource
|
||||||
|
} ?: false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A predicate to test whether a message contains any commands in its body.
|
||||||
|
* Use it as the `initialFilter` parameter in behaviour builder triggers.
|
||||||
|
* E.g.
|
||||||
|
*
|
||||||
|
* ```kotlin
|
||||||
|
* onContentMessage(
|
||||||
|
* initialFilter = CommonMessage<MessageContent>::hasNoCommands
|
||||||
|
* ) {
|
||||||
|
* // the message contains no commands here
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @return true if this [CommonMessage] does not contain any commands. False otherwise.
|
||||||
|
* @see hasCommands
|
||||||
|
*/
|
||||||
|
fun CommonMessage<*>.hasNoCommands(): Boolean = !this.hasCommands()
|
||||||
Reference in New Issue
Block a user