1
0
mirror of https://github.com/InsanusMokrassar/TelegramBotAPI.git synced 2025-11-25 00:36:15 +00:00

Compare commits

...

15 Commits

Author SHA1 Message Date
8b15296ee7 Update CHANGELOG.md 2022-11-01 12:41:35 +06:00
0fcc717269 Update libs.versions.toml 2022-11-01 12:41:24 +06:00
2ce26b4f1e Update CHANGELOG.md 2022-10-31 02:28:23 +06:00
b5d499b623 Update libs.versions.toml 2022-10-31 02:27:23 +06:00
102515dc8a Update CHANGELOG.md 2022-10-31 02:25:16 +06:00
777a58ce9a a little bit refactor hasCommands 2022-10-30 20:10:12 +06:00
7471da4ff0 update version of library 2022-10-30 19:48:04 +06:00
e753db0e71 Merge pull request #662 from InsanusMokrassar/renovate/korlibs
Update korlibs to v3.3.0
2022-10-28 18:54:53 +06:00
70984424e3 Merge pull request #669 from madhead/feature/initial-filters
Add `hasCommands` / `hasNoCommands` extensions on `CommonMessage`
2022-10-28 18:54:16 +06:00
c8354a330e Merge pull request #670 from InsanusMokrassar/renovate/ktor
Update ktor to v2.1.3
2022-10-28 18:53:38 +06:00
037ad8b87c Update gradle.properties 2022-10-28 18:51:52 +06:00
renovate[bot]
89550107d6 Update ktor to v2.1.3 2022-10-28 11:44:50 +00:00
madhead
86cc7cfb3d Add hasCommands / hasNoCommands extensions on CommonMessage
These extensions are meant to be used as arguments to the `initialFilter` parameter in behaviour builder triggers.
2022-10-24 03:46:30 +02:00
renovate[bot]
858586e608 Update korlibs to v3.3.0 2022-10-23 00:42:04 +00:00
d9846f27c9 Merge pull request #665 from InsanusMokrassar/3.3.0
3.3.0
2022-10-22 18:00:02 +06:00
6 changed files with 59 additions and 5 deletions

View File

@@ -1,5 +1,14 @@
# 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
**THIS VERSION CONTAINS UPGRADE KOTLIN (AND ALL RELATED LIBRARIES) UP TO 1.7.20**

View File

@@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true
library_group=dev.inmo
library_version=3.3.0
library_version=3.3.1

View File

@@ -6,14 +6,14 @@ kotlin-coroutines = "1.6.4"
javax-activation = "1.1.1"
korlibs = "3.2.0"
korlibs = "3.3.1"
uuid = "0.5.0"
ktor = "2.1.2"
ktor = "2.1.3"
ksp = "1.7.20-1.0.7"
kotlin-poet = "1.12.0"
microutils = "0.13.1"
microutils = "0.13.2"
github-release-plugin = "2.4.1"

View File

@@ -17,7 +17,7 @@ class MultipartRequestCallFactory : AbstractRequestCallFactory() {
): Any? = (request as? MultipartRequest) ?.let { castedRequest ->
MultiPartFormDataContent(
formData {
val params = castedRequest.paramsJson.mapWithCommonValues()
val params = castedRequest.paramsJson.mapWithCommonValues() - castedRequest.mediaMap.keys
for ((key, value) in castedRequest.mediaMap + params) {
when (value) {
is MultipartFile -> appendInput(

View File

@@ -13,6 +13,7 @@ import kotlinx.serialization.json.JsonObject
data class SetChatPhoto (
@SerialName(chatIdField)
override val chatId: ChatIdentifier,
@Transient
val photo: MultipartFile = throw IllegalArgumentException("Unfortunately, this type of objects can't be parsed automatically")
): ChatRequest, MultipartRequest<Boolean> {
override fun method(): String = "setChatPhoto"

View File

@@ -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()