mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-11-16 20:10:18 +00:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2052072e5d | |||
| 6fb3d3fcb1 | |||
| 9c5793bec7 | |||
| fd9bff611b | |||
| bb66279044 | |||
| 24b48f2536 | |||
| 670c26c982 | |||
| 7ed5d9ceed | |||
| 787941fcaf | |||
| 6c9f1bc016 | |||
| e5bffa7c51 | |||
|
|
3fe26b057a | ||
| dccd15a5e9 | |||
| 3d14c93d89 | |||
| b8a6534b6a | |||
| f5529033ec | |||
| 482c375327 | |||
| abb8b3491d | |||
| 2953005e6d | |||
| 1f6ddd97e3 | |||
| bc8da1120e | |||
| e895c2f3a8 | |||
| f84180b3ff | |||
| c21c8c5a26 | |||
| 27416daeb8 | |||
| b5b7482c2f | |||
| a7f4ab36c6 | |||
| 7398e53b85 | |||
| be25f705ef | |||
| 5ee87ac78d | |||
| fbd53e1f2d | |||
| 9fe8df9e11 | |||
| a053c08346 | |||
| 6fa769bce3 | |||
| 27ac8ee797 | |||
| ce84e3c198 | |||
| c3a3e9bd44 | |||
| 7b6be48ba8 | |||
| e98d5c7a9c |
2
.github/workflows/packages_publishing.yml
vendored
2
.github/workflows/packages_publishing.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
rm gradle.properties
|
||||
mv gradle.properties.tmp gradle.properties
|
||||
- name: KotlinSymbolProcessing execution
|
||||
run: ./gradlew ksp
|
||||
run: ./gradlew kspCommonMainKotlinMetadata
|
||||
- name: Build
|
||||
run: ./gradlew build
|
||||
- name: API compatibility check
|
||||
|
||||
37
CHANGELOG.md
37
CHANGELOG.md
@@ -1,5 +1,42 @@
|
||||
# TelegramBotAPI changelog
|
||||
|
||||
## 19.0.0
|
||||
|
||||
**THIS UPDATE CONTAINS BREAKING CHANGES**
|
||||
|
||||
**THIS UPDATE CONTAINS UPGRADE UP TO KTOR 3.0 (thanks to [@d1snin](https://github.com/d1snin))**
|
||||
|
||||
* `Version`:
|
||||
* `Ktor`: `2.3.12` -> `3.0.1`
|
||||
* `MicroUtils`: `0.22.7` -> `0.23.0`
|
||||
|
||||
## 18.2.3
|
||||
|
||||
* `Core`:
|
||||
* Add default middleware `ExceptionsThrottlerTelegramBotMiddleware`
|
||||
* Make `TelegramBotMiddlewaresPipelinesHandler` to be default `TelegramBotPipelinesHandler`
|
||||
* Make `DefaultKtorRequestsExecutor` now uses `runCatching` instead of `runCatchingSafely`
|
||||
* `onRequestResultPresented` lambda now accepts non-nullable `result`
|
||||
|
||||
## 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`:
|
||||
* `Serialization`: `1.7.2` -> `1.7.3`
|
||||
* `Coroutines`: `1.8.1` -> `1.9.0`
|
||||
* `MicroUtils`: `0.22.2` -> `0.22.4`
|
||||
|
||||
## 18.2.0
|
||||
|
||||
**THIS UPDATE CONTAINS SUPPORT OF [BOTS API 7.10](https://core.telegram.org/bots/api-changelog#september-6-2024)**
|
||||
|
||||
@@ -6,4 +6,4 @@ kotlin.incremental=true
|
||||
kotlin.incremental.js=true
|
||||
|
||||
library_group=dev.inmo
|
||||
library_version=18.2.0
|
||||
library_version=19.0.0
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
[versions]
|
||||
|
||||
kotlin = "2.0.20"
|
||||
kotlin-serialization = "1.7.2"
|
||||
kotlin-coroutines = "1.8.1"
|
||||
kotlin = "2.0.21"
|
||||
kotlin-serialization = "1.7.3"
|
||||
kotlin-coroutines = "1.9.0"
|
||||
|
||||
javax-activation = "1.1.1"
|
||||
|
||||
korlibs = "5.4.0"
|
||||
uuid = "0.8.4"
|
||||
ktor = "2.3.12"
|
||||
ktor = "3.0.1"
|
||||
|
||||
ksp = "2.0.20-1.0.24"
|
||||
ksp = "2.0.21-1.0.26"
|
||||
kotlin-poet = "1.18.1"
|
||||
|
||||
microutils = "0.22.2"
|
||||
microutils = "0.23.0"
|
||||
kslog = "1.3.6"
|
||||
|
||||
versions = "0.51.0"
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
||||
|
||||
@@ -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;
|
||||
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
@@ -312,37 +312,6 @@ public abstract interface class dev/inmo/tgbotapi/bot/ktor/KtorCallFactory {
|
||||
public abstract fun makeCall (Lio/ktor/client/HttpClient;Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlinx/serialization/json/Json;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder$Companion;
|
||||
public abstract fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestReturnResult (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder$Companion : dev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder {
|
||||
public fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestReturnResult (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder$DefaultImpls {
|
||||
public static fun onAfterCallFactoryMakeCall (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestException (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestResultAbsent (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestResultPresented (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestReturnResult (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorBuilder {
|
||||
public fun <init> (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;)V
|
||||
public final fun build ()Ldev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor;
|
||||
@@ -351,15 +320,16 @@ public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorBuilder {
|
||||
public final fun getExcludeDefaultFactories ()Z
|
||||
public final fun getJsonFormatter ()Lkotlinx/serialization/json/Json;
|
||||
public final fun getLogger ()Ldev/inmo/kslog/common/KSLog;
|
||||
public final fun getPipelineStepsHolder ()Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;
|
||||
public final fun getPipelineStepsHolder ()Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;
|
||||
public final fun getRequestsLimiter ()Ldev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;
|
||||
public final fun getTelegramAPIUrlsKeeper ()Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;
|
||||
public final fun includeMiddlewares (Lkotlin/jvm/functions/Function1;)V
|
||||
public final fun setCallsFactories (Ljava/util/List;)V
|
||||
public final fun setClient (Lio/ktor/client/HttpClient;)V
|
||||
public final fun setExcludeDefaultFactories (Z)V
|
||||
public final fun setJsonFormatter (Lkotlinx/serialization/json/Json;)V
|
||||
public final fun setLogger (Ldev/inmo/kslog/common/KSLog;)V
|
||||
public final fun setPipelineStepsHolder (Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;)V
|
||||
public final fun setPipelineStepsHolder (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;)V
|
||||
public final fun setRequestsLimiter (Ldev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;)V
|
||||
public final fun setTelegramAPIUrlsKeeper (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;)V
|
||||
}
|
||||
@@ -374,8 +344,39 @@ public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorFactoriesKt {
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/KtorRequestsExecutorKt {
|
||||
public static final fun KtorRequestsExecutor (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lio/ktor/client/HttpClient;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/kslog/common/KSLog;)Ldev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor;
|
||||
public static synthetic fun KtorRequestsExecutor$default (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lio/ktor/client/HttpClient;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;Ldev/inmo/kslog/common/KSLog;ILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor;
|
||||
public static final fun KtorRequestsExecutor (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lio/ktor/client/HttpClient;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/kslog/common/KSLog;)Ldev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor;
|
||||
public static synthetic fun KtorRequestsExecutor$default (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Lio/ktor/client/HttpClient;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/kslog/common/KSLog;ILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/ktor/base/DefaultKtorRequestsExecutor;
|
||||
}
|
||||
|
||||
public abstract interface class dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler$Companion;
|
||||
public abstract fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public abstract fun onRequestReturnResult-3t6e044 (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler$Companion : dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler {
|
||||
public fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestReturnResult-3t6e044 (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler$DefaultImpls {
|
||||
public static fun onAfterCallFactoryMakeCall (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestException (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestResultAbsent (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestResultPresented (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static fun onRequestReturnResult-3t6e044 (Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public abstract class dev/inmo/tgbotapi/bot/ktor/base/AbstractRequestCallFactory : dev/inmo/tgbotapi/bot/ktor/KtorCallFactory {
|
||||
@@ -414,7 +415,7 @@ public final class dev/inmo/tgbotapi/bot/ktor/base/MultipartRequestCallFactory :
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/base/MultipleClientKtorRequestsExecutor : dev/inmo/tgbotapi/bot/BaseRequestsExecutor {
|
||||
public fun <init> (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/KtorPipelineStepsHolder;ILdev/inmo/kslog/common/KSLog;Lkotlin/jvm/functions/Function0;)V
|
||||
public fun <init> (Ldev/inmo/tgbotapi/utils/TelegramAPIUrlsKeeper;Ljava/util/List;ZLdev/inmo/tgbotapi/bot/settings/limiters/RequestLimiter;Lkotlinx/serialization/json/Json;Ldev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler;ILdev/inmo/kslog/common/KSLog;Lkotlin/jvm/functions/Function0;)V
|
||||
public fun close ()V
|
||||
public fun execute (Ldev/inmo/tgbotapi/requests/abstracts/Request;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
@@ -425,6 +426,94 @@ public final class dev/inmo/tgbotapi/bot/ktor/base/SimpleRequestCallFactory : de
|
||||
public synthetic fun <init> (Ldev/inmo/kslog/common/KSLog;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
}
|
||||
|
||||
public class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware : dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware$Companion;
|
||||
public fun <init> ()V
|
||||
public fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function4;Ljava/lang/String;)V
|
||||
public synthetic fun <init> (Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function5;Lkotlin/jvm/functions/Function3;Lkotlin/jvm/functions/Function4;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun getId ()Ljava/lang/String;
|
||||
public fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestReturnResult-3t6e044 (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware$Companion {
|
||||
public final fun build (Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware$ResultAbsence : java/lang/Throwable {
|
||||
public static final field INSTANCE Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware$ResultAbsence;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewareBuilder {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewareBuilder$Companion;
|
||||
public fun <init> ()V
|
||||
public final fun build ()Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;
|
||||
public final fun doOnAfterCallFactoryMakeCall (Lkotlin/jvm/functions/Function4;)V
|
||||
public final fun doOnBeforeCallFactoryMakeCall (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun doOnBeforeSearchCallFactory (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun doOnRequestException (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun doOnRequestResultAbsent (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun doOnRequestResultPresented (Lkotlin/jvm/functions/Function5;)V
|
||||
public final fun doOnRequestReturnResult (Lkotlin/jvm/functions/Function4;)V
|
||||
public final fun getId ()Ljava/lang/String;
|
||||
public final fun getOnAfterCallFactoryMakeCall ()Lkotlin/jvm/functions/Function4;
|
||||
public final fun getOnBeforeCallFactoryMakeCall ()Lkotlin/jvm/functions/Function3;
|
||||
public final fun getOnBeforeSearchCallFactory ()Lkotlin/jvm/functions/Function3;
|
||||
public final fun getOnRequestException ()Lkotlin/jvm/functions/Function3;
|
||||
public final fun getOnRequestResultAbsent ()Lkotlin/jvm/functions/Function3;
|
||||
public final fun getOnRequestResultPresented ()Lkotlin/jvm/functions/Function5;
|
||||
public final fun getOnRequestReturnResult ()Lkotlin/jvm/functions/Function4;
|
||||
public final fun setId (Ljava/lang/String;)V
|
||||
public final fun setOnAfterCallFactoryMakeCall (Lkotlin/jvm/functions/Function4;)V
|
||||
public final fun setOnBeforeCallFactoryMakeCall (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun setOnBeforeSearchCallFactory (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun setOnRequestException (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun setOnRequestResultAbsent (Lkotlin/jvm/functions/Function3;)V
|
||||
public final fun setOnRequestResultPresented (Lkotlin/jvm/functions/Function5;)V
|
||||
public final fun setOnRequestReturnResult (Lkotlin/jvm/functions/Function4;)V
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewareBuilder$Companion {
|
||||
public final fun from (Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler : dev/inmo/tgbotapi/bot/ktor/TelegramBotPipelinesHandler {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler$Companion;
|
||||
public fun <init> ()V
|
||||
public fun <init> (Ljava/util/List;)V
|
||||
public synthetic fun <init> (Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public fun onAfterCallFactoryMakeCall (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeCallFactoryMakeCall (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onBeforeSearchCallFactory (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestException (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/lang/Throwable;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultAbsent (Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestResultPresented (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ldev/inmo/tgbotapi/bot/ktor/KtorCallFactory;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public fun onRequestReturnResult-3t6e044 (Ljava/lang/Object;Ldev/inmo/tgbotapi/requests/abstracts/Request;Ljava/util/List;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler$Builder {
|
||||
public fun <init> ()V
|
||||
public final fun addMiddleware (Lkotlin/jvm/functions/Function1;)Z
|
||||
public final fun build ()Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler;
|
||||
public final fun getMiddlewares ()Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler$Companion {
|
||||
public final fun build (Lkotlin/jvm/functions/Function1;)Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddlewaresPipelinesHandler;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/ktor/middlewares/builtins/ExceptionsThrottlerTelegramBotMiddleware {
|
||||
public static final field INSTANCE Ldev/inmo/tgbotapi/bot/ktor/middlewares/builtins/ExceptionsThrottlerTelegramBotMiddleware;
|
||||
public static final field id Ljava/lang/String;
|
||||
public final fun invoke-HG0u8IE (FJ)Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;
|
||||
public static synthetic fun invoke-HG0u8IE$default (Ldev/inmo/tgbotapi/bot/ktor/middlewares/builtins/ExceptionsThrottlerTelegramBotMiddleware;FJILjava/lang/Object;)Ldev/inmo/tgbotapi/bot/ktor/middlewares/TelegramBotMiddleware;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/bot/multiserver/SimpleMultiServerRequestsExecutor : dev/inmo/tgbotapi/bot/RequestsExecutor {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/bot/multiserver/SimpleMultiServerRequestsExecutor$Companion;
|
||||
public fun <init> (Ljava/util/List;Lkotlin/jvm/functions/Function4;Lkotlin/jvm/functions/Function0;)V
|
||||
@@ -945,7 +1034,7 @@ public final class dev/inmo/tgbotapi/requests/abstracts/MultipartFile : dev/inmo
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public fun getFileId ()Ljava/lang/String;
|
||||
public final fun getFilename ()Ljava/lang/String;
|
||||
public final fun getInput ()Lio/ktor/utils/io/core/Input;
|
||||
public final fun getInput ()Lkotlinx/io/Source;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
@@ -20010,6 +20099,57 @@ public final class dev/inmo/tgbotapi/types/message/PrivateEventMessage : dev/inm
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/message/RawMessageEntity {
|
||||
public static final field Companion Ldev/inmo/tgbotapi/types/message/RawMessageEntity$Companion;
|
||||
public synthetic fun <init> (Ljava/lang/String;IILjava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public synthetic fun <init> (Ljava/lang/String;IILjava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public final fun component1 ()Ljava/lang/String;
|
||||
public final fun component2 ()I
|
||||
public final fun component3 ()I
|
||||
public final fun component4 ()Ljava/lang/String;
|
||||
public final fun component5 ()Ldev/inmo/tgbotapi/types/chat/User;
|
||||
public final fun component6 ()Ljava/lang/String;
|
||||
public final fun component7-GbmMWyQ ()Ljava/lang/String;
|
||||
public final fun copy-SbQeJ6M (Ljava/lang/String;IILjava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;)Ldev/inmo/tgbotapi/types/message/RawMessageEntity;
|
||||
public static synthetic fun copy-SbQeJ6M$default (Ldev/inmo/tgbotapi/types/message/RawMessageEntity;Ljava/lang/String;IILjava/lang/String;Ldev/inmo/tgbotapi/types/chat/User;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ldev/inmo/tgbotapi/types/message/RawMessageEntity;
|
||||
public fun equals (Ljava/lang/Object;)Z
|
||||
public final fun getCustom_emoji_id-GbmMWyQ ()Ljava/lang/String;
|
||||
public final fun getLanguage ()Ljava/lang/String;
|
||||
public final fun getLength ()I
|
||||
public final fun getOffset ()I
|
||||
public final fun getPriority ()I
|
||||
public final fun getType ()Ljava/lang/String;
|
||||
public final fun getUrl ()Ljava/lang/String;
|
||||
public final fun getUser ()Ldev/inmo/tgbotapi/types/chat/User;
|
||||
public fun hashCode ()I
|
||||
public fun toString ()Ljava/lang/String;
|
||||
}
|
||||
|
||||
public synthetic class dev/inmo/tgbotapi/types/message/RawMessageEntity$$serializer : kotlinx/serialization/internal/GeneratedSerializer {
|
||||
public static final field INSTANCE Ldev/inmo/tgbotapi/types/message/RawMessageEntity$$serializer;
|
||||
public final fun childSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
public final fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ldev/inmo/tgbotapi/types/message/RawMessageEntity;
|
||||
public synthetic fun deserialize (Lkotlinx/serialization/encoding/Decoder;)Ljava/lang/Object;
|
||||
public final fun getDescriptor ()Lkotlinx/serialization/descriptors/SerialDescriptor;
|
||||
public final fun serialize (Lkotlinx/serialization/encoding/Encoder;Ldev/inmo/tgbotapi/types/message/RawMessageEntity;)V
|
||||
public synthetic fun serialize (Lkotlinx/serialization/encoding/Encoder;Ljava/lang/Object;)V
|
||||
public fun typeParametersSerializers ()[Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/message/RawMessageEntity$Companion {
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/message/RawMessageEntityKt {
|
||||
public static final fun asTextSource (Ldev/inmo/tgbotapi/types/message/RawMessageEntity;Ljava/lang/String;Ljava/util/List;)Ldev/inmo/tgbotapi/types/message/textsources/TextSource;
|
||||
public static final fun asTextSources (Ljava/util/List;Ljava/lang/String;)Ljava/util/List;
|
||||
public static final fun toRawMessageEntities (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;I)Ljava/util/List;
|
||||
public static final fun toRawMessageEntities (Ljava/util/List;)Ljava/util/List;
|
||||
public static final fun toRawMessageEntities (Ljava/util/List;I)Ljava/util/List;
|
||||
public static synthetic fun toRawMessageEntities$default (Ldev/inmo/tgbotapi/types/message/textsources/TextSource;IILjava/lang/Object;)Ljava/util/List;
|
||||
public static synthetic fun toRawMessageEntities$default (Ljava/util/List;IILjava/lang/Object;)Ljava/util/List;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/message/UnconnectedFromChannelGroupContentMessageImpl : dev/inmo/tgbotapi/types/message/abstracts/UnconnectedFromChannelGroupContentMessage {
|
||||
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat;Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;JDLdev/inmo/tgbotapi/types/message/ForwardInfo;Lkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/message/abstracts/AccessibleMessage;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/message/content/MessageContent;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
public synthetic fun <init> (Ldev/inmo/tgbotapi/types/chat/PreviewGroupChat;Ldev/inmo/tgbotapi/types/chat/PreviewChannelChat;JDLdev/inmo/tgbotapi/types/message/MessageOrigin;Lkorlibs/time/DateTime;ZLdev/inmo/tgbotapi/types/ReplyInfo;Ldev/inmo/tgbotapi/types/buttons/InlineKeyboardMarkup;Ldev/inmo/tgbotapi/types/message/content/MessageContent;Ldev/inmo/tgbotapi/types/chat/CommonBot;Ljava/lang/String;Ljava/lang/String;ZLkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
@@ -21771,6 +21911,7 @@ public synthetic class dev/inmo/tgbotapi/types/message/textsources/BotCommandTex
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/message/textsources/BotCommandTextSource$Companion {
|
||||
public final fun getCommandRegex ()Lkotlin/text/Regex;
|
||||
public final fun serializer ()Lkotlinx/serialization/KSerializer;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package dev.inmo.tgbotapi.bot.ktor
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.middlewares.TelegramBotMiddlewaresPipelinesHandler
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
@@ -24,7 +25,7 @@ expect class KtorRequestsExecutor internal constructor(
|
||||
excludeDefaultFactories: Boolean,
|
||||
requestsLimiter: RequestLimiter,
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
pipelineStepsHolder: TelegramBotPipelinesHandler,
|
||||
logger: KSLog,
|
||||
diff: Unit // just a diff property to know where constructor and where calling function with defaults
|
||||
) : BaseRequestsExecutor {
|
||||
@@ -39,7 +40,7 @@ fun KtorRequestsExecutor(
|
||||
excludeDefaultFactories: Boolean = false,
|
||||
requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter,
|
||||
jsonFormatter: Json = nonstrictJsonFormat,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder,
|
||||
pipelineStepsHolder: TelegramBotPipelinesHandler = TelegramBotMiddlewaresPipelinesHandler(),
|
||||
logger: KSLog = DefaultKTgBotAPIKSLog,
|
||||
) = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper = telegramAPIUrlsKeeper,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor
|
||||
|
||||
import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
import dev.inmo.tgbotapi.bot.ktor.base.*
|
||||
import dev.inmo.tgbotapi.bot.ktor.middlewares.TelegramBotMiddlewaresPipelinesHandler
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.utils.*
|
||||
@@ -27,7 +27,11 @@ class KtorRequestsExecutorBuilder(
|
||||
var requestsLimiter: RequestLimiter = ExceptionsOnlyLimiter
|
||||
var jsonFormatter: Json = nonstrictJsonFormat
|
||||
var logger: KSLog = DefaultKTgBotAPIKSLog
|
||||
var pipelineStepsHolder: KtorPipelineStepsHolder = KtorPipelineStepsHolder
|
||||
var pipelineStepsHolder: TelegramBotPipelinesHandler = TelegramBotMiddlewaresPipelinesHandler()
|
||||
|
||||
fun includeMiddlewares(block: TelegramBotMiddlewaresPipelinesHandler.Builder.() -> Unit) {
|
||||
pipelineStepsHolder = TelegramBotMiddlewaresPipelinesHandler.build(block)
|
||||
}
|
||||
|
||||
fun build() = KtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper,
|
||||
|
||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.bot.ktor
|
||||
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
|
||||
interface KtorPipelineStepsHolder {
|
||||
interface TelegramBotPipelinesHandler {
|
||||
/**
|
||||
* Will be called when any exception will happen due to the [request] handling. If returns value - that value
|
||||
* will be returned from [dev.inmo.tgbotapi.bot.RequestsExecutor.execute] instead
|
||||
@@ -68,7 +68,10 @@ interface KtorPipelineStepsHolder {
|
||||
result: Result<T>,
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T = result.getOrThrow()
|
||||
): Result<T> = result
|
||||
|
||||
companion object : KtorPipelineStepsHolder
|
||||
companion object : TelegramBotPipelinesHandler
|
||||
}
|
||||
|
||||
@Deprecated("Renamed", ReplaceWith("TelegramBotPipelinesHandler", "dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler"))
|
||||
typealias KtorPipelineStepsHolder = TelegramBotPipelinesHandler
|
||||
@@ -1,7 +1,6 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.base
|
||||
|
||||
import dev.inmo.kslog.common.*
|
||||
import dev.inmo.micro_utils.coroutines.defaultSafelyExceptionHandler
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.exceptions.BotException
|
||||
@@ -9,15 +8,12 @@ import dev.inmo.tgbotapi.bot.exceptions.CommonBotException
|
||||
import dev.inmo.tgbotapi.bot.exceptions.GetUpdatesConflict
|
||||
import dev.inmo.tgbotapi.bot.exceptions.newRequestException
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
import dev.inmo.tgbotapi.bot.ktor.createTelegramBotDefaultKtorCallRequestsFactories
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.types.Response
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.plugins.*
|
||||
import io.ktor.client.statement.*
|
||||
@@ -30,7 +26,7 @@ class DefaultKtorRequestsExecutor internal constructor(
|
||||
excludeDefaultFactories: Boolean,
|
||||
private val requestsLimiter: RequestLimiter,
|
||||
private val jsonFormatter: Json,
|
||||
private val pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
private val pipelineStepsHolder: TelegramBotPipelinesHandler,
|
||||
private val logger: KSLog,
|
||||
diff: Unit
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
@@ -51,7 +47,7 @@ class DefaultKtorRequestsExecutor internal constructor(
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> execute(request: Request<T>): T {
|
||||
return runCatchingSafely {
|
||||
return runCatching {
|
||||
logger.v { "Start request $request" }
|
||||
pipelineStepsHolder.onBeforeSearchCallFactory(request, callsFactories)
|
||||
requestsLimiter.limit(request) {
|
||||
@@ -110,7 +106,7 @@ class DefaultKtorRequestsExecutor internal constructor(
|
||||
}
|
||||
}
|
||||
} ?.let { Result.failure(it) } ?: it
|
||||
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).also {
|
||||
pipelineStepsHolder.onRequestReturnResult(result, request, callsFactories).getOrThrow().also {
|
||||
logger.v { "Result of handling $request: $it" }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,7 @@ import dev.inmo.tgbotapi.utils.ByteReadChannelAllocator
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.receive
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.HttpStatement
|
||||
import io.ktor.client.statement.bodyAsChannel
|
||||
import io.ktor.utils.io.*
|
||||
import kotlinx.coroutines.*
|
||||
|
||||
@@ -6,9 +6,9 @@ import dev.inmo.tgbotapi.requests.DownloadFile
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.request.get
|
||||
import io.ktor.client.statement.readBytes
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.request.*
|
||||
import io.ktor.client.statement.*
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
@RiskFeature
|
||||
@@ -17,13 +17,13 @@ object DownloadFileRequestCallFactory : KtorCallFactory {
|
||||
client: HttpClient,
|
||||
urlsKeeper: TelegramAPIUrlsKeeper,
|
||||
request: Request<T>,
|
||||
jsonFormatter: Json
|
||||
): T? = (request as? DownloadFile) ?.let {
|
||||
jsonFormatter: Json,
|
||||
): T? = (request as? DownloadFile)?.let {
|
||||
val fullUrl = urlsKeeper.createFileLinkUrl(it.filePath)
|
||||
|
||||
safely {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
client.get(fullUrl).readBytes() as T // always ByteArray
|
||||
client.get(fullUrl).readRawBytes() as T // always ByteArray
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,13 +4,10 @@ import dev.inmo.kslog.common.KSLog
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.BaseRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorPipelineStepsHolder
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorRequestsExecutor
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.ExceptionsOnlyLimiter
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
import dev.inmo.tgbotapi.bot.settings.limiters.RequestLimiter
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import dev.inmo.tgbotapi.utils.TelegramAPIUrlsKeeper
|
||||
import dev.inmo.tgbotapi.utils.nonstrictJsonFormat
|
||||
import io.ktor.client.*
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.first
|
||||
@@ -41,16 +38,16 @@ internal expect inline fun platformClientCopy(client: HttpClient): HttpClient
|
||||
* @param requestExecutorsCount Amount of [DefaultKtorRequestsExecutor] which will be created and used under the
|
||||
* hood
|
||||
*/
|
||||
class MultipleClientKtorRequestsExecutor (
|
||||
class MultipleClientKtorRequestsExecutor(
|
||||
telegramAPIUrlsKeeper: TelegramAPIUrlsKeeper,
|
||||
callsFactories: List<KtorCallFactory>,
|
||||
excludeDefaultFactories: Boolean,
|
||||
requestsLimiter: RequestLimiter,
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
pipelineStepsHolder: TelegramBotPipelinesHandler,
|
||||
requestExecutorsCount: Int,
|
||||
logger: KSLog,
|
||||
clientFactory: () -> HttpClient
|
||||
clientFactory: () -> HttpClient,
|
||||
) : BaseRequestsExecutor(telegramAPIUrlsKeeper) {
|
||||
private val requestExecutors = (0 until requestExecutorsCount).map {
|
||||
DefaultKtorRequestsExecutor(
|
||||
@@ -69,7 +66,7 @@ class MultipleClientKtorRequestsExecutor (
|
||||
private val clientAllocationMutex = Mutex()
|
||||
private val takerFlow = freeClients.mapNotNull {
|
||||
clientAllocationMutex.withLock {
|
||||
freeClients.value.firstOrNull() ?.also {
|
||||
freeClients.value.firstOrNull()?.also {
|
||||
freeClients.value -= it
|
||||
} ?: return@mapNotNull null
|
||||
}
|
||||
@@ -82,9 +79,9 @@ class MultipleClientKtorRequestsExecutor (
|
||||
excludeDefaultFactories: Boolean,
|
||||
requestsLimiter: RequestLimiter,
|
||||
jsonFormatter: Json,
|
||||
pipelineStepsHolder: KtorPipelineStepsHolder,
|
||||
pipelineStepsHolder: TelegramBotPipelinesHandler,
|
||||
logger: KSLog,
|
||||
diff: Unit
|
||||
diff: Unit,
|
||||
) : this(
|
||||
telegramAPIUrlsKeeper,
|
||||
callsFactories,
|
||||
@@ -92,7 +89,7 @@ class MultipleClientKtorRequestsExecutor (
|
||||
requestsLimiter,
|
||||
jsonFormatter,
|
||||
pipelineStepsHolder,
|
||||
client.engineConfig.threadsCount,
|
||||
requestExecutorsCount = 4, // default threads count; configurable through dispatcher property
|
||||
logger,
|
||||
{ platformClientCopy(client) }
|
||||
)
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.middlewares
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
|
||||
/**
|
||||
* @param onRequestException Will be called when some exception happen during [Request] handling. Non-null result of
|
||||
* lambda will be used as the result of request handling
|
||||
* @param onBeforeSearchCallFactory Will be called when telegram bot starts to choose which [KtorCallFactory] will handle
|
||||
* [Request]
|
||||
* @param onBeforeCallFactoryMakeCall Will be called when telegram bot trying to use [KtorCallFactory] as potential
|
||||
* handler for [Request]
|
||||
* @param onAfterCallFactoryMakeCall Will be called when [KtorCallFactory] made call. Non-null result of
|
||||
* lambda will be used as the result of request handling
|
||||
* @param onRequestResultPresented Will be called when [KtorCallFactory] **or** [TelegramBotPipelinesHandler]/[TelegramBotMiddleware]
|
||||
* returned non-null result. Non-null result of lambda will be used as the result of request handling
|
||||
* @param onRequestResultAbsent Will be called when some there is no any result of [Request] handling. Non-null result of
|
||||
* lambda will be used as the result of request handling
|
||||
* @param onRequestReturnResult Latest lambda before result returning. Will be called after all previous stages.
|
||||
* Non-null result of lambda will be used as the result of request handling
|
||||
*/
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
open class TelegramBotMiddleware(
|
||||
internal val onRequestException: (suspend (request: Request<*>, t: Throwable?) -> Any?)? = null,
|
||||
internal val onBeforeSearchCallFactory: (suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Unit)? = null,
|
||||
internal val onBeforeCallFactoryMakeCall: (suspend (request: Request<*>, potentialFactory: KtorCallFactory) -> Unit)? = null,
|
||||
internal val onAfterCallFactoryMakeCall: (suspend (result: Any?, request: Request<*>, potentialFactory: KtorCallFactory) -> Any?)? = null,
|
||||
internal val onRequestResultPresented: (suspend (result: Any, request: Request<*>, resultCallFactory: KtorCallFactory, callsFactories: List<KtorCallFactory>) -> Any?)? = null,
|
||||
internal val onRequestResultAbsent: (suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Any?)? = null,
|
||||
internal val onRequestReturnResult: (suspend (result: Result<*>, request: Request<*>, callsFactories: List<KtorCallFactory>) -> Result<Any?>?)? = null,
|
||||
val id: String = uuid4().toString()
|
||||
) : TelegramBotPipelinesHandler {
|
||||
object ResultAbsence : Throwable()
|
||||
override suspend fun <T : Any> onRequestException(request: Request<T>, t: Throwable): T? {
|
||||
return onRequestException ?.invoke(request, t) as? T
|
||||
}
|
||||
|
||||
override suspend fun onBeforeSearchCallFactory(request: Request<*>, callsFactories: List<KtorCallFactory>) {
|
||||
onBeforeSearchCallFactory ?.invoke(request, callsFactories)
|
||||
}
|
||||
|
||||
override suspend fun onBeforeCallFactoryMakeCall(request: Request<*>, potentialFactory: KtorCallFactory) {
|
||||
onBeforeCallFactoryMakeCall ?.invoke(request, potentialFactory)
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onAfterCallFactoryMakeCall(
|
||||
result: T?,
|
||||
request: Request<T>,
|
||||
potentialFactory: KtorCallFactory
|
||||
): T? {
|
||||
return onAfterCallFactoryMakeCall ?.invoke(result, request, potentialFactory) as? T
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestResultPresented(
|
||||
result: T,
|
||||
request: Request<T>,
|
||||
resultCallFactory: KtorCallFactory,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
return onRequestResultPresented ?.invoke(result, request, resultCallFactory, callsFactories) as? T
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestResultAbsent(
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
return onRequestResultAbsent ?.invoke(request, callsFactories) as? T
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestReturnResult(
|
||||
result: Result<T>,
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): Result<T> {
|
||||
return onRequestReturnResult ?.invoke(result, request, callsFactories) as? Result<T> ?: Result.failure(ResultAbsence)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun build(block: TelegramBotMiddlewareBuilder.() -> Unit): TelegramBotMiddleware = TelegramBotMiddlewareBuilder().apply(block).build()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.middlewares
|
||||
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
class TelegramBotMiddlewareBuilder {
|
||||
var onRequestException: (suspend (request: Request<*>, t: Throwable?) -> Any?)? = null
|
||||
var onBeforeSearchCallFactory: (suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Unit)? = null
|
||||
var onBeforeCallFactoryMakeCall: (suspend (request: Request<*>, potentialFactory: KtorCallFactory) -> Unit)? = null
|
||||
var onAfterCallFactoryMakeCall: (suspend (result: Any?, request: Request<*>, potentialFactory: KtorCallFactory) -> Any?)? = null
|
||||
var onRequestResultPresented: (suspend (result: Any, request: Request<*>, resultCallFactory: KtorCallFactory, callsFactories: List<KtorCallFactory>) -> Any?)? = null
|
||||
var onRequestResultAbsent: (suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Any?)? = null
|
||||
var onRequestReturnResult: (suspend (result: Result<*>, request: Request<*>, callsFactories: List<KtorCallFactory>) -> Result<Any?>?)? = null
|
||||
var id: String = uuid4().toString()
|
||||
|
||||
/**
|
||||
* Useful way to set [onRequestException]
|
||||
*/
|
||||
fun doOnRequestException(block: suspend (request: Request<*>, t: Throwable?) -> Any?) {
|
||||
onRequestException = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onBeforeSearchCallFactory]
|
||||
*/
|
||||
fun doOnBeforeSearchCallFactory(block: suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Unit) {
|
||||
onBeforeSearchCallFactory = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onBeforeCallFactoryMakeCall]
|
||||
*/
|
||||
fun doOnBeforeCallFactoryMakeCall(block: suspend (request: Request<*>, potentialFactory: KtorCallFactory) -> Unit) {
|
||||
onBeforeCallFactoryMakeCall = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onAfterCallFactoryMakeCall]
|
||||
*/
|
||||
fun doOnAfterCallFactoryMakeCall(block: suspend (result: Any?, request: Request<*>, potentialFactory: KtorCallFactory) -> Any?) {
|
||||
onAfterCallFactoryMakeCall = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestResultPresented]
|
||||
*/
|
||||
fun doOnRequestResultPresented(block: suspend (result: Any, request: Request<*>, resultCallFactory: KtorCallFactory, callsFactories: List<KtorCallFactory>) -> Any?) {
|
||||
onRequestResultPresented = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestResultAbsent]
|
||||
*/
|
||||
fun doOnRequestResultAbsent(block: suspend (request: Request<*>, callsFactories: List<KtorCallFactory>) -> Any?) {
|
||||
onRequestResultAbsent = block
|
||||
}
|
||||
/**
|
||||
* Useful way to set [onRequestReturnResult]
|
||||
*/
|
||||
fun doOnRequestReturnResult(block: suspend (result: Result<*>, request: Request<*>, callsFactories: List<KtorCallFactory>) -> Result<Any?>?) {
|
||||
onRequestReturnResult = block
|
||||
}
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun build(): TelegramBotMiddleware {
|
||||
return TelegramBotMiddleware(
|
||||
onRequestException = onRequestException,
|
||||
onBeforeSearchCallFactory = onBeforeSearchCallFactory,
|
||||
onBeforeCallFactoryMakeCall = onBeforeCallFactoryMakeCall,
|
||||
onAfterCallFactoryMakeCall = onAfterCallFactoryMakeCall,
|
||||
onRequestResultPresented = onRequestResultPresented,
|
||||
onRequestResultAbsent = onRequestResultAbsent,
|
||||
onRequestReturnResult = onRequestReturnResult,
|
||||
id = id
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun from(middleware: TelegramBotMiddleware, additionalSetup: TelegramBotMiddlewareBuilder.() -> Unit): TelegramBotMiddleware {
|
||||
return TelegramBotMiddlewareBuilder().apply {
|
||||
onRequestException = middleware.onRequestException
|
||||
onBeforeSearchCallFactory = middleware.onBeforeSearchCallFactory
|
||||
onBeforeCallFactoryMakeCall = middleware.onBeforeCallFactoryMakeCall
|
||||
onAfterCallFactoryMakeCall = middleware.onAfterCallFactoryMakeCall
|
||||
onRequestResultPresented = middleware.onRequestResultPresented
|
||||
onRequestResultAbsent = middleware.onRequestResultAbsent
|
||||
onRequestReturnResult = middleware.onRequestReturnResult
|
||||
id = middleware.id
|
||||
additionalSetup()
|
||||
}.build()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.middlewares
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.tgbotapi.bot.ktor.KtorCallFactory
|
||||
import dev.inmo.tgbotapi.bot.ktor.TelegramBotPipelinesHandler
|
||||
import dev.inmo.tgbotapi.bot.ktor.middlewares.builtins.ExceptionsThrottlerTelegramBotMiddleware
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
class TelegramBotMiddlewaresPipelinesHandler(
|
||||
private val middlewares: List<TelegramBotMiddleware> = emptyList()
|
||||
) : TelegramBotPipelinesHandler {
|
||||
override suspend fun <T : Any> onRequestException(request: Request<T>, t: Throwable): T? {
|
||||
return middlewares.firstNotNullOfOrNull {
|
||||
it.onRequestException(request, t)
|
||||
} ?: super.onRequestException(request, t)
|
||||
}
|
||||
|
||||
override suspend fun onBeforeSearchCallFactory(request: Request<*>, callsFactories: List<KtorCallFactory>) {
|
||||
middlewares.forEach {
|
||||
it.onBeforeSearchCallFactory(request, callsFactories)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun onBeforeCallFactoryMakeCall(request: Request<*>, potentialFactory: KtorCallFactory) {
|
||||
middlewares.forEach {
|
||||
it.onBeforeCallFactoryMakeCall(request, potentialFactory)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onAfterCallFactoryMakeCall(
|
||||
result: T?,
|
||||
request: Request<T>,
|
||||
potentialFactory: KtorCallFactory
|
||||
): T? {
|
||||
return middlewares.firstNotNullOfOrNull {
|
||||
it.onAfterCallFactoryMakeCall(result, request, potentialFactory)
|
||||
} ?: super.onAfterCallFactoryMakeCall(result, request, potentialFactory)
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestResultPresented(
|
||||
result: T,
|
||||
request: Request<T>,
|
||||
resultCallFactory: KtorCallFactory,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
return middlewares.firstNotNullOfOrNull {
|
||||
it.onRequestResultPresented(result, request, resultCallFactory, callsFactories)
|
||||
} ?: super.onRequestResultPresented(result, request, resultCallFactory, callsFactories)
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestResultAbsent(
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): T? {
|
||||
return middlewares.firstNotNullOfOrNull {
|
||||
it.onRequestResultAbsent(request, callsFactories)
|
||||
} ?: super.onRequestResultAbsent(request, callsFactories)
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> onRequestReturnResult(
|
||||
result: Result<T>,
|
||||
request: Request<T>,
|
||||
callsFactories: List<KtorCallFactory>
|
||||
): Result<T> {
|
||||
return middlewares.firstNotNullOfOrNull {
|
||||
it.onRequestReturnResult(result, request, callsFactories).takeIf {
|
||||
it.onFailure { return@takeIf it !is TelegramBotMiddleware.ResultAbsence }
|
||||
true
|
||||
}
|
||||
} ?: super.onRequestReturnResult(result, request, callsFactories)
|
||||
}
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
class Builder {
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
val middlewares = mutableListOf<TelegramBotMiddleware>()
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun addMiddleware(block: TelegramBotMiddlewareBuilder.() -> Unit) = middlewares.add(
|
||||
TelegramBotMiddleware.build(block)
|
||||
)
|
||||
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun build(): TelegramBotMiddlewaresPipelinesHandler = TelegramBotMiddlewaresPipelinesHandler(
|
||||
middlewares.toList()
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Warning("This API is experimental and subject of changes")
|
||||
fun build(block: Builder.() -> Unit) = Builder().apply(block).build()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package dev.inmo.tgbotapi.bot.ktor.middlewares.builtins
|
||||
|
||||
import dev.inmo.tgbotapi.bot.ktor.middlewares.TelegramBotMiddleware
|
||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||
import korlibs.time.milliseconds
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.time.Duration
|
||||
|
||||
/**
|
||||
* @see invoke
|
||||
*/
|
||||
object ExceptionsThrottlerTelegramBotMiddleware {
|
||||
const val id: String = "ExceptionsThrottlerTelegramBotMiddleware"
|
||||
|
||||
/**
|
||||
* Creates [TelegramBotMiddleware] and configures it with next parameters:
|
||||
*
|
||||
* * [TelegramBotMiddleware.onRequestException] will throttle after exception if exception has happened before
|
||||
* * [TelegramBotMiddleware.onRequestReturnResult] will clear state of all exceptions happened with the [Request] if its
|
||||
* handling has been completed successfully
|
||||
*/
|
||||
operator fun invoke(
|
||||
exceptionDurationMultiplier: Float = 2f,
|
||||
initialExceptionDuration: Duration = 125.milliseconds,
|
||||
): TelegramBotMiddleware = TelegramBotMiddleware.build {
|
||||
val exceptionsTimeouts = mutableMapOf<KClass<*>, Duration>()
|
||||
val latestExceptionsRequestsTypes = mutableMapOf<KClass<*>, MutableSet<KClass<*>>>()
|
||||
val mutex = Mutex()
|
||||
onRequestException = onRequestException@{ request, t ->
|
||||
t ?: return@onRequestException null
|
||||
val kclass = t::class
|
||||
val toSleep = mutex.withLock {
|
||||
val latestDuration = exceptionsTimeouts[kclass]
|
||||
exceptionsTimeouts[kclass] = latestDuration ?.times(exceptionDurationMultiplier.toDouble()) ?: initialExceptionDuration
|
||||
latestExceptionsRequestsTypes.getOrPut(request::class) { mutableSetOf() }.add(kclass)
|
||||
latestDuration
|
||||
}
|
||||
toSleep ?.let {
|
||||
delay(it)
|
||||
}
|
||||
null
|
||||
}
|
||||
onRequestReturnResult = onRequestReturnResult@{ result, request, _ ->
|
||||
if (result.isSuccess) {
|
||||
mutex.withLock {
|
||||
val exceptionKClass = latestExceptionsRequestsTypes.remove(request::class) ?: return@withLock
|
||||
exceptionKClass.forEach {
|
||||
exceptionsTimeouts.remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
null
|
||||
}
|
||||
id = ExceptionsThrottlerTelegramBotMiddleware.id
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.inmo.tgbotapi.types.message
|
||||
|
||||
import dev.inmo.micro_utils.common.Warning
|
||||
import dev.inmo.micro_utils.serialization.mapper.MapperSerializer
|
||||
import dev.inmo.tgbotapi.types.CustomEmojiId
|
||||
import dev.inmo.tgbotapi.types.chat.User
|
||||
@@ -9,7 +10,8 @@ import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.builtins.ListSerializer
|
||||
|
||||
@Serializable
|
||||
internal data class RawMessageEntity(
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this class")
|
||||
data class RawMessageEntity(
|
||||
val type: String,
|
||||
val offset: Int,
|
||||
val length: Int,
|
||||
@@ -49,7 +51,8 @@ internal data class RawMessageEntity(
|
||||
}
|
||||
}
|
||||
|
||||
internal fun RawMessageEntity.asTextSource(
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
fun RawMessageEntity.asTextSource(
|
||||
source: String,
|
||||
subParts: List<Pair<Int, TextSource>>
|
||||
): TextSource {
|
||||
@@ -92,6 +95,7 @@ private inline operator fun <T : Comparable<T>> ClosedRange<T>.contains(other: C
|
||||
return start <= other.start && endInclusive >= other.endInclusive
|
||||
}
|
||||
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
internal fun List<Pair<Int, TextSource>>.fillWithRegulars(source: String): TextSourcesList {
|
||||
var index = 0
|
||||
val result = mutableListOf<TextSource>()
|
||||
@@ -174,7 +178,8 @@ private fun createTextSources(
|
||||
return resultList
|
||||
}
|
||||
|
||||
internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEntity> {
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEntity> {
|
||||
val source = source
|
||||
val length = source.length
|
||||
return listOfNotNull(
|
||||
@@ -208,7 +213,8 @@ internal fun TextSource.toRawMessageEntities(offset: Int = 0): List<RawMessageEn
|
||||
}
|
||||
|
||||
|
||||
internal fun TextSourcesList.toRawMessageEntities(preOffset: Int = 0): List<RawMessageEntity> {
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
fun TextSourcesList.toRawMessageEntities(preOffset: Int = 0): List<RawMessageEntity> {
|
||||
var i = preOffset
|
||||
return flatMap { textSource ->
|
||||
textSource.toRawMessageEntities(i).also {
|
||||
@@ -217,9 +223,12 @@ internal fun TextSourcesList.toRawMessageEntities(preOffset: Int = 0): List<RawM
|
||||
}
|
||||
}
|
||||
|
||||
internal fun TextSourcesList.toRawMessageEntities(): List<RawMessageEntity> = toRawMessageEntities(0)
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
fun TextSourcesList.toRawMessageEntities(): List<RawMessageEntity> = toRawMessageEntities(0)
|
||||
|
||||
internal fun RawMessageEntities.asTextSources(sourceString: String): TextSourcesList =
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this extension")
|
||||
fun RawMessageEntities.asTextSources(sourceString: String): TextSourcesList =
|
||||
createTextSources(sourceString, this).fillWithRegulars(sourceString)
|
||||
|
||||
internal typealias RawMessageEntities = List<RawMessageEntity>
|
||||
@Warning("This thing is subject of changes. Library do not guarantee stability of this typealias")
|
||||
typealias RawMessageEntities = List<RawMessageEntity>
|
||||
|
||||
@@ -7,8 +7,6 @@ import dev.inmo.tgbotapi.utils.RiskFeature
|
||||
import dev.inmo.tgbotapi.utils.internal.*
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
private val commandRegex = Regex("[/!][^@\\s]*")
|
||||
|
||||
/**
|
||||
* @see botCommand
|
||||
*/
|
||||
@@ -17,7 +15,7 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
|
||||
override val source: String
|
||||
) : TextSource {
|
||||
val command: String by lazy {
|
||||
commandRegex.find(source) ?.value ?.substring(1) ?: source.substring(1)// skip first symbol like "/" or "!"
|
||||
CommandRegex.find(source) ?.value ?.substring(1) ?: source.substring(1)// skip first symbol like "/" or "!"
|
||||
}
|
||||
val username: Username? by lazy {
|
||||
Username(usernameRegex.find(source) ?.value ?: return@lazy null)
|
||||
@@ -26,6 +24,10 @@ data class BotCommandTextSource @RiskFeature(DirectInvocationOfTextSourceConstru
|
||||
override val markdown: String by lazy { source.commandMarkdown() }
|
||||
override val markdownV2: String by lazy { source.commandMarkdownV2() }
|
||||
override val html: String by lazy { source.commandHTML() }
|
||||
|
||||
companion object {
|
||||
val CommandRegex = Regex("[/!][^@\\s]*")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,27 +7,6 @@ import kotlinx.serialization.encoding.CompositeEncoder
|
||||
import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
|
||||
//private val baseSerializers: Map<String, KSerializer<out TextSource>> = mapOf(
|
||||
// "regular" to RegularTextSource.serializer(),
|
||||
// "text_link" to TextLinkTextSource.serializer(),
|
||||
// "code" to CodeTextSource.serializer(),
|
||||
// "url" to URLTextSource.serializer(),
|
||||
// "pre" to PreTextSource.serializer(),
|
||||
// "bot_command" to BotCommandTextSource.serializer(),
|
||||
// "strikethrough" to StrikethroughTextSource.serializer(),
|
||||
// "italic" to ItalicTextSource.serializer(),
|
||||
// "bold" to BoldTextSource.serializer(),
|
||||
// "email" to EMailTextSource.serializer(),
|
||||
// "underline" to UnderlineTextSource.serializer(),
|
||||
// "mention" to MentionTextSource.serializer(),
|
||||
// "phone_number" to PhoneNumberTextSource.serializer(),
|
||||
// "text_mention" to TextMentionTextSource.serializer(),
|
||||
// "hashtag" to HashTagTextSource.serializer(),
|
||||
// "cashtag" to CashTagTextSource.serializer(),
|
||||
// "spoiler" to SpoilerTextSource.serializer(),
|
||||
// "custom_emoji" to CustomEmojiTextSource.serializer(),
|
||||
//)
|
||||
|
||||
object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, emptyMap()) {
|
||||
private val baseSerializers: Map<String, KSerializer<out TextSource>> by lazy {
|
||||
mapOf(
|
||||
@@ -49,6 +28,8 @@ object TextSourceSerializer : TypedSerializer<TextSource>(TextSource::class, emp
|
||||
"cashtag" to CashTagTextSource.serializer(),
|
||||
"spoiler" to SpoilerTextSource.serializer(),
|
||||
"custom_emoji" to CustomEmojiTextSource.serializer(),
|
||||
"blockquote" to BlockquoteTextSource.serializer(),
|
||||
"expandable_blockquote" to ExpandableBlockquoteTextSource.serializer(),
|
||||
).also {
|
||||
it.forEach { (k, s) ->
|
||||
include(k, s)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package dev.inmo.tgbotapi.utils
|
||||
|
||||
import io.ktor.util.toByteArray
|
||||
import io.ktor.utils.io.ByteReadChannel
|
||||
import io.ktor.utils.io.core.ByteReadPacket
|
||||
import io.ktor.utils.io.core.Input
|
||||
import io.ktor.utils.io.*
|
||||
import io.ktor.utils.io.core.*
|
||||
|
||||
actual suspend fun ByteReadChannel.asInput(): Input = ByteReadPacket(toByteArray())
|
||||
|
||||
@@ -3541,10 +3541,10 @@ public final class dev/inmo/tgbotapi/extensions/utils/updates/retrieving/Webhook
|
||||
public static synthetic fun includeWebhookHandlingInRoute$default (Lio/ktor/server/routing/Route;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
|
||||
public static final fun includeWebhookHandlingInRouteWithFlows (Lio/ktor/server/routing/Route;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JLkotlin/jvm/functions/Function1;)V
|
||||
public static synthetic fun includeWebhookHandlingInRouteWithFlows$default (Lio/ktor/server/routing/Route;Lkotlinx/coroutines/CoroutineScope;Lkotlin/jvm/functions/Function2;JLkotlin/jvm/functions/Function1;ILjava/lang/Object;)V
|
||||
public static final fun setWebhookInfoAndStartListenWebhooks (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILio/ktor/server/engine/ApplicationEngineFactory;Ldev/inmo/tgbotapi/requests/webhook/SetWebhookRequest;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun setWebhookInfoAndStartListenWebhooks$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILio/ktor/server/engine/ApplicationEngineFactory;Ldev/inmo/tgbotapi/requests/webhook/SetWebhookRequest;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun startListenWebhooks (ILio/ktor/server/engine/ApplicationEngineFactory;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/ktor/server/engine/ApplicationEngine;
|
||||
public static synthetic fun startListenWebhooks$default (ILio/ktor/server/engine/ApplicationEngineFactory;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/ktor/server/engine/ApplicationEngine;
|
||||
public static final fun setWebhookInfoAndStartListenWebhooks (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILio/ktor/server/engine/ApplicationEngineFactory;Ldev/inmo/tgbotapi/requests/webhook/SetWebhookRequest;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
|
||||
public static synthetic fun setWebhookInfoAndStartListenWebhooks$default (Ldev/inmo/tgbotapi/bot/RequestsExecutor;ILio/ktor/server/engine/ApplicationEngineFactory;Ldev/inmo/tgbotapi/requests/webhook/SetWebhookRequest;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
|
||||
public static final fun startListenWebhooks (ILio/ktor/server/engine/ApplicationEngineFactory;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/ktor/server/engine/EmbeddedServer;
|
||||
public static synthetic fun startListenWebhooks$default (ILio/ktor/server/engine/ApplicationEngineFactory;Lkotlin/jvm/functions/Function2;Ljava/lang/String;Ljava/lang/String;Ldev/inmo/tgbotapi/updateshandlers/webhook/WebhookPrivateKeyConfig;Lkotlinx/coroutines/CoroutineScope;JLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/ktor/server/engine/EmbeddedServer;
|
||||
}
|
||||
|
||||
public final class dev/inmo/tgbotapi/types/files/PathedFileAsStreamKt {
|
||||
|
||||
@@ -2,11 +2,10 @@ package dev.inmo.tgbotapi.extensions.utils
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.safely
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.channels.BroadcastChannel
|
||||
import kotlinx.coroutines.flow.*
|
||||
|
||||
/**
|
||||
* Analog of [merge] function for [Flow]s. The difference is in the usage of [BroadcastChannel] in this case
|
||||
* Analog of [merge] function for [Flow]s. The difference is in the usage of [MutableSharedFlow] in this case
|
||||
*/
|
||||
fun <T> aggregateFlows(
|
||||
withScope: CoroutineScope,
|
||||
|
||||
@@ -1,19 +1,21 @@
|
||||
package dev.inmo.tgbotapi.extensions.utils.updates.retrieving
|
||||
|
||||
import dev.inmo.micro_utils.coroutines.*
|
||||
import dev.inmo.micro_utils.coroutines.ExceptionHandler
|
||||
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||
import dev.inmo.tgbotapi.bot.RequestsExecutor
|
||||
import dev.inmo.tgbotapi.extensions.utils.nonstrictJsonFormat
|
||||
import dev.inmo.tgbotapi.extensions.utils.updates.flowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.requests.webhook.SetWebhookRequest
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||
import dev.inmo.tgbotapi.types.update.abstracts.UpdateDeserializationStrategy
|
||||
import dev.inmo.tgbotapi.updateshandlers.*
|
||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||
import dev.inmo.tgbotapi.updateshandlers.UpdateReceiver
|
||||
import dev.inmo.tgbotapi.updateshandlers.UpdatesFilter
|
||||
import dev.inmo.tgbotapi.updateshandlers.webhook.WebhookPrivateKeyConfig
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.http.*
|
||||
import io.ktor.server.engine.*
|
||||
import io.ktor.server.request.receiveText
|
||||
import io.ktor.server.response.respond
|
||||
import io.ktor.server.request.*
|
||||
import io.ktor.server.response.*
|
||||
import io.ktor.server.routing.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
@@ -38,7 +40,7 @@ fun Route.includeWebhookHandlingInRoute(
|
||||
scope: CoroutineScope,
|
||||
exceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
mediaGroupsDebounceTimeMillis: Long = 1000L,
|
||||
block: UpdateReceiver<Update>
|
||||
block: UpdateReceiver<Update>,
|
||||
) {
|
||||
val transformer = scope.updateHandlerWithMediaGroupsAdaptation(block, mediaGroupsDebounceTimeMillis)
|
||||
post {
|
||||
@@ -55,7 +57,7 @@ fun Route.includeWebhookHandlingInRoute(
|
||||
call.respond(HttpStatusCode.InternalServerError)
|
||||
}.getOrThrow()
|
||||
} catch (e: Throwable) {
|
||||
exceptionsHandler ?.invoke(e)
|
||||
exceptionsHandler?.invoke(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,7 +71,7 @@ fun Route.includeWebhookHandlingInRouteWithFlows(
|
||||
scope: CoroutineScope,
|
||||
exceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||
mediaGroupsDebounceTimeMillis: Long = 1000L,
|
||||
block: FlowsUpdatesFilter.() -> Unit
|
||||
block: FlowsUpdatesFilter.() -> Unit,
|
||||
) = includeWebhookHandlingInRoute(
|
||||
scope,
|
||||
exceptionsHandler,
|
||||
@@ -92,50 +94,57 @@ fun Route.includeWebhookHandlingInRouteWithFlows(
|
||||
* @see UpdatesFilter
|
||||
* @see UpdatesFilter.asUpdateReceiver
|
||||
*/
|
||||
fun startListenWebhooks(
|
||||
fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> startListenWebhooks(
|
||||
listenPort: Int,
|
||||
engineFactory: ApplicationEngineFactory<*, *>,
|
||||
engineFactory: ApplicationEngineFactory<TEngine, TConfiguration>,
|
||||
exceptionsHandler: ExceptionHandler<Unit>,
|
||||
listenHost: String = "0.0.0.0",
|
||||
listenRoute: String? = null,
|
||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||
mediaGroupsDebounceTimeMillis: Long = 1000L,
|
||||
additionalApplicationEngineEnvironmentConfigurator: ApplicationEngineEnvironmentBuilder.() -> Unit = {},
|
||||
block: UpdateReceiver<Update>
|
||||
): ApplicationEngine {
|
||||
val env = applicationEngineEnvironment {
|
||||
|
||||
module {
|
||||
routing {
|
||||
listenRoute ?.also {
|
||||
createRouteFromPath(it).includeWebhookHandlingInRoute(scope, exceptionsHandler, mediaGroupsDebounceTimeMillis, block)
|
||||
} ?: includeWebhookHandlingInRoute(scope, exceptionsHandler, mediaGroupsDebounceTimeMillis, block)
|
||||
}
|
||||
}
|
||||
|
||||
privateKeyConfig ?.let {
|
||||
sslConnector(
|
||||
privateKeyConfig.keyStore,
|
||||
privateKeyConfig.aliasName,
|
||||
privateKeyConfig::keyStorePassword,
|
||||
privateKeyConfig::aliasPassword
|
||||
) {
|
||||
additionalApplicationEnvironmentConfigurator: ApplicationEnvironmentBuilder.() -> Unit = {},
|
||||
additionalEngineConfigurator: TConfiguration.() -> Unit = {},
|
||||
block: UpdateReceiver<Update>,
|
||||
): EmbeddedServer<TEngine, TConfiguration> =
|
||||
embeddedServer(
|
||||
factory = engineFactory,
|
||||
environment = applicationEnvironment {
|
||||
additionalApplicationEnvironmentConfigurator()
|
||||
},
|
||||
configure = {
|
||||
privateKeyConfig?.let {
|
||||
sslConnector(
|
||||
privateKeyConfig.keyStore,
|
||||
privateKeyConfig.aliasName,
|
||||
privateKeyConfig::keyStorePassword,
|
||||
privateKeyConfig::aliasPassword
|
||||
) {
|
||||
host = listenHost
|
||||
port = listenPort
|
||||
}
|
||||
} ?: connector {
|
||||
host = listenHost
|
||||
port = listenPort
|
||||
}
|
||||
} ?: connector {
|
||||
host = listenHost
|
||||
port = listenPort
|
||||
|
||||
additionalEngineConfigurator()
|
||||
},
|
||||
module = {
|
||||
routing {
|
||||
listenRoute?.also {
|
||||
createRouteFromPath(it).includeWebhookHandlingInRoute(
|
||||
scope,
|
||||
exceptionsHandler,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
block
|
||||
)
|
||||
} ?: includeWebhookHandlingInRoute(scope, exceptionsHandler, mediaGroupsDebounceTimeMillis, block)
|
||||
}
|
||||
}
|
||||
|
||||
additionalApplicationEngineEnvironmentConfigurator()
|
||||
}
|
||||
|
||||
return embeddedServer(engineFactory, env).also {
|
||||
).also {
|
||||
it.start(false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Setting up ktor server, set webhook info via [SetWebhookRequest] request.
|
||||
@@ -152,9 +161,9 @@ fun startListenWebhooks(
|
||||
* @see UpdatesFilter.asUpdateReceiver
|
||||
*/
|
||||
@Suppress("unused")
|
||||
suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
||||
suspend fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
||||
listenPort: Int,
|
||||
engineFactory: ApplicationEngineFactory<*, *>,
|
||||
engineFactory: ApplicationEngineFactory<TEngine, TConfiguration>,
|
||||
setWebhookRequest: SetWebhookRequest,
|
||||
exceptionsHandler: ExceptionHandler<Unit> = {},
|
||||
listenHost: String = "0.0.0.0",
|
||||
@@ -162,11 +171,24 @@ suspend fun RequestsExecutor.setWebhookInfoAndStartListenWebhooks(
|
||||
privateKeyConfig: WebhookPrivateKeyConfig? = null,
|
||||
scope: CoroutineScope = CoroutineScope(Executors.newFixedThreadPool(4).asCoroutineDispatcher()),
|
||||
mediaGroupsDebounceTimeMillis: Long = 1000L,
|
||||
additionalApplicationEngineEnvironmentConfigurator: ApplicationEngineEnvironmentBuilder.() -> Unit = {},
|
||||
block: UpdateReceiver<Update>
|
||||
): ApplicationEngine = try {
|
||||
additionalApplicationEnvironmentConfigurator: ApplicationEnvironmentBuilder.() -> Unit = {},
|
||||
additionalEngineConfigurator: TConfiguration.() -> Unit = {},
|
||||
block: UpdateReceiver<Update>,
|
||||
): EmbeddedServer<TEngine, TConfiguration> = try {
|
||||
execute(setWebhookRequest)
|
||||
startListenWebhooks(listenPort, engineFactory, exceptionsHandler, listenHost, listenRoute, privateKeyConfig, scope, mediaGroupsDebounceTimeMillis, additionalApplicationEngineEnvironmentConfigurator, block)
|
||||
startListenWebhooks(
|
||||
listenPort,
|
||||
engineFactory,
|
||||
exceptionsHandler,
|
||||
listenHost,
|
||||
listenRoute,
|
||||
privateKeyConfig,
|
||||
scope,
|
||||
mediaGroupsDebounceTimeMillis,
|
||||
additionalApplicationEnvironmentConfigurator,
|
||||
additionalEngineConfigurator,
|
||||
block
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user