Skip to content

Commit

Permalink
Merge pull request #909 from InsanusMokrassar/18.2.2
Browse files Browse the repository at this point in the history
18.2.2
  • Loading branch information
InsanusMokrassar authored Oct 21, 2024
2 parents 9fe8df9 + abb8b34 commit 482c375
Show file tree
Hide file tree
Showing 19 changed files with 555 additions and 91 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# TelegramBotAPI changelog

## 18.2.2

* `Version`:
* `Kotlin`: `2.0.20` -> `2.0.21`
* `MicroUtils`: `0.22.4` -> `0.22.7`
* `Core`:
* Fixes in blockquotes serializations
* Now `RawMessageEntity` is public. It is still under `Warning` annotation and is subject of changes
* `BehaviourBuilder`:
* Add `CommonMessageFilterExcludeCommand` to filter commands in messages
* Add `minus` operation for `SimpleFilter`s

## 18.2.1

* `Version`:
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ kotlin.incremental=true
kotlin.incremental.js=true

library_group=dev.inmo
library_version=18.2.1
library_version=18.2.2
6 changes: 3 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]

kotlin = "2.0.20"
kotlin = "2.0.21"
kotlin-serialization = "1.7.3"
kotlin-coroutines = "1.9.0"

Expand All @@ -10,10 +10,10 @@ korlibs = "5.4.0"
uuid = "0.8.4"
ktor = "2.3.12"

ksp = "2.0.20-1.0.25"
ksp = "2.0.21-1.0.25"
kotlin-poet = "1.18.1"

microutils = "0.22.4"
microutils = "0.22.7"
kslog = "1.3.6"

versions = "0.51.0"
Expand Down
11 changes: 11 additions & 0 deletions tgbotapi.behaviour_builder/api/tgbotapi.behaviour_builder.api
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,15 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/filters/ChatMe
public static final fun getChatMemberUnsubscribedFilter ()Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
}

public final class dev/inmo/tgbotapi/extensions/behaviour_builder/filters/CommonMessageFilterExcludeCommandKt {
public static final fun CommonMessageFilterExcludeCommand (Ljava/lang/String;Z)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static synthetic fun CommonMessageFilterExcludeCommand$default (Ljava/lang/String;ZILjava/lang/Object;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
}

public final class dev/inmo/tgbotapi/extensions/behaviour_builder/filters/CommonMessageFilterIncludeTextKt {
public static final fun CommonMessageFilterIncludeText (Lkotlin/text/Regex;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
}

public final class dev/inmo/tgbotapi/extensions/behaviour_builder/filters/MessageFilterByChatKt {
public static final fun getCallbackQueryFilterByUser ()Lkotlin/jvm/functions/Function4;
public static final fun getChatJoinRequestFilterByChat ()Lkotlin/jvm/functions/Function4;
Expand Down Expand Up @@ -1488,9 +1497,11 @@ public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFi
public static final fun listAll (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun listAny (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun listNone (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun minus (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun not (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun plus (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun times (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
public static final fun unaryMinus (Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;)Ldev/inmo/tgbotapi/extensions/behaviour_builder/utils/SimpleFilter;
}

public final class dev/inmo/tgbotapi/extensions/behaviour_builder/utils/SubcontextUpdatesFilterOperationsKt {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters

import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.CommonMessageFilter
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.not
import dev.inmo.tgbotapi.extensions.utils.textedContentOrNull
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource

/**
* Use as initialFilter. Will exclude messages with [excludedCommand] if it is not null, if null - all messages with commands.
* If [textBeginOnly] set to false, all commands inside of message will be taken in attention.
*
* **It is supposed, that you will pass command name without `/` or `!`**
*
* @param excludedCommand Pass non-null value to search specific command or null (default) to search any command
* @param textBeginOnly Pass true (default) to check only start of message. Pass false to search in whole text of
* content
*/
fun CommonMessageFilterExcludeCommand(
excludedCommand: String? = null,
textBeginOnly: Boolean = true
): CommonMessageFilter<*> {
return !CommonMessageFilterIncludeText(
when {
excludedCommand == null -> BotCommandTextSource.CommandRegex
textBeginOnly -> Regex("^[/!]$excludedCommand(\\s|$)")
!textBeginOnly -> Regex("[/!]$excludedCommand(\\s|$)")
else -> error("Unreachable code has been reached. It is error and must not happen")
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters

import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.CommonMessageFilter
import dev.inmo.tgbotapi.extensions.utils.textedContentOrNull

/**
* Includes messages only contains text with [textRegex]
*/
fun CommonMessageFilterIncludeText(
textRegex: Regex,
): CommonMessageFilter<*> {
return CommonMessageFilter {
it.content.textedContentOrNull() ?.text ?.contains(textRegex) == true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,14 @@ infix operator fun <T> SimpleFilter<T>?.plus(other: SimpleFilter<T>?): SimpleFil
operator fun <T> SimpleFilter<T>.not() = SimpleFilter<T> {
!this(it)
}

/**
* Works as [not]
*/
operator fun <T> SimpleFilter<T>.unaryMinus() = not()

/**
* Making +! operation. In fact that means that [other] will be inversed with [not] and that added to [this] via
* [plus]
*/
operator fun <T> SimpleFilter<T>?.minus(other: SimpleFilter<T>?): SimpleFilter<T> = this + (other ?.not())
Loading

0 comments on commit 482c375

Please sign in to comment.