mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-12-30 18:09:25 +00:00
Compare commits
98 Commits
6cbe313e42
...
1.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 8a3538d9c7 | |||
| e3db4250bb | |||
| 4643ac906a | |||
| 497974e45c | |||
| 78a00f0efb | |||
| 14ecb9d948 | |||
| c759b9a466 | |||
| 58c1f2ee6a | |||
| 9d16ca3b7e | |||
| 9d40e598f1 | |||
| f1be8bf16e | |||
| 56a8804e99 | |||
| 1e73aac750 | |||
| 82c6eda0b7 | |||
| e9ff93cde1 | |||
| 9b179ea1c9 | |||
| 72d20d2344 | |||
| bcd288fe05 | |||
| 75477060e9 | |||
| 60df609486 | |||
| 556b492b35 | |||
| 53e8c53fb1 | |||
| 69d36c5c1b | |||
| ad97008f12 | |||
| 3e58114eeb | |||
| d55d8fa000 | |||
| bd32dbb3ab | |||
| 8e0389f032 | |||
| cb37b85234 | |||
| df01976ea8 | |||
| 7be74e468b | |||
| 437176203a | |||
| 7b25862035 | |||
| 45585caab0 | |||
| 6fea2a12d8 | |||
| ae639d38e0 | |||
| 0510f72859 | |||
| 233c789054 | |||
| 52f405c3b1 | |||
| 199856acce | |||
| f36d642ec8 | |||
| aa6e5b2284 | |||
| 32b83ac687 | |||
| a2206b99a2 | |||
| 90e0b1ac81 | |||
| 1b5b3af45b | |||
| 7ff6412ec5 | |||
| bd23d3fbdb | |||
| 08147fc33b | |||
| ba4c153659 | |||
| 3c3607d817 | |||
| d0add888c4 | |||
| 3e3adab46b | |||
| 89d13de307 | |||
| 32451f4e1c | |||
| 721c3f2430 | |||
| fc92df8fbe | |||
| ad50f41d1e | |||
| 8c9cd9df67 | |||
| 8e7f7a03c8 | |||
| 484e09374d | |||
|
|
619c82bb32 | ||
| 33fb75a5eb | |||
| 901c1e8956 | |||
| 2ae105cb15 | |||
|
|
db14eee3b6 | ||
| 6f8b881668 | |||
| d113d4f0f5 | |||
| dd893b14d3 | |||
| 19ddff2999 | |||
| 7f08fd9d66 | |||
| d3cb44490b | |||
| 4d3cad16a4 | |||
| a52f31f4c9 | |||
| 682f696866 | |||
| 87fff2e5d0 | |||
| 92b4ba2ff0 | |||
| 9014cdbc99 | |||
| d0709a509f | |||
| 0273d07777 | |||
| bafb0c2459 | |||
| 9be2b899cb | |||
| 37317a1055 | |||
| 60c21002e1 | |||
| 78a7a3546a | |||
| 4799617ced | |||
| c70484076d | |||
| 9f451f25f7 | |||
| 506c2b4a09 | |||
| 0c92e6eeb4 | |||
| efd1c8f83a | |||
| 7e57a0e4e0 | |||
| 6b977e67d0 | |||
| ab5937449c | |||
| 61d3131bf2 | |||
| 048f244449 | |||
| 6ebf4ff652 | |||
| b4c41d7dd8 |
119
CHANGELOG.md
119
CHANGELOG.md
@@ -1,9 +1,42 @@
|
|||||||
# TelegramBotAPI changelog
|
# TelegramBotAPI changelog
|
||||||
|
|
||||||
|
## 1.1.2
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Rename of `TelegramAPIUrlsKeeper#checkWebAppLink` -> `TelegramAPIUrlsKeeper#checkWebAppData` (fix of [#591](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/591))
|
||||||
|
* `Behaviour Builder with FSM`:
|
||||||
|
* New typealias `StateHandlingErrorHandler`
|
||||||
|
* `BehaviourBuilderWithFSM` now accepts new parameter `onStateHandlingErrorHandler` which will be used in case if state has not been successfully completed
|
||||||
|
|
||||||
|
## 1.1.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `MicroUtils.Crypto` will not be provided with that library anymore. Instead, it is recommended to use `Korlibs.Krypto`. You still can add crypto from microutils using next groovy dependency: `dev.inmo:micro_utils.crypto:$micro_utils_version`
|
||||||
|
* `Core`:
|
||||||
|
* Improvements in `TelegramAPIUrlsKeeper#checkWebAppLink`
|
||||||
|
* New field in `TelegramAPIUrlsKeeper#webAppDataSecretKeyHash`
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Extension `TelegramBot#buildBehaviour` now returns `BehaviourContext`
|
||||||
|
|
||||||
|
## 1.1.0
|
||||||
|
|
||||||
|
* `Utils`:
|
||||||
|
* New parameter `additionalApplicationEngineEnvironmentConfigurator` in `RequestsExecutor#setWebhookInfoAndStartListenWebhooks` and `startListenWebhooks`
|
||||||
|
|
||||||
|
## 1.0.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Serialization`: `1.3.2` -> `1.3.3`
|
||||||
|
* `MicroUtils`: `0.10.3` -> `0.10.4`
|
||||||
|
|
||||||
## 1.0.0
|
## 1.0.0
|
||||||
|
|
||||||
__All the `tgbotapi.extensions.*` packages have been removed__
|
__All the `tgbotapi.extensions.*` packages have been removed__
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `Kotlin`: `1.6.10` -> `1.6.21`
|
||||||
|
* `Ktor`: `1.6.8` -> `2.0.1`
|
||||||
|
* `MicroUtils`: `0.9.24` -> `0.10.3`
|
||||||
* `Core`:
|
* `Core`:
|
||||||
* **`Ktor` package renamed. Migration:** `dev.inmo.tgbotapi.bot.Ktor` -> `dev.inmo.tgbotapi.bot.ktor`
|
* **`Ktor` package renamed. Migration:** `dev.inmo.tgbotapi.bot.Ktor` -> `dev.inmo.tgbotapi.bot.ktor`
|
||||||
* **`CallbackQuery` package renamed. Migration:** `dev.inmo.tgbotapi.types.CallbackQuery([\s\\.])` -> `dev.inmo.tgbotapi.types.queries.callback$1`
|
* **`CallbackQuery` package renamed. Migration:** `dev.inmo.tgbotapi.types.CallbackQuery([\s\\.])` -> `dev.inmo.tgbotapi.types.queries.callback$1`
|
||||||
@@ -22,6 +55,21 @@ __All the `tgbotapi.extensions.*` packages have been removed__
|
|||||||
* `dev.inmo.tgbotapi.types.UserSerializer` -> `dev.inmo.tgbotapi.types.chat.UserSerializer`
|
* `dev.inmo.tgbotapi.types.UserSerializer` -> `dev.inmo.tgbotapi.types.chat.UserSerializer`
|
||||||
* **All `InputMedia` has been renamed as `TelegramMedia`. Migration:** `InputMedia` -> `TelegramMedia`
|
* **All `InputMedia` has been renamed as `TelegramMedia`. Migration:** `InputMedia` -> `TelegramMedia`
|
||||||
* `dev.inmo.tgbotapi.types.InputMedia` -> `dev.inmo.tgbotapi.types.media`
|
* `dev.inmo.tgbotapi.types.InputMedia` -> `dev.inmo.tgbotapi.types.media`
|
||||||
|
* **Replaces of `MessageContent`. Migrations:**
|
||||||
|
* `dev.inmo.tgbotapi.types.message.content.abstracts` -> `dev.inmo.tgbotapi.types.message.content`
|
||||||
|
* `dev.inmo.tgbotapi.types.message.content.media` -> `dev.inmo.tgbotapi.types.message.content`
|
||||||
|
* **Replaces of `TextSource`s. Migrations:** `dev.inmo.tgbotapi.types.MessageEntity.textsources` -> `dev.inmo.tgbotapi.types.message.textsources`
|
||||||
|
* **Replaces of `ParseMode`s. Migrations:** `dev.inmo.tgbotapi.types.ParseMode` -> `dev.inmo.tgbotapi.types.message`
|
||||||
|
* **Replaces of `MediaGroupUpdate`s. Migrations:** `dev.inmo.tgbotapi.types.update.MediaGroupUpdates` -> `dev.inmo.tgbotapi.types.update.media_group`
|
||||||
|
* **`InvoiceContent` has been replaced: `dev.inmo.tgbotapi.types.message.payments.InvoiceContent` -> `dev.inmo.tgbotapi.types.message.content.InvoiceContent`**
|
||||||
|
* **`PossiblySentViaBotCommonMessage` has been replaced: `dev.inmo.tgbotapi.types.message.content.abstracts.PossiblySentViaBotCommonMessage` -> `dev.inmo.tgbotapi.types.message.abstracts.PossiblySentViaBotCommonMessage`**
|
||||||
|
* **Edit live location requests have been replaced:**
|
||||||
|
* `dev.inmo.tgbotapi.requests.edit.LiveLocation` -> `dev.inmo.tgbotapi.requests.edit.location.live`
|
||||||
|
* `dev.inmo.tgbotapi.extensions.api.edit.LiveLocation` -> `dev.inmo.tgbotapi.extensions.api.edit.location.live`
|
||||||
|
* **Edit reply markup requests have been replaced:**
|
||||||
|
* `dev.inmo.tgbotapi.requests.edit.ReplyMarkup` -> `dev.inmo.tgbotapi.requests.edit.reply_markup`
|
||||||
|
* `dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup` -> `dev.inmo.tgbotapi.extensions.api.edit.reply_markup`
|
||||||
|
* **Common abstracts have been replaced: `dev.inmo.tgbotapi.CommonAbstracts` -> `dev.inmo.tgbotapi.abstracts`**
|
||||||
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json` ([#563](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/563))
|
* Constructor of `UnknownInlineKeyboardButton` is not internal and can be created with any `json` ([#563](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/563))
|
||||||
* All the interfaces from `dev.inmo.tgbotapi.types.files.abstracts` have been replaced to `dev.inmo.tgbotapi.types.files` and converted to sealed ([#550](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/550))
|
* All the interfaces from `dev.inmo.tgbotapi.types.files.abstracts` have been replaced to `dev.inmo.tgbotapi.types.files` and converted to sealed ([#550](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/550))
|
||||||
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`
|
* `PassportFile` has been replaced to `dev.inmo.tgbotapi.types.files`
|
||||||
@@ -31,6 +79,77 @@ __All the `tgbotapi.extensions.*` packages have been removed__
|
|||||||
* New typealias `FileUrl` (represents `FileId` but declare that they are the same)
|
* New typealias `FileUrl` (represents `FileId` but declare that they are the same)
|
||||||
* `BehaviourBuilder`:
|
* `BehaviourBuilder`:
|
||||||
* `SimpleFilter` now is a `fun interface` instead of just callback (fix of [#546](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/546))
|
* `SimpleFilter` now is a `fun interface` instead of just callback (fix of [#546](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/546))
|
||||||
|
* New extension `BehaviourContext#createSubContext`. It uses separated `AccumulatorFlow` and will retrieve updates by itself
|
||||||
|
* New extension `BehaviourContext#doInContext`
|
||||||
|
* Extension `BehaviourContext#doInSubContextWithUpdatesFilter` has been renamed to `BehaviourContext#createSubContextAndDoWithUpdatesFilter`
|
||||||
|
* Extension `BehaviourContext#doInSubContext` has been deprecated
|
||||||
|
* `BehaviourContextWithFSM`:
|
||||||
|
* `launchStateHandling` lost its parameter `contextUpdatesFlow: Flow`
|
||||||
|
* `handleState` of `BehaviourContextWithFSM` now will get/create sub context for the state and launch handling in it
|
||||||
|
* `BehaviourWithFSMStateHandler` now extends `StatesHandler`
|
||||||
|
* `BehaviourWithFSMStateHandlerHolder` now extends `CheckableHandlerHolder` and `BehaviourWithFSMStateHandler`
|
||||||
|
* Function `checkHandleable` of `BehaviourWithFSMStateHandlerHolder` now is `suspend`
|
||||||
|
|
||||||
|
## 0.38.23
|
||||||
|
|
||||||
|
* `BehaviourHandler`:
|
||||||
|
* Add support of fallback triggers (fix of [#560](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/560))
|
||||||
|
|
||||||
|
## 0.38.22
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* New constant `tgWebAppStartParamField`
|
||||||
|
* All keyboards builders and rows blocks becomes not crossinline
|
||||||
|
|
||||||
|
## 0.38.21
|
||||||
|
|
||||||
|
* `WebApps`:
|
||||||
|
* `WebAppInitData#queryId` now have correct js name of field
|
||||||
|
* New function `sendDataOrWorkWithQueryId`
|
||||||
|
|
||||||
|
## 0.38.20
|
||||||
|
|
||||||
|
* `BehaviourBuilder FSM`:
|
||||||
|
* Hotfixes
|
||||||
|
* `WebApps`:
|
||||||
|
* New extension `TelegramBot#answerWebAppQuery`
|
||||||
|
* New function `handleResult`
|
||||||
|
|
||||||
|
## 0.38.19
|
||||||
|
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* Hotfixes
|
||||||
|
* `BehaviourBuilder FSM`:
|
||||||
|
* `BehaviourContextWithFSMBuilder` deprecated in favor to `BehaviourContextWithFSM`
|
||||||
|
* Now it is possible to define additional handlers in subcontexts of `BehaviourBuilderWithFSM`
|
||||||
|
|
||||||
|
## 0.38.18
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Add support of test servers (fix of [#577](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/577))
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* Fixes in extension `BehaviourContext#doInSubContextWithUpdatesFilter` (thanks to [xzima](https://github.com/xzima))
|
||||||
|
|
||||||
|
## 0.38.17
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* Add `BotCommandScopeChat` as new `BotCommandScope` (fix of [#574](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/574))
|
||||||
|
* `BotCommandScope` companion got several properties and functions for more useful scope creation
|
||||||
|
|
||||||
|
## 0.38.16
|
||||||
|
|
||||||
|
* `Core`:
|
||||||
|
* `TelegramAPIUrlsKeeper` now have two new things: properties `webAppDataSecretKey` and fun `checkWebAppLink`
|
||||||
|
|
||||||
|
## 0.38.15
|
||||||
|
|
||||||
|
* `Common`:
|
||||||
|
* `Version`:
|
||||||
|
* `MicroUtils`: `0.9.20` -> `0.9.24`
|
||||||
|
* `Core`:
|
||||||
|
* Fixes in `MessageContent#serializationModule`
|
||||||
|
* `BehaviourBuilder`:
|
||||||
|
* Add triggers for `DataCallbackQuery` and subtypes with regex checking of data
|
||||||
|
|
||||||
## 0.38.14
|
## 0.38.14
|
||||||
|
|
||||||
|
|||||||
@@ -5,21 +5,21 @@ kotlin.js.generate.externals=true
|
|||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
|
||||||
kotlin_version=1.6.10
|
kotlin_version=1.6.21
|
||||||
kotlin_coroutines_version=1.6.1
|
kotlin_coroutines_version=1.6.1
|
||||||
kotlin_serialisation_runtime_version=1.3.2
|
kotlin_serialisation_runtime_version=1.3.3
|
||||||
klock_version=2.7.0
|
korlibs_version=2.7.0
|
||||||
uuid_version=0.4.0
|
uuid_version=0.4.0
|
||||||
ktor_version=1.6.8
|
ktor_version=2.0.1
|
||||||
|
|
||||||
micro_utils_version=0.9.24
|
micro_utils_version=0.10.4
|
||||||
|
|
||||||
javax_activation_version=1.1.1
|
javax_activation_version=1.1.1
|
||||||
|
|
||||||
|
|
||||||
dokka_version=1.6.10
|
dokka_version=1.6.21
|
||||||
|
|
||||||
library_group=dev.inmo
|
library_group=dev.inmo
|
||||||
library_version=1.0.0
|
library_version=1.1.2
|
||||||
|
|
||||||
github_release_plugin_version=2.3.7
|
github_release_plugin_version=2.3.7
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ data class BotBuilder internal constructor(
|
|||||||
fun buildBot(
|
fun buildBot(
|
||||||
token: String,
|
token: String,
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
block: BotBuilder.() -> Unit
|
block: BotBuilder.() -> Unit
|
||||||
) = telegramBot(
|
) = telegramBot(
|
||||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
||||||
BotBuilder().apply(block).createHttpClient()
|
BotBuilder().apply(block).createHttpClient()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -66,17 +66,19 @@ inline fun telegramBot(
|
|||||||
inline fun telegramBot(
|
inline fun telegramBot(
|
||||||
token: String,
|
token: String,
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
client: HttpClient = HttpClient()
|
client: HttpClient = HttpClient()
|
||||||
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, apiUrl), client)
|
): TelegramBot = telegramBot(TelegramAPIUrlsKeeper(token, testServer, apiUrl), client)
|
||||||
|
|
||||||
@Suppress("NOTHING_TO_INLINE")
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
inline fun <T: HttpClientEngineConfig> telegramBot(
|
inline fun <T: HttpClientEngineConfig> telegramBot(
|
||||||
token: String,
|
token: String,
|
||||||
clientFactory: HttpClientEngineFactory<T>,
|
clientFactory: HttpClientEngineFactory<T>,
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
|
noinline clientConfig: HttpClientConfig<T>.() -> Unit = {}
|
||||||
) = telegramBot(
|
) = telegramBot(
|
||||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
||||||
clientFactory,
|
clientFactory,
|
||||||
clientConfig
|
clientConfig
|
||||||
)
|
)
|
||||||
@@ -90,9 +92,10 @@ inline fun telegramBot(
|
|||||||
token: String,
|
token: String,
|
||||||
clientEngine: HttpClientEngine,
|
clientEngine: HttpClientEngine,
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
noinline clientConfig: HttpClientConfig<*>.() -> Unit = {}
|
||||||
) = telegramBot(
|
) = telegramBot(
|
||||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
||||||
clientEngine,
|
clientEngine,
|
||||||
clientConfig
|
clientConfig
|
||||||
)
|
)
|
||||||
@@ -105,8 +108,9 @@ inline fun telegramBot(
|
|||||||
inline fun telegramBot(
|
inline fun telegramBot(
|
||||||
token: String,
|
token: String,
|
||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
|
testServer: Boolean = false,
|
||||||
noinline clientConfig: HttpClientConfig<*>.() -> Unit
|
noinline clientConfig: HttpClientConfig<*>.() -> Unit
|
||||||
) = telegramBot(
|
) = telegramBot(
|
||||||
TelegramAPIUrlsKeeper(token, apiUrl),
|
TelegramAPIUrlsKeeper(token, testServer, apiUrl),
|
||||||
clientConfig
|
clientConfig
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import dev.inmo.tgbotapi.types.MediaGroupIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
import dev.inmo.tgbotapi.types.UpdateIdentifier
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.update.*
|
import dev.inmo.tgbotapi.types.update.*
|
||||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.*
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.*
|
import dev.inmo.tgbotapi.types.update.abstracts.*
|
||||||
|
import dev.inmo.tgbotapi.types.update.media_group.*
|
||||||
|
|
||||||
internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
|
internal fun Update.lastUpdateIdentifier(): UpdateIdentifier {
|
||||||
return if (this is SentMediaGroupUpdate) {
|
return if (this is SentMediaGroupUpdate) {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.extensions.api
|
|||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import com.soywiz.klock.TimeSpan
|
import com.soywiz.klock.TimeSpan
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.editLiveLocation
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||||
import dev.inmo.tgbotapi.extensions.api.edit.LiveLocation.stopLiveLocation
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||||
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
import dev.inmo.tgbotapi.requests.send.SendLiveLocation
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|||||||
@@ -1,18 +1,19 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.EditChatMessageLiveLocation
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||||
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
@@ -22,16 +23,13 @@ suspend fun TelegramBot.editLiveLocation(
|
|||||||
heading: Degrees? = null,
|
heading: Degrees? = null,
|
||||||
proximityAlertRadius: Meters? = null,
|
proximityAlertRadius: Meters? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = editLiveLocation(chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
EditChatMessageLiveLocation(
|
|
||||||
chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
@@ -41,12 +39,13 @@ suspend fun TelegramBot.editLiveLocation(
|
|||||||
heading: Degrees? = null,
|
heading: Degrees? = null,
|
||||||
proximityAlertRadius: Meters? = null,
|
proximityAlertRadius: Meters? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editLiveLocation(chat.id, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
) = editLiveLocation(chat, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
message: ContentMessage<LocationContent>,
|
message: ContentMessage<LocationContent>,
|
||||||
latitude: Double,
|
latitude: Double,
|
||||||
@@ -55,40 +54,39 @@ suspend fun TelegramBot.editLiveLocation(
|
|||||||
heading: Degrees? = null,
|
heading: Degrees? = null,
|
||||||
proximityAlertRadius: Meters? = null,
|
proximityAlertRadius: Meters? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
) = editLiveLocation(message, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
location: LiveLocation,
|
location: LiveLocation,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = editLiveLocation(chatId, messageId, location, replyMarkup)
|
||||||
EditChatMessageLiveLocation(
|
|
||||||
chatId, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
location: LiveLocation,
|
location: LiveLocation,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
) = editLiveLocation(chat, messageId, location, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
message: ContentMessage<LocationContent>,
|
message: ContentMessage<LocationContent>,
|
||||||
location: LiveLocation,
|
location: LiveLocation,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
) = editLiveLocation(message, location, replyMarkup)
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.EditInlineMessageLiveLocation
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.location.LiveLocation
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
|
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
latitude: Double,
|
latitude: Double,
|
||||||
@@ -14,13 +16,10 @@ suspend fun TelegramBot.editLiveLocation(
|
|||||||
heading: Degrees? = null,
|
heading: Degrees? = null,
|
||||||
proximityAlertRadius: Meters? = null,
|
proximityAlertRadius: Meters? = null,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = editLiveLocation(inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
EditInlineMessageLiveLocation(
|
@Deprecated("Replaced", ReplaceWith("editLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.editLiveLocation"))
|
||||||
inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
suspend fun TelegramBot.editLiveLocation(
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
location: LiveLocation,
|
location: LiveLocation,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
) = editLiveLocation(inlineMessageId, location, replyMarkup)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.StopChatMessageLiveLocation
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
@@ -13,31 +14,30 @@ import dev.inmo.tgbotapi.types.message.content.LocationContent
|
|||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||||
suspend fun TelegramBot.stopLiveLocation(
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = stopLiveLocation(chatId, messageId, replyMarkup)
|
||||||
StopChatMessageLiveLocation(
|
|
||||||
chatId, messageId, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||||
suspend fun TelegramBot.stopLiveLocation(
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
) = stopLiveLocation(chat, messageId, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||||
suspend fun TelegramBot.stopLiveLocation(
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
message: ContentMessage<LocationContent>,
|
message: ContentMessage<LocationContent>,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
) = stopLiveLocation(message, replyMarkup)
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
package dev.inmo.tgbotapi.extensions.api.edit.LiveLocation
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.LiveLocation.StopInlineMessageLiveLocation
|
import dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
@@ -9,11 +10,8 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("stopLiveLocation", "dev.inmo.tgbotapi.extensions.api.edit.location.live.stopLiveLocation"))
|
||||||
suspend fun TelegramBot.stopLiveLocation(
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = stopLiveLocation(inlineMessageId, replyMarkup)
|
||||||
StopInlineMessageLiveLocation(
|
|
||||||
inlineMessageId, replyMarkup
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.ReplyMarkup.EditChatMessageReplyMarkup
|
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
@@ -12,30 +12,31 @@ import dev.inmo.tgbotapi.types.message.abstracts.Message
|
|||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
chatId: ChatIdentifier,
|
chatId: ChatIdentifier,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(
|
) = editMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||||
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
chat: Chat,
|
chat: Chat,
|
||||||
messageId: MessageIdentifier,
|
messageId: MessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
) = editMessageReplyMarkup(chat, messageId, replyMarkup)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
message: Message,
|
message: Message,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
) = editMessageReplyMarkup(message, replyMarkup)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
package dev.inmo.tgbotapi.extensions.api.edit.ReplyMarkup
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.ReplyMarkup.EditInlineMessageReplyMarkup
|
import dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
@@ -9,7 +10,8 @@ import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
|||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
* as a builder for that
|
* as a builder for that
|
||||||
*/
|
*/
|
||||||
|
@Deprecated("Replaced", ReplaceWith("editMessageReplyMarkup", "dev.inmo.tgbotapi.extensions.api.edit.reply_markup.editMessageReplyMarkup"))
|
||||||
suspend fun TelegramBot.editMessageReplyMarkup(
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
inlineMessageId: InlineMessageIdentifier,
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
replyMarkup: InlineKeyboardMarkup? = null
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
) = editMessageReplyMarkup(inlineMessageId, replyMarkup)
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
package dev.inmo.tgbotapi.extensions.api.edit.caption
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.CommonAbstracts.TextedWithTextSources
|
import dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption
|
import dev.inmo.tgbotapi.requests.edit.caption.EditChatMessageCaption
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.extensions.api.edit.caption
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption
|
import dev.inmo.tgbotapi.requests.edit.caption.EditInlineMessageCaption
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.EditChatMessageLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: LiveLocation,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageLiveLocation(
|
||||||
|
chatId, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
location: LiveLocation,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(chat.id, messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
location: LiveLocation,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(message.chat, message.messageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.EditInlineMessageLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.*
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.location.LiveLocation
|
||||||
|
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
latitude: Double,
|
||||||
|
longitude: Double,
|
||||||
|
horizontalAccuracy: Meters? = null,
|
||||||
|
heading: Degrees? = null,
|
||||||
|
proximityAlertRadius: Meters? = null,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, latitude, longitude, horizontalAccuracy, heading, proximityAlertRadius, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
suspend fun TelegramBot.editLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
location: LiveLocation,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editLiveLocation(inlineMessageId, location.latitude, location.longitude, location.horizontalAccuracy, location.heading, location.proximityAlertRadius, replyMarkup)
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.StopChatMessageLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.LocationContent
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopChatMessageLiveLocation(
|
||||||
|
chatId, messageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
|
message: ContentMessage<LocationContent>,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = stopLiveLocation(message.chat, message.messageId, replyMarkup)
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.location.live
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.location.live.StopInlineMessageLiveLocation
|
||||||
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.stopLiveLocation(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
StopInlineMessageLiveLocation(
|
||||||
|
inlineMessageId, replyMarkup
|
||||||
|
)
|
||||||
|
)
|
||||||
@@ -8,7 +8,7 @@ import dev.inmo.tgbotapi.types.MessageIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.reply_markup
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.reply_markup.EditChatMessageReplyMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
|
chatId: ChatIdentifier,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(
|
||||||
|
EditChatMessageReplyMarkup(chatId, messageId, replyMarkup)
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
|
chat: Chat,
|
||||||
|
messageId: MessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(chat.id, messageId, replyMarkup)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
|
message: Message,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = editMessageReplyMarkup(message.chat.id, message.messageId, replyMarkup)
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.api.edit.reply_markup
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.requests.edit.reply_markup.EditInlineMessageReplyMarkup
|
||||||
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param replyMarkup Some [InlineKeyboardMarkup]. See [dev.inmo.tgbotapi.extensions.utils.types.buttons.inlineKeyboard]
|
||||||
|
* as a builder for that
|
||||||
|
*/
|
||||||
|
suspend fun TelegramBot.editMessageReplyMarkup(
|
||||||
|
inlineMessageId: InlineMessageIdentifier,
|
||||||
|
replyMarkup: InlineKeyboardMarkup? = null
|
||||||
|
) = execute(EditInlineMessageReplyMarkup(inlineMessageId, replyMarkup))
|
||||||
@@ -3,9 +3,9 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
import dev.inmo.tgbotapi.requests.edit.text.EditChatMessageText
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.ContentMessage
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ package dev.inmo.tgbotapi.extensions.api.edit.text
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
import dev.inmo.tgbotapi.requests.edit.text.EditInlineMessageText
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.requests.DownloadFile
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFile(
|
suspend fun TelegramBot.downloadFile(
|
||||||
filePath: String
|
filePath: String
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStream(
|
suspend fun TelegramBot.downloadFileStream(
|
||||||
filePath: String
|
filePath: String
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.requests.DownloadFileStream
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
suspend fun TelegramBot.downloadFileStreamAllocator(
|
suspend fun TelegramBot.downloadFileStreamAllocator(
|
||||||
filePath: String
|
filePath: String
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.requests.get.GetFile
|
import dev.inmo.tgbotapi.requests.get.GetFile
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
|
||||||
suspend fun TelegramBot.getFileAdditionalInfo(
|
suspend fun TelegramBot.getFileAdditionalInfo(
|
||||||
fileId: FileId
|
fileId: FileId
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package dev.inmo.tgbotapi.extensions.api.send
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
import dev.inmo.tgbotapi.requests.send.CopyMessage
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
import dev.inmo.tgbotapi.extensions.api.send.media.sendMediaGroup
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
* Send media group via [sendMediaGroup] extension with edited [entities] of first [messages] element. Other elements
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
|||||||
import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning
|
import dev.inmo.tgbotapi.requests.send.media.rawSendingMediaGroupsWarning
|
||||||
import dev.inmo.tgbotapi.types.*
|
import dev.inmo.tgbotapi.types.*
|
||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
import dev.inmo.tgbotapi.types.message.textsources.TextSource
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.InlineKeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
@@ -23,8 +23,7 @@ import dev.inmo.tgbotapi.types.files.Sticker
|
|||||||
import dev.inmo.tgbotapi.types.games.Game
|
import dev.inmo.tgbotapi.types.games.Game
|
||||||
import dev.inmo.tgbotapi.types.location.*
|
import dev.inmo.tgbotapi.types.location.*
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
import dev.inmo.tgbotapi.types.message.abstracts.Message
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
|
||||||
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
import dev.inmo.tgbotapi.types.payments.LabeledPrice
|
||||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
import dev.inmo.tgbotapi.types.payments.abstracts.Currency
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ package dev.inmo.tgbotapi.extensions.api.send
|
|||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
import dev.inmo.tgbotapi.requests.send.SendTextMessage
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
import dev.inmo.tgbotapi.requests.send.media.SendAnimation
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.AnimationFile
|
import dev.inmo.tgbotapi.types.files.AnimationFile
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
import dev.inmo.tgbotapi.requests.send.media.SendAudio
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.AudioFile
|
import dev.inmo.tgbotapi.types.files.AudioFile
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
import dev.inmo.tgbotapi.requests.send.media.SendDocument
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.DocumentFile
|
import dev.inmo.tgbotapi.types.files.DocumentFile
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import dev.inmo.tgbotapi.types.ChatIdentifier
|
|||||||
import dev.inmo.tgbotapi.types.media.*
|
import dev.inmo.tgbotapi.types.media.*
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioContent
|
import dev.inmo.tgbotapi.types.message.content.AudioContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentContent
|
import dev.inmo.tgbotapi.types.message.content.DocumentContent
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
import dev.inmo.tgbotapi.utils.RiskFeature
|
||||||
import kotlin.jvm.JvmName
|
import kotlin.jvm.JvmName
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
import dev.inmo.tgbotapi.requests.send.media.SendPhoto
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.*
|
import dev.inmo.tgbotapi.types.files.*
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
import dev.inmo.tgbotapi.requests.send.media.SendVideo
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.VideoFile
|
import dev.inmo.tgbotapi.types.files.VideoFile
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
import dev.inmo.tgbotapi.requests.abstracts.InputFile
|
||||||
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
import dev.inmo.tgbotapi.requests.send.media.SendVoice
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.files.VoiceFile
|
import dev.inmo.tgbotapi.types.files.VoiceFile
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import dev.inmo.tgbotapi.bot.TelegramBot
|
|||||||
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
import dev.inmo.tgbotapi.requests.send.polls.SendQuizPoll
|
||||||
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
import dev.inmo.tgbotapi.requests.send.polls.SendRegularPoll
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
import dev.inmo.tgbotapi.types.ChatIdentifier
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSourcesList
|
import dev.inmo.tgbotapi.types.message.textsources.TextSourcesList
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
import dev.inmo.tgbotapi.types.MessageIdentifier
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
import dev.inmo.tgbotapi.types.message.ParseMode
|
||||||
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
import dev.inmo.tgbotapi.types.buttons.KeyboardMarkup
|
||||||
import dev.inmo.tgbotapi.types.chat.Chat
|
import dev.inmo.tgbotapi.types.chat.Chat
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import dev.inmo.tgbotapi.extensions.api.get.getFileAdditionalInfo
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
import dev.inmo.tgbotapi.requests.abstracts.FileId
|
||||||
import dev.inmo.tgbotapi.types.files.PathedFile
|
import dev.inmo.tgbotapi.types.files.PathedFile
|
||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MediaContent
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
import io.ktor.util.cio.use
|
import io.ktor.util.cio.use
|
||||||
import io.ktor.util.cio.writeChannel
|
import io.ktor.util.cio.writeChannel
|
||||||
import io.ktor.utils.io.copyTo
|
import io.ktor.utils.io.copyTo
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
import dev.inmo.micro_utils.coroutines.*
|
||||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
import dev.inmo.micro_utils.fsm.common.*
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.micro_utils.coroutines.accumulatorFlow
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
import kotlinx.coroutines.channels.BufferOverflow
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface which combine [BehaviourContext] and [StatesMachine]. Subcontext of triggers and states contexts must have
|
* Interface which combine [BehaviourContext] and [StatesMachine]. Subcontext of triggers and states contexts must have
|
||||||
@@ -20,15 +20,24 @@ import kotlinx.coroutines.flow.*
|
|||||||
interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T> {
|
interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T> {
|
||||||
suspend fun start() = start(this)
|
suspend fun start() = start(this)
|
||||||
|
|
||||||
suspend fun launchStateHandling(
|
/**
|
||||||
state: T,
|
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
||||||
contextUpdatesFlow: Flow<Update>,
|
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
||||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
|
*
|
||||||
): T? {
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
return handlers.firstOrNull { it.checkHandleable(state) } ?.run {
|
* @see onStateOrSubstate
|
||||||
handleState(contextUpdatesFlow, state)
|
*/
|
||||||
}
|
fun <I : T> add(kClass: KClass<I>, strict: Boolean = false, handler: BehaviourWithFSMStateHandler<I, T>)
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
||||||
|
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
||||||
|
* requirements
|
||||||
|
*
|
||||||
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
|
* @see strictlyOn
|
||||||
|
*/
|
||||||
|
fun <I : T> addStrict(kClass: KClass<I>, handler: BehaviourWithFSMStateHandler<I, T>) = add(kClass, strict = true, handler)
|
||||||
|
|
||||||
override fun copy(
|
override fun copy(
|
||||||
bot: TelegramBot,
|
bot: TelegramBot,
|
||||||
@@ -36,41 +45,105 @@ interface BehaviourContextWithFSM<T : State> : BehaviourContext, StatesMachine<T
|
|||||||
broadcastChannelsSize: Int,
|
broadcastChannelsSize: Int,
|
||||||
onBufferOverflow: BufferOverflow,
|
onBufferOverflow: BufferOverflow,
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
upstreamUpdatesFlow: Flow<Update>?,
|
||||||
|
triggersHolder: TriggersHolder,
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||||
): BehaviourContextWithFSM<T>
|
): BehaviourContextWithFSM<T>
|
||||||
|
|
||||||
|
fun copy(
|
||||||
|
bot: TelegramBot = this.bot,
|
||||||
|
scope: CoroutineScope = this.scope,
|
||||||
|
broadcastChannelsSize: Int = 100,
|
||||||
|
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||||
|
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||||
|
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||||
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||||
|
): BehaviourContextWithFSM<T> = copy(
|
||||||
|
bot,
|
||||||
|
scope,
|
||||||
|
broadcastChannelsSize,
|
||||||
|
onBufferOverflow,
|
||||||
|
upstreamUpdatesFlow,
|
||||||
|
triggersHolder,
|
||||||
|
updatesFilter
|
||||||
|
)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
operator fun <T : State> invoke(
|
operator fun <T : State> invoke(
|
||||||
behaviourContext: BehaviourContext,
|
behaviourContext: BehaviourContext,
|
||||||
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||||
statesManager: StatesManager<T>
|
statesManager: StatesManager<T>,
|
||||||
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers)
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||||
|
) = DefaultBehaviourContextWithFSM<T>(behaviourContext, statesManager, handlers, onStateHandlingErrorHandler)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
||||||
|
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
||||||
|
*
|
||||||
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
|
* @see BehaviourContextWithFSM.add
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
inline fun <reified I : O, O: State> BehaviourContextWithFSM<O>.onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, O>) = add(I::class, strict = false, handler)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
||||||
|
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
||||||
|
* requirements
|
||||||
|
*
|
||||||
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
|
* @see BehaviourContextWithFSM.addStrict
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
inline fun <reified I : O, O: State> BehaviourContextWithFSM<O>.strictlyOn(handler: BehaviourWithFSMStateHandler<I, O>) = addStrict(I::class, handler)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default realization of [BehaviourContextWithFSM]. It uses [behaviourContext] as a base for this object as
|
* Default realization of [BehaviourContextWithFSM]. It uses [behaviourContext] as a base for this object as
|
||||||
* [BehaviourContext], but managing substates contexts updates for avoiding of updates lost between states
|
* [BehaviourContext], but managing substates contexts updates for avoiding of updates lost between states
|
||||||
|
* @param onStateHandlingErrorHandler Will be used in case if state handling has not been successfully completed in [launchStateHandling]
|
||||||
*/
|
*/
|
||||||
class DefaultBehaviourContextWithFSM<T : State>(
|
class DefaultBehaviourContextWithFSM<T : State>(
|
||||||
private val behaviourContext: BehaviourContext,
|
private val behaviourContext: BehaviourContext,
|
||||||
private val statesManager: StatesManager<T>,
|
private val statesManager: StatesManager<T>,
|
||||||
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>
|
private val handlers: List<BehaviourWithFSMStateHandlerHolder<*, T>>,
|
||||||
|
private val onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler()
|
||||||
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
) : BehaviourContext by behaviourContext, BehaviourContextWithFSM<T> {
|
||||||
private val updatesFlows = mutableMapOf<Any, Flow<Update>>()
|
private val updatesFlows = mutableMapOf<Any, DefaultBehaviourContextWithFSM<T>>()
|
||||||
private fun getContextUpdatesFlow(context: Any) = updatesFlows.getOrPut(context) {
|
private val additionalHandlers = mutableListOf<BehaviourWithFSMStateHandlerHolder<*, T>>()
|
||||||
allUpdatesFlow.accumulatorFlow(scope)
|
private var actualHandlersList = additionalHandlers + handlers
|
||||||
|
|
||||||
|
override suspend fun launchStateHandling(state: T, handlers: List<CheckableHandlerHolder<in T, T>>): T? {
|
||||||
|
return runCatchingSafely {
|
||||||
|
super.launchStateHandling(state, handlers)
|
||||||
|
}.getOrElse {
|
||||||
|
onStateHandlingErrorHandler(state, it)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun StatesMachine<in T>.handleState(state: T): T? = launchStateHandling(
|
private fun getSubContext(context: Any) = updatesFlows.getOrPut(context) {
|
||||||
state,
|
createSubContext()
|
||||||
allUpdatesFlow,
|
}
|
||||||
handlers
|
|
||||||
)
|
override suspend fun StatesMachine<in T>.handleState(state: T): T? {
|
||||||
|
return getSubContext(
|
||||||
|
state.context
|
||||||
|
).launchStateHandling(
|
||||||
|
state,
|
||||||
|
actualHandlersList
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun <I : T> add(kClass: KClass<I>, strict: Boolean, handler: BehaviourWithFSMStateHandler<I, T>) {
|
||||||
|
additionalHandlers.add(BehaviourWithFSMStateHandlerHolder(kClass, strict, handler))
|
||||||
|
actualHandlersList = additionalHandlers + handlers
|
||||||
|
}
|
||||||
|
|
||||||
override fun start(scope: CoroutineScope): Job = scope.launchSafelyWithoutExceptions {
|
override fun start(scope: CoroutineScope): Job = scope.launchSafelyWithoutExceptions {
|
||||||
val statePerformer: suspend (T) -> Unit = { state: T ->
|
val statePerformer: suspend (T) -> Unit = { state: T ->
|
||||||
val newState = launchStateHandling(state, getContextUpdatesFlow(state.context), handlers)
|
val newState = getSubContext(state.context).launchStateHandling(state, actualHandlersList)
|
||||||
if (newState != null) {
|
if (newState != null) {
|
||||||
statesManager.update(state, newState)
|
statesManager.update(state, newState)
|
||||||
} else {
|
} else {
|
||||||
@@ -94,6 +167,26 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
launch { statePerformer(it) }
|
launch { statePerformer(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
||||||
|
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
||||||
|
*
|
||||||
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
|
* @see BehaviourContextWithFSM.add
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
inline fun <reified I : T> onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, T>) = add(I::class, strict = false, handler)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
||||||
|
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
||||||
|
* requirements
|
||||||
|
*
|
||||||
|
* @see BehaviourWithFSMStateHandlerHolder
|
||||||
|
* @see BehaviourContextWithFSM.addStrict
|
||||||
|
*/
|
||||||
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
|
inline fun <reified I : T> strictlyOn(handler: BehaviourWithFSMStateHandler<I, T>) = addStrict(I::class, handler)
|
||||||
|
|
||||||
override suspend fun startChain(state: T) {
|
override suspend fun startChain(state: T) {
|
||||||
statesManager.startChain(state)
|
statesManager.startChain(state)
|
||||||
@@ -105,10 +198,28 @@ class DefaultBehaviourContextWithFSM<T : State>(
|
|||||||
broadcastChannelsSize: Int,
|
broadcastChannelsSize: Int,
|
||||||
onBufferOverflow: BufferOverflow,
|
onBufferOverflow: BufferOverflow,
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
upstreamUpdatesFlow: Flow<Update>?,
|
||||||
|
triggersHolder: TriggersHolder,
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||||
): BehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter),
|
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter),
|
||||||
handlers,
|
handlers,
|
||||||
statesManager
|
statesManager,
|
||||||
|
onStateHandlingErrorHandler
|
||||||
|
)
|
||||||
|
|
||||||
|
override fun copy(
|
||||||
|
bot: TelegramBot,
|
||||||
|
scope: CoroutineScope,
|
||||||
|
broadcastChannelsSize: Int,
|
||||||
|
onBufferOverflow: BufferOverflow,
|
||||||
|
upstreamUpdatesFlow: Flow<Update>?,
|
||||||
|
triggersHolder: TriggersHolder,
|
||||||
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T>,
|
||||||
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||||
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
|
behaviourContext.copy(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter),
|
||||||
|
handlers,
|
||||||
|
statesManager,
|
||||||
|
onStateHandlingErrorHandler
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,78 +6,13 @@ import dev.inmo.micro_utils.fsm.common.managers.DefaultStatesManager
|
|||||||
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
import dev.inmo.micro_utils.fsm.common.managers.InMemoryDefaultStatesManagerRepo
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlin.reflect.KClass
|
|
||||||
|
|
||||||
class BehaviourContextWithFSMBuilder<T : State> internal constructor(
|
@Deprecated("Will be removed soon")
|
||||||
private val resultBehaviourContext: BehaviourContextWithFSM<T>,
|
typealias BehaviourContextWithFSMBuilder<T> = BehaviourContextWithFSM<T>
|
||||||
private val handlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>>
|
|
||||||
) : BehaviourContextWithFSM<T> by resultBehaviourContext {
|
|
||||||
internal constructor(
|
|
||||||
baseBehaviourContext: BehaviourContext,
|
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
|
||||||
handlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf()
|
|
||||||
) : this(DefaultBehaviourContextWithFSM(baseBehaviourContext, statesManager, handlers), handlers)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
|
||||||
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see onStateOrSubstate
|
|
||||||
*/
|
|
||||||
fun <I : T> add(kClass: KClass<I>, handler: BehaviourWithFSMStateHandler<I, T>) {
|
|
||||||
handlers.add(BehaviourWithFSMStateHandlerHolder(kClass, false, handler))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
|
||||||
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
|
||||||
* requirements
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see strictlyOn
|
|
||||||
*/
|
|
||||||
fun <I : T> addStrict(kClass: KClass<I>, handler: BehaviourWithFSMStateHandler<I, T>) {
|
|
||||||
handlers.add(BehaviourWithFSMStateHandlerHolder(kClass, true, handler))
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add NON STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Non strict means that
|
|
||||||
* for input [State] will be used [KClass.isInstance] and any inheritor of [kClass] will pass this requirement
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSMBuilder.add
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : T> onStateOrSubstate(handler: BehaviourWithFSMStateHandler<I, T>) {
|
|
||||||
add(I::class, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add STRICT [handler] to list of available in future [BehaviourContextWithFSM]. Strict means that
|
|
||||||
* for input [State] will be used [State]::class == [kClass] and any [State] with exactly the same type will pass
|
|
||||||
* requirements
|
|
||||||
*
|
|
||||||
* @see BehaviourWithFSMStateHandlerHolder
|
|
||||||
* @see BehaviourContextWithFSMBuilder.addStrict
|
|
||||||
*/
|
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
|
||||||
inline fun <reified I : T> strictlyOn(handler: BehaviourWithFSMStateHandler<I, T>) {
|
|
||||||
addStrict(I::class, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns completed [resultBehaviourContext], [handlers] and [statesManager]
|
|
||||||
*/
|
|
||||||
internal fun build() = resultBehaviourContext
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot],
|
* Creates [BehaviourContextWithFSM] via creating of [DefaultBehaviourContext] with [this] as [TelegramBot],
|
||||||
@@ -94,17 +29,19 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
): BehaviourContextWithFSM<T> = BehaviourContextWithFSMBuilder(
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
DefaultBehaviourContext(
|
DefaultBehaviourContext(
|
||||||
this,
|
this,
|
||||||
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
||||||
upstreamUpdatesFlow = upstreamUpdatesFlow
|
upstreamUpdatesFlow = upstreamUpdatesFlow
|
||||||
),
|
),
|
||||||
|
presetHandlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers
|
onStateHandlingErrorHandler
|
||||||
).apply { block() }.build()
|
).apply { block() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
||||||
@@ -116,14 +53,16 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
): Pair<BehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
|
): Pair<DefaultBehaviourContextWithFSM<T>, Job> = buildBehaviourWithFSM(
|
||||||
upstreamUpdatesFlow,
|
upstreamUpdatesFlow,
|
||||||
scope,
|
scope,
|
||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
).run {
|
).run {
|
||||||
this to scope.launch {
|
this to scope.launch {
|
||||||
@@ -147,26 +86,27 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
* @see BehaviourContext
|
* @see BehaviourContext
|
||||||
* @see BehaviourContextWithFSM
|
* @see BehaviourContextWithFSM
|
||||||
* @see longPolling
|
* @see longPolling
|
||||||
* @see BehaviourContextWithFSMBuilder.strictlyOn
|
* @see BehaviourContextWithFSM.strictlyOn
|
||||||
* @see BehaviourContextWithFSMBuilder.onStateOrSubstate
|
* @see BehaviourContextWithFSM.onStateOrSubstate
|
||||||
*/
|
*/
|
||||||
@PreviewFeature
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
||||||
flowUpdatesFilter: FlowsUpdatesFilter,
|
flowUpdatesFilter: FlowsUpdatesFilter,
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
): BehaviourContextWithFSM<T> = BehaviourContextWithFSMBuilder(
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
|
): DefaultBehaviourContextWithFSM<T> = BehaviourContextWithFSM(
|
||||||
DefaultBehaviourContext(
|
DefaultBehaviourContext(
|
||||||
this,
|
this,
|
||||||
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
defaultExceptionsHandler ?.let { scope + ContextSafelyExceptionHandler(it) } ?: scope,
|
||||||
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow
|
upstreamUpdatesFlow = flowUpdatesFilter.allUpdatesFlow
|
||||||
),
|
),
|
||||||
|
presetHandlers,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers
|
onStateHandlingErrorHandler
|
||||||
).apply { block() }.build()
|
).apply { block() }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
* Use [buildBehaviourWithFSM] to create [BehaviourContextWithFSM] and launch getting of updates
|
||||||
@@ -176,16 +116,16 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSM(
|
|||||||
* @see buildBehaviourWithFSMAndStartLongPolling
|
* @see buildBehaviourWithFSMAndStartLongPolling
|
||||||
* @see BehaviourContext
|
* @see BehaviourContext
|
||||||
* @see longPolling
|
* @see longPolling
|
||||||
* @see BehaviourContextWithFSMBuilder.strictlyOn
|
* @see BehaviourContextWithFSM.strictlyOn
|
||||||
* @see BehaviourContextWithFSMBuilder.onStateOrSubstate
|
* @see BehaviourContextWithFSM.onStateOrSubstate
|
||||||
*/
|
*/
|
||||||
@PreviewFeature
|
|
||||||
suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
) = FlowsUpdatesFilter().let {
|
) = FlowsUpdatesFilter().let {
|
||||||
buildBehaviourWithFSM(
|
buildBehaviourWithFSM(
|
||||||
it,
|
it,
|
||||||
@@ -193,6 +133,7 @@ suspend fun <T : State> TelegramBot.buildBehaviourWithFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
).run {
|
).run {
|
||||||
start()
|
start()
|
||||||
|
|||||||
@@ -2,6 +2,12 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
import dev.inmo.micro_utils.fsm.common.*
|
||||||
|
|
||||||
fun interface BehaviourWithFSMStateHandler<I : O, O : State> {
|
fun interface BehaviourWithFSMStateHandler<I : O, O : State> : StatesHandler<I, O> {
|
||||||
suspend fun BehaviourContextWithFSM<in O>.handleState(state: I): O?
|
suspend fun BehaviourContextWithFSM<in O>.handleState(state: I): O?
|
||||||
|
|
||||||
|
override suspend fun StatesMachine<in O>.handleState(state: I): O? = if (this is BehaviourContextWithFSM) {
|
||||||
|
handleState(state)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.LinkedSupervisorScope
|
|
||||||
import dev.inmo.micro_utils.coroutines.weakLaunch
|
|
||||||
import dev.inmo.micro_utils.fsm.common.*
|
import dev.inmo.micro_utils.fsm.common.*
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import kotlinx.coroutines.flow.collect
|
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,31 +17,26 @@ class BehaviourWithFSMStateHandlerHolder<I : O, O : State>(
|
|||||||
private val inputKlass: KClass<I>,
|
private val inputKlass: KClass<I>,
|
||||||
private val strict: Boolean = false,
|
private val strict: Boolean = false,
|
||||||
private val delegateTo: BehaviourWithFSMStateHandler<I, O>
|
private val delegateTo: BehaviourWithFSMStateHandler<I, O>
|
||||||
) {
|
) : CheckableHandlerHolder<O, O>, BehaviourWithFSMStateHandler<O, O> {
|
||||||
/**
|
/**
|
||||||
* Check ability of [delegateTo] to handle this [state]
|
* Check ability of [delegateTo] to handle this [state]
|
||||||
*
|
*
|
||||||
* @return When [state]::class exactly equals to [inputKlass] will always return true. Otherwise when [strict]
|
* @return When [state]::class exactly equals to [inputKlass] will always return true. Otherwise when [strict]
|
||||||
* mode is disabled, will be used [KClass.isInstance] of [inputKlass] for checking
|
* mode is disabled, will be used [KClass.isInstance] of [inputKlass] for checking
|
||||||
*/
|
*/
|
||||||
fun checkHandleable(state: O): Boolean = state::class == inputKlass || (!strict && inputKlass.isInstance(state))
|
override suspend fun checkHandleable(state: O): Boolean = state::class == inputKlass || (!strict && inputKlass.isInstance(state))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handling of state :)
|
* Handling of state :)
|
||||||
*
|
|
||||||
* @param contextUpdatesFlow This [Flow] will be used as source of updates. By contract, this [Flow] must be common
|
|
||||||
* for all [State]s of incoming [state] [State.context] and for the whole chain inside of [BehaviourContextWithFSM]
|
|
||||||
*/
|
*/
|
||||||
suspend fun BehaviourContextWithFSM<in O>.handleState(
|
override suspend fun BehaviourContextWithFSM<in O>.handleState(state: O): O? = with(delegateTo) {
|
||||||
contextUpdatesFlow: Flow<Update>,
|
@Suppress("UNCHECKED_CAST")
|
||||||
state: O
|
handleState(state as I)
|
||||||
): O? {
|
}
|
||||||
val subscope = scope.LinkedSupervisorScope()
|
|
||||||
return with(copy(scope = subscope, upstreamUpdatesFlow = contextUpdatesFlow)) {
|
override suspend fun StatesMachine<in O>.handleState(state: O): O? = with(delegateTo) {
|
||||||
with(delegateTo) {
|
@Suppress("UNCHECKED_CAST")
|
||||||
handleState(state as I)
|
handleState(state as I)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder
|
||||||
|
|
||||||
|
typealias StateHandlingErrorHandler<T> = suspend (T, Throwable) -> T?
|
||||||
|
val DefaultStateHandlingErrorHandler: StateHandlingErrorHandler<*> = { _, _ -> null }
|
||||||
|
inline fun <T> defaultStateHandlingErrorHandler(): StateHandlingErrorHandler<T> = DefaultStateHandlingErrorHandler as StateHandlingErrorHandler<T>
|
||||||
@@ -37,11 +37,14 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
|||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
testServer: Boolean = false,
|
||||||
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
): TelegramBot = telegramBot(
|
): TelegramBot = telegramBot(
|
||||||
token,
|
token,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
|
testServer,
|
||||||
builder
|
builder
|
||||||
).apply {
|
).apply {
|
||||||
buildBehaviourWithFSMAndStartLongPolling(
|
buildBehaviourWithFSMAndStartLongPolling(
|
||||||
@@ -50,6 +53,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSM(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -72,12 +76,15 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
|||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
statesManager: StatesManager<T> = DefaultStatesManager(InMemoryDefaultStatesManagerRepo()),
|
||||||
presetHandlers: MutableList<BehaviourWithFSMStateHandlerHolder<*, T>> = mutableListOf(),
|
presetHandlers: List<BehaviourWithFSMStateHandlerHolder<*, T>> = listOf(),
|
||||||
block: CustomBehaviourContextReceiver<BehaviourContextWithFSMBuilder<T>, Unit>
|
testServer: Boolean = false,
|
||||||
|
onStateHandlingErrorHandler: StateHandlingErrorHandler<T> = defaultStateHandlingErrorHandler(),
|
||||||
|
block: CustomBehaviourContextReceiver<DefaultBehaviourContextWithFSM<T>, Unit>
|
||||||
): Pair<TelegramBot, Job> {
|
): Pair<TelegramBot, Job> {
|
||||||
return telegramBot(
|
return telegramBot(
|
||||||
token,
|
token,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
|
testServer,
|
||||||
builder
|
builder
|
||||||
).let {
|
).let {
|
||||||
it to it.buildBehaviourWithFSMAndStartLongPolling (
|
it to it.buildBehaviourWithFSMAndStartLongPolling (
|
||||||
@@ -85,6 +92,7 @@ suspend fun <T : State> telegramBotWithBehaviourAndFSMAndStartLongPolling(
|
|||||||
defaultExceptionsHandler,
|
defaultExceptionsHandler,
|
||||||
statesManager,
|
statesManager,
|
||||||
presetHandlers,
|
presetHandlers,
|
||||||
|
onStateHandlingErrorHandler,
|
||||||
block
|
block
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.longPolling
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||||
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
import dev.inmo.tgbotapi.updateshandlers.FlowsUpdatesFilter
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.plus
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is used in [buildBehaviour] extensions to provide default [CoroutineScope] and allow to avoid all
|
* This function is used in [buildBehaviour] extensions to provide default [CoroutineScope] and allow to avoid all
|
||||||
@@ -25,24 +24,23 @@ expect var defaultCoroutineScopeProvider: () -> CoroutineScope
|
|||||||
* @see [BehaviourContext]
|
* @see [BehaviourContext]
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
* @see startGettingOfUpdatesByLongPolling
|
||||||
*/
|
*/
|
||||||
@PreviewFeature
|
|
||||||
suspend fun TelegramBot.buildBehaviour(
|
suspend fun TelegramBot.buildBehaviour(
|
||||||
flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
flowUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
block: BehaviourContextReceiver<Unit>
|
block: BehaviourContextReceiver<Unit>
|
||||||
) {
|
): BehaviourContext = BehaviourContext(
|
||||||
BehaviourContext(
|
this,
|
||||||
this,
|
scope.let {
|
||||||
scope.let {
|
if (defaultExceptionsHandler == null) {
|
||||||
if (defaultExceptionsHandler == null) {
|
it
|
||||||
it
|
} else {
|
||||||
} else {
|
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
||||||
it + ContextSafelyExceptionHandler(defaultExceptionsHandler)
|
}
|
||||||
}
|
},
|
||||||
},
|
flowUpdatesFilter
|
||||||
flowUpdatesFilter
|
).apply {
|
||||||
).block()
|
block()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -53,20 +51,18 @@ suspend fun TelegramBot.buildBehaviour(
|
|||||||
* @see BehaviourContext
|
* @see BehaviourContext
|
||||||
* @see startGettingOfUpdatesByLongPolling
|
* @see startGettingOfUpdatesByLongPolling
|
||||||
*/
|
*/
|
||||||
@PreviewFeature
|
|
||||||
suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
suspend fun TelegramBot.buildBehaviourWithLongPolling(
|
||||||
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
scope: CoroutineScope = defaultCoroutineScopeProvider(),
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
block: BehaviourContextReceiver<Unit>
|
block: BehaviourContextReceiver<Unit>
|
||||||
) = FlowsUpdatesFilter().let {
|
): Job {
|
||||||
buildBehaviour(
|
val behaviourContext = buildBehaviour(
|
||||||
it,
|
scope = scope,
|
||||||
scope,
|
defaultExceptionsHandler = defaultExceptionsHandler,
|
||||||
defaultExceptionsHandler,
|
block = block
|
||||||
block
|
|
||||||
)
|
)
|
||||||
longPolling(
|
return longPolling(
|
||||||
it,
|
behaviourContext,
|
||||||
scope = scope
|
scope = behaviourContext
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder
|
|||||||
|
|
||||||
import dev.inmo.micro_utils.coroutines.*
|
import dev.inmo.micro_utils.coroutines.*
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar.TriggersHolder
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.updateshandlers.*
|
import dev.inmo.tgbotapi.updateshandlers.*
|
||||||
import dev.inmo.tgbotapi.utils.RiskFeature
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
import kotlinx.coroutines.channels.BufferOverflow
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
||||||
@@ -26,7 +26,7 @@ internal inline fun <BC, T, I1, I2> CustomBehaviourContextAndTwoTypesReceiver<BC
|
|||||||
): CustomBehaviourContextAndTypeReceiver<BC, T, I2> = { invoke(this, i1, it) }
|
): CustomBehaviourContextAndTypeReceiver<BC, T, I2> = { invoke(this, i1, it) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class contains all necessary tools for work with bots and especially for [buildBehaviour]
|
* This class contains all necessary tools for work with bots and especially [buildBehaviour]
|
||||||
*
|
*
|
||||||
* @see DefaultBehaviourContext
|
* @see DefaultBehaviourContext
|
||||||
*/
|
*/
|
||||||
@@ -47,12 +47,15 @@ interface BehaviourContext : FlowsUpdatesFilter, TelegramBot, CoroutineScope {
|
|||||||
val flowsUpdatesFilter: FlowsUpdatesFilter
|
val flowsUpdatesFilter: FlowsUpdatesFilter
|
||||||
get() = this
|
get() = this
|
||||||
|
|
||||||
|
val triggersHolder: TriggersHolder
|
||||||
|
|
||||||
fun copy(
|
fun copy(
|
||||||
bot: TelegramBot = this.bot,
|
bot: TelegramBot = this.bot,
|
||||||
scope: CoroutineScope = this.scope,
|
scope: CoroutineScope = this.scope,
|
||||||
broadcastChannelsSize: Int = 100,
|
broadcastChannelsSize: Int = 100,
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||||
upstreamUpdatesFlow: Flow<Update>? = null,
|
upstreamUpdatesFlow: Flow<Update>? = null,
|
||||||
|
triggersHolder: TriggersHolder = TriggersHolder(),
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||||
): BehaviourContext
|
): BehaviourContext
|
||||||
}
|
}
|
||||||
@@ -63,6 +66,7 @@ class DefaultBehaviourContext(
|
|||||||
broadcastChannelsSize: Int = 100,
|
broadcastChannelsSize: Int = 100,
|
||||||
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
onBufferOverflow: BufferOverflow = BufferOverflow.SUSPEND,
|
||||||
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
private val upstreamUpdatesFlow: Flow<Update>? = null,
|
||||||
|
override val triggersHolder: TriggersHolder = TriggersHolder(),
|
||||||
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
private val updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>? = null
|
||||||
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
) : AbstractFlowsUpdatesFilter(), TelegramBot by bot, CoroutineScope by scope, BehaviourContext {
|
||||||
|
|
||||||
@@ -80,7 +84,7 @@ class DefaultBehaviourContext(
|
|||||||
} else {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
}
|
}.accumulatorFlow(scope)
|
||||||
override val asUpdateReceiver: UpdateReceiver<Update> = additionalUpdatesSharedFlow::emit
|
override val asUpdateReceiver: UpdateReceiver<Update> = additionalUpdatesSharedFlow::emit
|
||||||
|
|
||||||
override fun copy(
|
override fun copy(
|
||||||
@@ -89,34 +93,32 @@ class DefaultBehaviourContext(
|
|||||||
broadcastChannelsSize: Int,
|
broadcastChannelsSize: Int,
|
||||||
onBufferOverflow: BufferOverflow,
|
onBufferOverflow: BufferOverflow,
|
||||||
upstreamUpdatesFlow: Flow<Update>?,
|
upstreamUpdatesFlow: Flow<Update>?,
|
||||||
|
triggersHolder: TriggersHolder,
|
||||||
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
updatesFilter: BehaviourContextAndTypeReceiver<Boolean, Update>?
|
||||||
): BehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, updatesFilter)
|
): DefaultBehaviourContext = DefaultBehaviourContext(bot, scope, broadcastChannelsSize, onBufferOverflow, upstreamUpdatesFlow, triggersHolder, updatesFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BehaviourContext(
|
fun BehaviourContext(
|
||||||
bot: TelegramBot,
|
bot: TelegramBot,
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter()
|
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
||||||
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow)
|
triggersHolder: TriggersHolder = TriggersHolder(),
|
||||||
|
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder)
|
||||||
|
|
||||||
inline fun <T> BehaviourContext(
|
inline fun <T> BehaviourContext(
|
||||||
bot: TelegramBot,
|
bot: TelegramBot,
|
||||||
scope: CoroutineScope,
|
scope: CoroutineScope,
|
||||||
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
flowsUpdatesFilter: FlowsUpdatesFilter = FlowsUpdatesFilter(),
|
||||||
|
triggersHolder: TriggersHolder = TriggersHolder(),
|
||||||
crossinline block: BehaviourContext.() -> T
|
crossinline block: BehaviourContext.() -> T
|
||||||
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow).run(block)
|
) = DefaultBehaviourContext(bot, scope, upstreamUpdatesFlow = flowsUpdatesFilter.allUpdatesFlow, triggersHolder = triggersHolder).run(block)
|
||||||
|
|
||||||
/**
|
fun <BC : BehaviourContext> BC.createSubContext(
|
||||||
* Creates new one [BehaviourContext], adding subsequent [FlowsUpdatesFilter] in case [updatesFilter] is provided and
|
|
||||||
* [CoroutineScope] as new [BehaviourContext.scope]
|
|
||||||
*/
|
|
||||||
suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithUpdatesFilter(
|
|
||||||
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
|
||||||
stopOnCompletion: Boolean = true,
|
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||||
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||||
): T = copy(
|
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||||
|
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>? = null,
|
||||||
|
) = copy(
|
||||||
scope = scope,
|
scope = scope,
|
||||||
updatesFilter = updatesFilter ?.let { _ ->
|
updatesFilter = updatesFilter ?.let { _ ->
|
||||||
{
|
{
|
||||||
@@ -125,19 +127,90 @@ suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithUpdatesFilter(
|
|||||||
} ?: true
|
} ?: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
upstreamUpdatesFlow = updatesUpstreamFlow
|
upstreamUpdatesFlow = updatesUpstreamFlow,
|
||||||
).run {
|
triggersHolder = triggersHolder
|
||||||
withContext(coroutineContext) {
|
) as BC
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch [behaviourContextReceiver] in context of [this] as [BehaviourContext] and as [kotlin.coroutines.CoroutineContext]
|
||||||
|
*
|
||||||
|
* @param stopOnCompletion ___FALSE BY DEFAULT___. Will stop [this] in case if passed true
|
||||||
|
*/
|
||||||
|
suspend fun <T, BC : BehaviourContext> BC.doInContext(
|
||||||
|
stopOnCompletion: Boolean = false,
|
||||||
|
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||||
|
): T {
|
||||||
|
return withContext(coroutineContext) {
|
||||||
behaviourContextReceiver().also { if (stopOnCompletion) stop() }
|
behaviourContextReceiver().also { if (stopOnCompletion) stop() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
||||||
|
* using [doInContext]
|
||||||
|
*
|
||||||
|
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
||||||
|
*/
|
||||||
|
suspend fun <T, BC : BehaviourContext> BC.createSubContextAndDoWithUpdatesFilter(
|
||||||
|
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||||
|
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||||
|
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||||
|
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>? = null,
|
||||||
|
stopOnCompletion: Boolean = true,
|
||||||
|
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||||
|
): T {
|
||||||
|
return createSubContext(
|
||||||
|
scope,
|
||||||
|
triggersHolder,
|
||||||
|
updatesUpstreamFlow,
|
||||||
|
updatesFilter
|
||||||
|
).doInContext(
|
||||||
|
stopOnCompletion,
|
||||||
|
behaviourContextReceiver
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates new one [BehaviourContext] using [createSubContext] and launches [behaviourContextReceiver] in a new context
|
||||||
|
* using [doInContext]
|
||||||
|
*
|
||||||
|
* @param stopOnCompletion ___TRUE BY DEFAULT___
|
||||||
|
*/
|
||||||
|
@Deprecated("Renamed", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter"))
|
||||||
|
suspend fun <T, BC : BehaviourContext> BC.doInSubContextWithUpdatesFilter(
|
||||||
|
updatesFilter: CustomBehaviourContextAndTypeReceiver<BC, Boolean, Update>?,
|
||||||
|
stopOnCompletion: Boolean = true,
|
||||||
|
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||||
|
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||||
|
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||||
|
behaviourContextReceiver: CustomBehaviourContextReceiver<BC, T>
|
||||||
|
): T {
|
||||||
|
return createSubContext(
|
||||||
|
scope,
|
||||||
|
triggersHolder,
|
||||||
|
updatesUpstreamFlow,
|
||||||
|
updatesFilter
|
||||||
|
).doInContext(
|
||||||
|
stopOnCompletion,
|
||||||
|
behaviourContextReceiver
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Deprecated("Redundant", ReplaceWith("createSubContextAndDoWithUpdatesFilter", "dev.inmo.tgbotapi.extensions.behaviour_builder.createSubContextAndDoWithUpdatesFilter"))
|
||||||
suspend fun <T> BehaviourContext.doInSubContext(
|
suspend fun <T> BehaviourContext.doInSubContext(
|
||||||
stopOnCompletion: Boolean = true,
|
stopOnCompletion: Boolean = true,
|
||||||
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
updatesUpstreamFlow: Flow<Update> = allUpdatesFlow,
|
||||||
scope: CoroutineScope = LinkedSupervisorScope(),
|
scope: CoroutineScope = LinkedSupervisorScope(),
|
||||||
|
triggersHolder: TriggersHolder = this.triggersHolder,
|
||||||
behaviourContextReceiver: BehaviourContextReceiver<T>
|
behaviourContextReceiver: BehaviourContextReceiver<T>
|
||||||
) = doInSubContextWithUpdatesFilter(updatesFilter = null, stopOnCompletion, updatesUpstreamFlow, scope, behaviourContextReceiver)
|
) = createSubContextAndDoWithUpdatesFilter(
|
||||||
|
scope,
|
||||||
|
triggersHolder,
|
||||||
|
updatesUpstreamFlow,
|
||||||
|
updatesFilter = null,
|
||||||
|
stopOnCompletion,
|
||||||
|
behaviourContextReceiver
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will cancel ALL subsequent contexts, expectations and waiters
|
* This method will cancel ALL subsequent contexts, expectations and waiters
|
||||||
|
|||||||
@@ -30,10 +30,12 @@ suspend fun telegramBotWithBehaviour(
|
|||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
|
testServer: Boolean = false,
|
||||||
block: BehaviourContextReceiver<Unit>
|
block: BehaviourContextReceiver<Unit>
|
||||||
): TelegramBot = telegramBot(
|
): TelegramBot = telegramBot(
|
||||||
token,
|
token,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
|
testServer,
|
||||||
builder
|
builder
|
||||||
).apply {
|
).apply {
|
||||||
buildBehaviour(
|
buildBehaviour(
|
||||||
@@ -63,11 +65,13 @@ suspend fun telegramBotWithBehaviourAndLongPolling(
|
|||||||
apiUrl: String = telegramBotAPIDefaultUrl,
|
apiUrl: String = telegramBotAPIDefaultUrl,
|
||||||
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
builder: KtorRequestsExecutorBuilder.() -> Unit = {},
|
||||||
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
defaultExceptionsHandler: ExceptionHandler<Unit>? = null,
|
||||||
|
testServer: Boolean = false,
|
||||||
block: BehaviourContextReceiver<Unit>
|
block: BehaviourContextReceiver<Unit>
|
||||||
): Pair<TelegramBot, Job> {
|
): Pair<TelegramBot, Job> {
|
||||||
return telegramBot(
|
return telegramBot(
|
||||||
token,
|
token,
|
||||||
apiUrl,
|
apiUrl,
|
||||||
|
testServer,
|
||||||
builder
|
builder
|
||||||
).let {
|
).let {
|
||||||
it to it.buildBehaviourWithLongPolling(
|
it to it.buildBehaviourWithLongPolling(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
typealias ChosenInlineResultMapper<T> = suspend T.() -> T?
|
typealias ChosenInlineResultMapper<T> = suspend T.() -> T?
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import dev.inmo.tgbotapi.extensions.utils.withContent
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|||||||
@@ -9,14 +9,12 @@ import dev.inmo.tgbotapi.extensions.utils.withContent
|
|||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
@@ -38,7 +36,7 @@ internal suspend fun <O : MessageContent> BehaviourContext.waitCommonMessage(
|
|||||||
val messages = when (it) {
|
val messages = when (it) {
|
||||||
is SentMediaGroupUpdate -> {
|
is SentMediaGroupUpdate -> {
|
||||||
if (includeMediaGroups) {
|
if (includeMediaGroups) {
|
||||||
it.data.map { it as CommonMessage<MessageContent> }
|
it.data
|
||||||
} else {
|
} else {
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
@@ -47,7 +45,8 @@ internal suspend fun <O : MessageContent> BehaviourContext.waitCommonMessage(
|
|||||||
else -> return@expectFlow emptyList()
|
else -> return@expectFlow emptyList()
|
||||||
}
|
}
|
||||||
messages.mapNotNull { message ->
|
messages.mapNotNull { message ->
|
||||||
val asCommonMessage = message as CommonMessage<MessageContent>
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
val asCommonMessage = message as? CommonMessage<MessageContent> ?: return@mapNotNull null
|
||||||
if (filter == null || filter(asCommonMessage)) {
|
if (filter == null || filter(asCommonMessage)) {
|
||||||
asCommonMessage.mapper()
|
asCommonMessage.mapper()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ import dev.inmo.tgbotapi.requests.abstracts.Request
|
|||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,17 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
|||||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.MediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.VisualMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
import kotlinx.coroutines.flow.take
|
import kotlinx.coroutines.flow.take
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
typealias MediaGroupFilter<T> = suspend List<MediaGroupMessage<T>>.() -> Boolean
|
typealias MediaGroupFilter<T> = suspend List<MediaGroupMessage<T>>.() -> Boolean
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
internal suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupWaiter(
|
internal suspend inline fun <reified T : MediaGroupContent> BehaviourContext.buildMediaGroupWaiter(
|
||||||
count: Int = 1,
|
count: Int = 1,
|
||||||
initRequest: Request<*>? = null,
|
initRequest: Request<*>? = null,
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer?
|
typealias PollAnswerMapper = suspend PollAnswer.() -> PollAnswer?
|
||||||
@@ -45,14 +45,10 @@ private suspend inline fun BehaviourContext.waitPollAnswers(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
if (this is PollAnswer) {
|
if (mapper == null) {
|
||||||
if (mapper == null) {
|
this
|
||||||
this
|
|
||||||
} else {
|
|
||||||
mapper(this)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
null
|
mapper(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.*
|
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|||||||
@@ -3,10 +3,8 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.expectations
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
|
||||||
import dev.inmo.tgbotapi.requests.abstracts.Request
|
import dev.inmo.tgbotapi.requests.abstracts.Request
|
||||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
|
||||||
import kotlinx.coroutines.flow.toList
|
import kotlinx.coroutines.flow.toList
|
||||||
|
|
||||||
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
|
typealias PreCheckoutQueryMapper = suspend PreCheckoutQuery.() -> PreCheckoutQuery?
|
||||||
|
|||||||
@@ -1,16 +1,14 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.filters
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.CommonMessageFilter
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.MessageContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow only messages which are not [MediaGroupMessage]
|
* Allow only messages which are not [MediaGroupMessage]
|
||||||
*/
|
*/
|
||||||
val MessageFilterExcludingMediaGroups: BehaviourContextAndTwoTypesReceiver<Boolean, CommonMessage<*>, Update> = { message, update ->
|
val MessageFilterExcludingMediaGroups: BehaviourContextAndTwoTypesReceiver<Boolean, CommonMessage<*>, Update> = { _, update ->
|
||||||
update !is MediaGroupMessage<*>
|
update !is MediaGroupMessage<*>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asCallbackQueryUpdate
|
||||||
import dev.inmo.tgbotapi.types.queries.callback.*
|
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> BC.onCallbackQuery(
|
internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> BC.onCallbackQuery(
|
||||||
initialFilter: SimpleFilter<T>? = null,
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
@@ -20,6 +24,48 @@ internal suspend inline fun <BC : BehaviourContext, reified T : CallbackQuery> B
|
|||||||
(it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
(it.asCallbackQueryUpdate() ?.data as? T) ?.let(::listOfNotNull)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
internal suspend inline fun <BC : BehaviourContext, reified T : DataCallbackQuery> BC.onDataCallbackQueryCounted(
|
||||||
|
initialFilter: SimpleFilter<T>? = null,
|
||||||
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, T, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in T, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, T>
|
||||||
|
): Job {
|
||||||
|
val newInitialFilter = SimpleFilter<DataCallbackQuery> {
|
||||||
|
it is T && initialFilter ?.invoke(it) ?: true
|
||||||
|
}::invoke
|
||||||
|
return runCatchingSafely {
|
||||||
|
onCallbackQuery (
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
}.onFailure {
|
||||||
|
triggersHolder.handleableCallbackQueriesDataHolder.unregisterHandleable(newInitialFilter)
|
||||||
|
}.onSuccess {
|
||||||
|
triggersHolder.handleableCallbackQueriesDataHolder.registerHandleable(newInitialFilter)
|
||||||
|
it.invokeOnCompletion {
|
||||||
|
runCatching {
|
||||||
|
launchSafelyWithoutExceptions {
|
||||||
|
triggersHolder.handleableCallbackQueriesDataHolder.unregisterHandleable(newInitialFilter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.getOrThrow()
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
@@ -37,7 +83,63 @@ suspend fun <BC : BehaviourContext> BC.onDataCallbackQuery(
|
|||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
||||||
) = onCallbackQuery(
|
) = onDataCallbackQueryCounted(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataRegex Will be used with [initialFilter] as [initialFilter] for upstream [onDataCallbackQuery] to filter
|
||||||
|
* [DataCallbackQuery] with [DataCallbackQuery.data] [String.matches] to [dataRegex]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onDataCallbackQuery(
|
||||||
|
dataRegex: Regex,
|
||||||
|
initialFilter: SimpleFilter<DataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
||||||
|
) = onDataCallbackQuery(
|
||||||
|
initialFilter = initialFilter + {
|
||||||
|
it.data.matches(dataRegex)
|
||||||
|
},
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data Will be converted to [Regex] via its constructor and pass it to upstream [onDataCallbackQuery]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onDataCallbackQuery(
|
||||||
|
data: String,
|
||||||
|
initialFilter: SimpleFilter<DataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
||||||
|
) = onDataCallbackQuery(
|
||||||
|
Regex(data),
|
||||||
initialFilter,
|
initialFilter,
|
||||||
subcontextUpdatesFilter,
|
subcontextUpdatesFilter,
|
||||||
markerFactory,
|
markerFactory,
|
||||||
@@ -109,7 +211,63 @@ suspend fun <BC : BehaviourContext> BC.onInlineMessageIdDataCallbackQuery(
|
|||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InlineMessageIdDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InlineMessageIdDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||||
) = onCallbackQuery(
|
) = onDataCallbackQueryCounted(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataRegex Will be used with [initialFilter] as [initialFilter] for upstream [onInlineMessageIdDataCallbackQuery]
|
||||||
|
* to filter [InlineMessageIdDataCallbackQuery] with [InlineMessageIdDataCallbackQuery.data] [String.matches] to [dataRegex]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onInlineMessageIdDataCallbackQuery(
|
||||||
|
dataRegex: Regex,
|
||||||
|
initialFilter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InlineMessageIdDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||||
|
) = onInlineMessageIdDataCallbackQuery(
|
||||||
|
initialFilter = initialFilter + {
|
||||||
|
it.data.matches(dataRegex)
|
||||||
|
},
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data Will be converted to [Regex] via its constructor and pass it to upstream [onInlineMessageIdDataCallbackQuery]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onInlineMessageIdDataCallbackQuery(
|
||||||
|
data: String,
|
||||||
|
initialFilter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InlineMessageIdDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||||
|
) = onInlineMessageIdDataCallbackQuery(
|
||||||
|
Regex(data),
|
||||||
initialFilter,
|
initialFilter,
|
||||||
subcontextUpdatesFilter,
|
subcontextUpdatesFilter,
|
||||||
markerFactory,
|
markerFactory,
|
||||||
@@ -181,7 +339,63 @@ suspend fun <BC : BehaviourContext> BC.onMessageDataCallbackQuery(
|
|||||||
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MessageDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MessageDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
||||||
) = onCallbackQuery(
|
) = onDataCallbackQueryCounted(
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param dataRegex Will be used with [initialFilter] as [initialFilter] for upstream [onMessageDataCallbackQuery] to filter
|
||||||
|
* [MessageDataCallbackQuery] with [MessageDataCallbackQuery.data] [String.matches] to [dataRegex]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onMessageDataCallbackQuery(
|
||||||
|
dataRegex: Regex,
|
||||||
|
initialFilter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MessageDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
||||||
|
) = onMessageDataCallbackQuery(
|
||||||
|
initialFilter = initialFilter + {
|
||||||
|
it.data.matches(dataRegex)
|
||||||
|
},
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param data Will be converted to [Regex] via its constructor and pass it to upstream [onMessageDataCallbackQuery]
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onMessageDataCallbackQuery(
|
||||||
|
data: String,
|
||||||
|
initialFilter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MessageDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
||||||
|
) = onMessageDataCallbackQuery(
|
||||||
|
Regex(data),
|
||||||
initialFilter,
|
initialFilter,
|
||||||
subcontextUpdatesFilter,
|
subcontextUpdatesFilter,
|
||||||
markerFactory,
|
markerFactory,
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserCallbackQueryMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.types.queries.callback.*
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onUnhandledDataCallbackQuery(
|
||||||
|
initialFilter: SimpleFilter<DataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, DataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in DataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, DataCallbackQuery>
|
||||||
|
) = onCallbackQuery (
|
||||||
|
initialFilter * !SimpleFilter<MessageDataCallbackQuery> { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) },
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onUnhandledInlineMessageIdDataCallbackQuery(
|
||||||
|
initialFilter: SimpleFilter<InlineMessageIdDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, InlineMessageIdDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in InlineMessageIdDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, InlineMessageIdDataCallbackQuery>
|
||||||
|
) = onCallbackQuery (
|
||||||
|
initialFilter * !SimpleFilter<MessageDataCallbackQuery> { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) },
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param initialFilter This filter will be called to remove unnecessary data BEFORE [scenarioReceiver] call
|
||||||
|
* @param subcontextUpdatesFilter This filter will be applied to each update inside of [scenarioReceiver]. For example,
|
||||||
|
* this filter will be used if you will call [dev.inmo.tgbotapi.extensions.behaviour_builder.expectations.waitContentMessage].
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextAndTwoTypesReceiver] function to create your own.
|
||||||
|
* Use [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.plus] or [dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times]
|
||||||
|
* to combinate several filters
|
||||||
|
* @param [markerFactory] Will be used to identify different "stream". [scenarioReceiver] will be called synchronously
|
||||||
|
* in one "stream". Output of [markerFactory] will be used as a key for "stream"
|
||||||
|
* @param scenarioReceiver Main callback which will be used to handle incoming data if [initialFilter] will pass that
|
||||||
|
* data
|
||||||
|
*/
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onUnhandledMessageDataCallbackQuery(
|
||||||
|
initialFilter: SimpleFilter<MessageDataCallbackQuery>? = null,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, MessageDataCallbackQuery, Update>? = CallbackQueryFilterByUser,
|
||||||
|
markerFactory: MarkerFactory<in MessageDataCallbackQuery, Any> = ByUserCallbackQueryMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, MessageDataCallbackQuery>
|
||||||
|
) = onCallbackQuery(
|
||||||
|
initialFilter * !SimpleFilter<MessageDataCallbackQuery> { triggersHolder.handleableCallbackQueriesDataHolder.isHandled(it) },
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ChatJoinRequestFilterByChat
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatChatJoinRequestMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asChatJoinRequestUpdate
|
||||||
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
import dev.inmo.tgbotapi.types.chat.ChatJoinRequest
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserIdChosenInlineResultMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asChosenInlineResultUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
import dev.inmo.tgbotapi.types.InlineQueries.ChosenInlineResult.*
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : ChosenInlineResult> BC.onChosenInlineResultBase(
|
internal suspend inline fun <BC : BehaviourContext, reified T : ChosenInlineResult> BC.onChosenInlineResultBase(
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
|
import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
||||||
@@ -15,8 +17,7 @@ import dev.inmo.tgbotapi.types.message.content.TextContent
|
|||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
|
|
||||||
|
internal suspend fun <BC : BehaviourContext> BC.commandUncounted(
|
||||||
suspend fun <BC : BehaviourContext> BC.command(
|
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
@@ -43,6 +44,35 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
scenarioReceiver
|
scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
|
suspend fun <BC : BehaviourContext> BC.command(
|
||||||
|
commandRegex: Regex,
|
||||||
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
|
): Job = runCatchingSafely {
|
||||||
|
commandUncounted(
|
||||||
|
commandRegex,
|
||||||
|
requireOnlyCommandInMessage,
|
||||||
|
initialFilter,
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
}.onFailure {
|
||||||
|
triggersHolder.handleableCommandsHolder.unregisterHandleable(commandRegex)
|
||||||
|
}.onSuccess {
|
||||||
|
triggersHolder.handleableCommandsHolder.registerHandleable(commandRegex)
|
||||||
|
it.invokeOnCompletion {
|
||||||
|
runCatching {
|
||||||
|
launchSafelyWithoutExceptions {
|
||||||
|
triggersHolder.handleableCommandsHolder.unregisterHandleable(commandRegex)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.getOrThrow()
|
||||||
|
|
||||||
suspend fun <BC : BehaviourContext> BC.command(
|
suspend fun <BC : BehaviourContext> BC.command(
|
||||||
command: String,
|
command: String,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
@@ -52,22 +82,22 @@ suspend fun <BC : BehaviourContext> BC.command(
|
|||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
) = command(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = command(commandRegex, requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommand(
|
suspend fun <BC : BehaviourContext> BC.onCommand(
|
||||||
command: String,
|
command: String,
|
||||||
requireOnlyCommandInMessage: Boolean = true,
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommand(command.toRegex(), requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
||||||
@@ -104,18 +134,18 @@ suspend fun <BC : BehaviourContext> BC.commandWithArgs(
|
|||||||
scenarioReceiver = scenarioReceiver
|
scenarioReceiver = scenarioReceiver
|
||||||
)
|
)
|
||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
commandRegex: Regex,
|
commandRegex: Regex,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||||
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = commandWithArgs(commandRegex, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
suspend inline fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
suspend fun <BC : BehaviourContext> BC.onCommandWithArgs(
|
||||||
command: String,
|
command: String,
|
||||||
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Array<String>>
|
||||||
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
): Job = onCommandWithArgs(command.toRegex(), initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
@file:Suppress("unused")
|
||||||
|
|
||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.MessageFilterByChat
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByChatMessageMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.times
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.asBotCommandTextSource
|
||||||
|
import dev.inmo.tgbotapi.extensions.utils.extensions.parseCommandsWithParams
|
||||||
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.TextContent
|
||||||
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
import kotlinx.coroutines.Job
|
||||||
|
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.unhandledCommand(
|
||||||
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
|
): Job = onText(
|
||||||
|
CommonMessageFilter<TextContent> { message ->
|
||||||
|
val content = message.content
|
||||||
|
val textSources = content.textSources
|
||||||
|
val sizeRequirement = if (requireOnlyCommandInMessage) {
|
||||||
|
textSources.size == 1
|
||||||
|
} else {
|
||||||
|
true
|
||||||
|
}
|
||||||
|
sizeRequirement && textSources.any {
|
||||||
|
val command = it.asBotCommandTextSource() ?.command ?: return@any false
|
||||||
|
!triggersHolder.handleableCommandsHolder.isHandled(command)
|
||||||
|
}
|
||||||
|
}.let {
|
||||||
|
initialFilter ?.times(it) ?: it
|
||||||
|
},
|
||||||
|
subcontextUpdatesFilter,
|
||||||
|
markerFactory,
|
||||||
|
scenarioReceiver
|
||||||
|
)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onUnhandledCommand(
|
||||||
|
requireOnlyCommandInMessage: Boolean = true,
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, CommonMessage<TextContent>>
|
||||||
|
): Job = unhandledCommand(requireOnlyCommandInMessage, initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.unhandledCommandWithArgs(
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Map<String, Array<String>>>
|
||||||
|
) = onUnhandledCommand(
|
||||||
|
requireOnlyCommandInMessage = false,
|
||||||
|
initialFilter = initialFilter,
|
||||||
|
subcontextUpdatesFilter = subcontextUpdatesFilter,
|
||||||
|
markerFactory = markerFactory
|
||||||
|
) {
|
||||||
|
val args = it.parseCommandsWithParams().let { commandsWithArgs ->
|
||||||
|
commandsWithArgs
|
||||||
|
}
|
||||||
|
scenarioReceiver(it, args)
|
||||||
|
}
|
||||||
|
|
||||||
|
@PreviewFeature
|
||||||
|
suspend fun <BC : BehaviourContext> BC.onUnhandledCommandWithArgs(
|
||||||
|
initialFilter: CommonMessageFilter<TextContent>? = CommonMessageFilterExcludeMediaGroups,
|
||||||
|
subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<TextContent>, Update> = MessageFilterByChat,
|
||||||
|
markerFactory: MarkerFactory<in CommonMessage<TextContent>, Any> = ByChatMessageMarkerFactory,
|
||||||
|
scenarioReceiver: CustomBehaviourContextAndTwoTypesReceiver<BC, Unit, CommonMessage<TextContent>, Map<String, Array<String>>>
|
||||||
|
): Job = unhandledCommandWithArgs(initialFilter, subcontextUpdatesFilter, markerFactory, scenarioReceiver)
|
||||||
@@ -12,12 +12,10 @@ import dev.inmo.tgbotapi.extensions.utils.whenCommonMessage
|
|||||||
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.update.media_group.SentMediaGroupUpdate
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.MediaGroupUpdates.SentMediaGroupUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseSentMessageUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
|
|||||||
@@ -26,15 +26,16 @@ import dev.inmo.tgbotapi.types.files.TelegramMediaFile
|
|||||||
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.CommonMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
import dev.inmo.tgbotapi.types.message.content.abstracts.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.AudioMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.DocumentMediaGroupContent
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
import dev.inmo.tgbotapi.types.message.content.InvoiceContent
|
||||||
import dev.inmo.tgbotapi.types.message.payments.InvoiceContent
|
import dev.inmo.tgbotapi.types.message.content.MediaCollectionContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.MediaContent
|
||||||
|
import dev.inmo.tgbotapi.types.message.content.MessageContent
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
import dev.inmo.tgbotapi.types.update.abstracts.BaseEditMessageUpdate
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
|
||||||
@PreviewFeature
|
|
||||||
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onEditedContent(
|
internal suspend inline fun <BC : BehaviourContext, reified T : MessageContent> BC.onEditedContent(
|
||||||
initialFilter: CommonMessageFilter<T>? = null,
|
initialFilter: CommonMessageFilter<T>? = null,
|
||||||
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
noinline subcontextUpdatesFilter: CustomBehaviourContextAndTwoTypesReceiver<BC, Boolean, CommonMessage<T>, Update>? = MessageFilterByChat,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ internal suspend inline fun <BC : BehaviourContext, reified T : ChatEvent> BC.on
|
|||||||
markerFactory: MarkerFactory<in ChatEventMessage<T>, Any> = ByChatMessageMarkerFactory,
|
markerFactory: MarkerFactory<in ChatEventMessage<T>, Any> = ByChatMessageMarkerFactory,
|
||||||
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<T>>
|
noinline scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, ChatEventMessage<T>>
|
||||||
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
) = on(markerFactory, initialFilter, subcontextUpdatesFilter, scenarioReceiver) {
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
(it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage<T>) ?.let(::listOfNotNull)
|
(it.asBaseSentMessageUpdate() ?.data ?.asChatEventMessage() ?.takeIf { it.chatEvent is T } as? ChatEventMessage<T>) ?.let(::listOfNotNull)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +585,7 @@ suspend fun <BC : BehaviourContext> BC.onWebAppData(
|
|||||||
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<WebAppData>>
|
scenarioReceiver: CustomBehaviourContextAndTypeReceiver<BC, Unit, PrivateEventMessage<WebAppData>>
|
||||||
) = onEvent(
|
) = onEvent(
|
||||||
initialFilter ?.let { { it is PrivateEventMessage<WebAppData> && initialFilter(it) } },
|
initialFilter ?.let { { it is PrivateEventMessage<WebAppData> && initialFilter(it) } },
|
||||||
subcontextUpdatesFilter ?.let { { it: ChatEventMessage<WebAppData>, update: Update -> it is PrivateEventMessage<WebAppData> && subcontextUpdatesFilter(it, update) } },
|
subcontextUpdatesFilter ?.let { { message: ChatEventMessage<WebAppData>, update: Update -> message is PrivateEventMessage<WebAppData> && subcontextUpdatesFilter(message, update) } },
|
||||||
markerFactory
|
markerFactory
|
||||||
) {
|
) {
|
||||||
if (it is PrivateEventMessage<WebAppData>) {
|
if (it is PrivateEventMessage<WebAppData>) {
|
||||||
|
|||||||
@@ -21,12 +21,9 @@ internal suspend inline fun <BC : BehaviourContext, reified T> BC.on(
|
|||||||
scope,
|
scope,
|
||||||
markerFactory::invoke
|
markerFactory::invoke
|
||||||
) { triggerData ->
|
) { triggerData ->
|
||||||
val scope = LinkedSupervisorScope()
|
createSubContextAndDoWithUpdatesFilter(
|
||||||
doInSubContextWithUpdatesFilter(
|
|
||||||
updatesFilter = subcontextUpdatesFilter ?.toOneType(triggerData),
|
updatesFilter = subcontextUpdatesFilter ?.toOneType(triggerData),
|
||||||
stopOnCompletion = false,
|
stopOnCompletion = false
|
||||||
updatesUpstreamFlow = allUpdatesFlow.accumulatorFlow(scope),
|
|
||||||
scope = scope
|
|
||||||
) {
|
) {
|
||||||
scenarioReceiver(triggerData)
|
scenarioReceiver(triggerData)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,11 +9,7 @@ import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByC
|
|||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asSentMediaGroupUpdate
|
||||||
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
import dev.inmo.tgbotapi.types.message.abstracts.MediaGroupMessage
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.*
|
import dev.inmo.tgbotapi.types.message.content.*
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.AudioMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.DocumentMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.MediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.message.content.media.VisualMediaGroupContent
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
import dev.inmo.tgbotapi.utils.PreviewFeature
|
import dev.inmo.tgbotapi.utils.PreviewFeature
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollAnswerMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asPollAnswerUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
import dev.inmo.tgbotapi.types.polls.PollAnswer
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
internal suspend inline fun <BC : BehaviourContext> BC.onPollAnswered(
|
internal suspend inline fun <BC : BehaviourContext> BC.onPollAnswered(
|
||||||
|
|||||||
@@ -4,7 +4,8 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
|||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByIdPollMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asPollUpdate
|
||||||
import dev.inmo.tgbotapi.types.polls.*
|
import dev.inmo.tgbotapi.types.polls.*
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.PreCheckoutQueryFilterByUser
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserPreCheckoutQueryMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asPreCheckoutQueryUpdate
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
|
||||||
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
import dev.inmo.tgbotapi.types.payments.PreCheckoutQuery
|
||||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CallbackQueryFilterByUser
|
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ShippingQueryFilterByUser
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.ShippingQueryFilterByUser
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.ByUserShippingQueryMarkerFactory
|
||||||
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.marker_factories.MarkerFactory
|
||||||
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
import dev.inmo.tgbotapi.extensions.utils.asShippingQueryUpdate
|
||||||
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
import dev.inmo.tgbotapi.types.payments.ShippingQuery
|
||||||
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
import dev.inmo.tgbotapi.types.update.abstracts.Update
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.tgbotapi.extensions.behaviour_builder.utils
|
|||||||
fun interface SimpleFilter<in T> {
|
fun interface SimpleFilter<in T> {
|
||||||
suspend operator fun invoke(o: T): Boolean
|
suspend operator fun invoke(o: T): Boolean
|
||||||
}
|
}
|
||||||
|
val TrueSimpleFilter = SimpleFilter<Any?> { true }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return [SimpleFilter] which will return true in case when all the items in incoming data passed [this] filter
|
* @return [SimpleFilter] which will return true in case when all the items in incoming data passed [this] filter
|
||||||
@@ -28,16 +29,20 @@ fun <T> SimpleFilter<T>.listNone() = SimpleFilter<Iterable<T>> {
|
|||||||
/**
|
/**
|
||||||
* Makes an AND (&&) operation between [this] and [other]
|
* Makes an AND (&&) operation between [this] and [other]
|
||||||
*/
|
*/
|
||||||
operator fun <T> SimpleFilter<T>.times(other: SimpleFilter<T>) = SimpleFilter<T> {
|
operator fun <T> SimpleFilter<T>?.times(other: SimpleFilter<T>): SimpleFilter<T> = this ?.let {
|
||||||
this(it) && other(it)
|
SimpleFilter {
|
||||||
}
|
this(it) && other(it)
|
||||||
|
}
|
||||||
|
} ?: other
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes an OR (||) operation between [this] and [other]
|
* Makes an OR (||) operation between [this] and [other]
|
||||||
*/
|
*/
|
||||||
operator fun <T> SimpleFilter<T>.plus(other: SimpleFilter<T>) = SimpleFilter<T> {
|
operator fun <T> SimpleFilter<T>?.plus(other: SimpleFilter<T>): SimpleFilter<T> = this ?.let {
|
||||||
this(it) || other(it)
|
SimpleFilter {
|
||||||
}
|
this(it) || other(it)
|
||||||
|
}
|
||||||
|
} ?: other
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reverse results of [this]
|
* Reverse results of [this]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar
|
||||||
|
|
||||||
|
class HandleableCallbackBasedHolder<T> : HandleableTriggersHolder<suspend (T) -> Boolean>() {
|
||||||
|
suspend fun isHandled(data: T) = handleable.any { it(data) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar
|
||||||
|
|
||||||
|
class HandleableRegexesHolder : HandleableTriggersHolder<Regex>() {
|
||||||
|
fun isHandled(command: String) = handleable.any {
|
||||||
|
it.matches(command)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar
|
||||||
|
|
||||||
|
import kotlinx.coroutines.sync.Mutex
|
||||||
|
import kotlinx.coroutines.sync.withLock
|
||||||
|
|
||||||
|
open class HandleableTriggersHolder<T>(
|
||||||
|
preset: List<T> = emptyList()
|
||||||
|
) {
|
||||||
|
protected val commandsMutex = Mutex()
|
||||||
|
protected val _handleable = mutableListOf<T>().also {
|
||||||
|
it.addAll(preset)
|
||||||
|
}
|
||||||
|
val handleable: List<T>
|
||||||
|
get() = _handleable.toList()
|
||||||
|
|
||||||
|
suspend fun registerHandleable(data: T) {
|
||||||
|
commandsMutex.withLock {
|
||||||
|
_handleable.add(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun unregisterHandleable(data: T) {
|
||||||
|
commandsMutex.withLock {
|
||||||
|
_handleable.remove(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package dev.inmo.tgbotapi.extensions.behaviour_builder.utils.handlers_registrar
|
||||||
|
|
||||||
|
import dev.inmo.tgbotapi.types.queries.callback.DataCallbackQuery
|
||||||
|
|
||||||
|
class TriggersHolder {
|
||||||
|
val handleableCommandsHolder = HandleableRegexesHolder()
|
||||||
|
val handleableCallbackQueriesDataHolder = HandleableCallbackBasedHolder<DataCallbackQuery>()
|
||||||
|
}
|
||||||
@@ -47,10 +47,10 @@ kotlin {
|
|||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-json:$kotlin_serialisation_runtime_version"
|
||||||
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
api "org.jetbrains.kotlinx:kotlinx-serialization-properties:$kotlin_serialisation_runtime_version"
|
||||||
|
|
||||||
api "com.soywiz.korlibs.klock:klock:$klock_version"
|
api "com.soywiz.korlibs.klock:klock:$korlibs_version"
|
||||||
|
api "com.soywiz.korlibs.krypto:krypto:$korlibs_version"
|
||||||
api "com.benasher44:uuid:$uuid_version"
|
api "com.benasher44:uuid:$uuid_version"
|
||||||
|
|
||||||
api "dev.inmo:micro_utils.crypto:$micro_utils_version"
|
|
||||||
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
api "dev.inmo:micro_utils.coroutines:$micro_utils_version"
|
||||||
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
api "dev.inmo:micro_utils.serialization.base64:$micro_utils_version"
|
||||||
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
api "dev.inmo:micro_utils.serialization.encapsulator:$micro_utils_version"
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
interface CommonContactData {
|
@Deprecated("Replaced", ReplaceWith("CommonContactData", "dev.inmo.tgbotapi.abstracts.CommonContactData"))
|
||||||
val phoneNumber: String
|
typealias CommonContactData = dev.inmo.tgbotapi.abstracts.CommonContactData
|
||||||
val firstName: String
|
|
||||||
val lastName: String?
|
|
||||||
val vcard: String? // TODO:: Replace by some vCard abstraction
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,36 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.payments.abstracts.Currencied
|
@Deprecated("Replaced", ReplaceWith("CommonSendInvoiceData", "dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData"))
|
||||||
import dev.inmo.tgbotapi.types.payments.abstracts.Priced
|
typealias CommonSendInvoiceData = dev.inmo.tgbotapi.abstracts.CommonSendInvoiceData
|
||||||
|
|
||||||
interface CommonSendInvoiceData : Titled, Currencied, Priced {
|
|
||||||
val description: String
|
|
||||||
val payload: String
|
|
||||||
val providerToken: String
|
|
||||||
val maxTipAmount: Int?
|
|
||||||
val suggestedTipAmounts: List<Int>?
|
|
||||||
val providerData: String?
|
|
||||||
val requireName: Boolean
|
|
||||||
val requirePhoneNumber: Boolean
|
|
||||||
val requireEmail: Boolean
|
|
||||||
val requireShippingAddress: Boolean
|
|
||||||
val shouldSendPhoneNumberToProvider: Boolean
|
|
||||||
val shouldSendEmailToProvider: Boolean
|
|
||||||
val priceDependOnShipAddress: Boolean
|
|
||||||
|
|
||||||
val photoUrl: String?
|
|
||||||
val photoSize: Long?
|
|
||||||
val photoWidth: Int?
|
|
||||||
val photoHeight: Int?
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fun setPhoto(
|
|
||||||
photoUrl: String,
|
|
||||||
photoSize: Long? = null,
|
|
||||||
photoWidth: Int? = null,
|
|
||||||
photoHeight: Int? = null
|
|
||||||
)
|
|
||||||
|
|
||||||
fun unsetPhoto()
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.*
|
@Deprecated("Replaced", ReplaceWith("CommonVenueData", "dev.inmo.tgbotapi.abstracts.CommonVenueData"))
|
||||||
|
typealias CommonVenueData = dev.inmo.tgbotapi.abstracts.CommonVenueData
|
||||||
interface CommonVenueData : Titled {
|
|
||||||
override val title: String
|
|
||||||
val address: String
|
|
||||||
val foursquareId: FoursquareId?
|
|
||||||
val foursquareType: FoursquareType? // TODO:: Rewrite with enum or interface
|
|
||||||
val googlePlaceId: GooglePlaceId?
|
|
||||||
val googlePlaceType: GooglePlaceType?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,16 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
@Deprecated("Replaced", ReplaceWith("FromUser", "dev.inmo.tgbotapi.abstracts.FromUser"))
|
||||||
|
typealias FromUser = dev.inmo.tgbotapi.abstracts.FromUser
|
||||||
/**
|
|
||||||
* Inheritors of this interface have some [User] as a source of data. For example, any [dev.inmo.tgbotapi.types.queries.callback.CallbackQuery]
|
|
||||||
* have [User] as the source of that query
|
|
||||||
*/
|
|
||||||
interface FromUser : WithUser {
|
|
||||||
/**
|
|
||||||
* The source [User] of this type
|
|
||||||
*/
|
|
||||||
val from: User
|
|
||||||
override val user: User
|
|
||||||
get() = from
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.Degrees
|
@Deprecated("Replaced", ReplaceWith("Headed", "dev.inmo.tgbotapi.abstracts.Headed"))
|
||||||
|
typealias Headed = dev.inmo.tgbotapi.abstracts.Headed
|
||||||
interface Headed {
|
|
||||||
val heading: Degrees?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.Meters
|
@Deprecated("Replaced", ReplaceWith("HorizontallyAccured", "dev.inmo.tgbotapi.abstracts.HorizontallyAccured"))
|
||||||
|
typealias HorizontallyAccured = dev.inmo.tgbotapi.abstracts.HorizontallyAccured
|
||||||
interface HorizontallyAccured {
|
|
||||||
val horizontalAccuracy: Meters?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.Seconds
|
@Deprecated("Replaced", ReplaceWith("Livable", "dev.inmo.tgbotapi.abstracts.Livable"))
|
||||||
|
typealias Livable = dev.inmo.tgbotapi.abstracts.Livable
|
||||||
interface Livable {
|
|
||||||
/**
|
|
||||||
* Period in [Seconds]
|
|
||||||
*/
|
|
||||||
val livePeriod: Seconds?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
interface Locationed {
|
@Deprecated("Replaced", ReplaceWith("Locationed", "dev.inmo.tgbotapi.abstracts.Locationed"))
|
||||||
val latitude: Double
|
typealias Locationed = dev.inmo.tgbotapi.abstracts.Locationed
|
||||||
val longitude: Double
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.utils.MimeType
|
@Deprecated("Replaced", ReplaceWith("MimeTyped", "dev.inmo.tgbotapi.abstracts.MimeTyped"))
|
||||||
|
typealias MimeTyped = dev.inmo.tgbotapi.abstracts.MimeTyped
|
||||||
interface MimeTyped {
|
|
||||||
val mimeType: MimeType?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
interface Performerable {
|
@Deprecated("Replaced", ReplaceWith("Performerable", "dev.inmo.tgbotapi.abstracts.Performerable"))
|
||||||
val performer: String?
|
typealias Performerable = dev.inmo.tgbotapi.abstracts.Performerable
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.Meters
|
@Deprecated("Replaced", ReplaceWith("ProximityAlertable", "dev.inmo.tgbotapi.abstracts.ProximityAlertable"))
|
||||||
|
typealias ProximityAlertable = dev.inmo.tgbotapi.abstracts.ProximityAlertable
|
||||||
interface ProximityAlertable {
|
|
||||||
val proximityAlertRadius: Meters?
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,29 +1,18 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.MessageEntity.textsources.TextSource
|
@Deprecated("Replaced", ReplaceWith("Texted", "dev.inmo.tgbotapi.abstracts.Texted"))
|
||||||
import dev.inmo.tgbotapi.types.ParseMode.ParseMode
|
typealias Texted = dev.inmo.tgbotapi.abstracts.Texted
|
||||||
|
@Deprecated("Replaced", ReplaceWith("TextedWithTextSources", "dev.inmo.tgbotapi.abstracts.TextedWithTextSources"))
|
||||||
|
typealias TextedWithTextSources = dev.inmo.tgbotapi.abstracts.TextedWithTextSources
|
||||||
|
|
||||||
interface Texted {
|
@Deprecated("Replaced", ReplaceWith("ParsableOutput", "dev.inmo.tgbotapi.abstracts.ParsableOutput"))
|
||||||
val text: String?
|
typealias ParsableOutput = dev.inmo.tgbotapi.abstracts.ParsableOutput
|
||||||
}
|
|
||||||
interface TextedWithTextSources : Texted {
|
|
||||||
/**
|
|
||||||
* Full list of [TextSource]s
|
|
||||||
*/
|
|
||||||
val textSources: List<TextSource>?
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ParsableOutput : Texted {
|
@Deprecated("Replaced", ReplaceWith("EntitiesOutput", "dev.inmo.tgbotapi.abstracts.EntitiesOutput"))
|
||||||
val parseMode: ParseMode?
|
typealias EntitiesOutput = dev.inmo.tgbotapi.abstracts.EntitiesOutput
|
||||||
}
|
|
||||||
|
|
||||||
interface EntitiesOutput : TextedWithTextSources {
|
@Deprecated("Replaced", ReplaceWith("TextedOutput", "dev.inmo.tgbotapi.abstracts.TextedOutput"))
|
||||||
val entities: List<TextSource>?
|
typealias TextedOutput = dev.inmo.tgbotapi.abstracts.TextedOutput
|
||||||
get() = textSources
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TextedOutput : ParsableOutput, EntitiesOutput
|
@Deprecated("Replaced", ReplaceWith("TextedInput", "dev.inmo.tgbotapi.abstracts.TextedInput"))
|
||||||
|
typealias TextedInput = dev.inmo.tgbotapi.abstracts.TextedInput
|
||||||
interface TextedInput : TextedWithTextSources {
|
|
||||||
override val textSources: List<TextSource>
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
interface Titled {
|
@Deprecated("Replaced", ReplaceWith("Titled", "dev.inmo.tgbotapi.abstracts.Titled"))
|
||||||
val title: String?
|
typealias Titled = dev.inmo.tgbotapi.abstracts.Titled
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts
|
package dev.inmo.tgbotapi.CommonAbstracts
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.chat.User
|
@Deprecated("Replaced", ReplaceWith("WithUser", "dev.inmo.tgbotapi.abstracts.WithUser"))
|
||||||
|
typealias WithUser = dev.inmo.tgbotapi.abstracts.WithUser
|
||||||
/**
|
|
||||||
* All inheritors of this type have [User] in their data as one of the main data
|
|
||||||
*
|
|
||||||
* @see FromUser
|
|
||||||
*/
|
|
||||||
interface WithUser {
|
|
||||||
val user: User
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
@Deprecated("Replaced", ReplaceWith("ChatRequest", "dev.inmo.tgbotapi.abstracts.types.ChatRequest"))
|
||||||
|
typealias ChatRequest = dev.inmo.tgbotapi.abstracts.types.ChatRequest
|
||||||
interface ChatRequest : OptionalChatRequest {
|
|
||||||
override val chatId: ChatIdentifier
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
interface DisableNotification {
|
@Deprecated("Replaced", ReplaceWith("DisableNotification", "dev.inmo.tgbotapi.abstracts.types.DisableNotification"))
|
||||||
val disableNotification: Boolean
|
typealias DisableNotification = dev.inmo.tgbotapi.abstracts.types.DisableNotification
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
interface DisableWebPagePreview {
|
@Deprecated("Replaced", ReplaceWith("DisableWebPagePreview", "dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview"))
|
||||||
val disableWebPagePreview: Boolean?
|
typealias DisableWebPagePreview = dev.inmo.tgbotapi.abstracts.types.DisableWebPagePreview
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.InlineMessageIdentifier
|
@Deprecated("Replaced", ReplaceWith("InlineMessageAction", "dev.inmo.tgbotapi.abstracts.types.InlineMessageAction"))
|
||||||
|
typealias InlineMessageAction = dev.inmo.tgbotapi.abstracts.types.InlineMessageAction
|
||||||
interface InlineMessageAction {
|
|
||||||
val inlineMessageId: InlineMessageIdentifier
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.MessageIdentifier
|
@Deprecated("Replaced", ReplaceWith("MessageAction:", "dev.inmo.tgbotapi.abstracts.types.MessageAction:"))
|
||||||
|
typealias MessageAction = dev.inmo.tgbotapi.abstracts.types.MessageAction
|
||||||
interface MessageAction: ChatRequest {
|
|
||||||
val messageId: MessageIdentifier
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
package dev.inmo.tgbotapi.CommonAbstracts.types
|
package dev.inmo.tgbotapi.CommonAbstracts.types
|
||||||
|
|
||||||
import dev.inmo.tgbotapi.types.ChatIdentifier
|
@Deprecated("Replaced", ReplaceWith("OptionalChatRequest", "dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest"))
|
||||||
|
typealias OptionalChatRequest = dev.inmo.tgbotapi.abstracts.types.OptionalChatRequest
|
||||||
interface OptionalChatRequest {
|
|
||||||
val chatId: ChatIdentifier?
|
|
||||||
}
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user