mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2025-09-05 16:19:45 +00:00
add support of subcontext initial actions
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
## 10.2.1
|
## 10.2.1
|
||||||
|
|
||||||
|
* `Versions`:
|
||||||
|
* `tgbotapi`: `21.0.1`
|
||||||
|
* `Bot`:
|
||||||
|
* Now all `CombinedSubcontextInitialAction.SubItem`s will be taken from `Koin` to setup root `subcontextInitialAction`
|
||||||
|
|
||||||
## 10.2.0
|
## 10.2.0
|
||||||
|
|
||||||
* `Versions`:
|
* `Versions`:
|
||||||
|
15
README.md
15
README.md
@@ -19,6 +19,8 @@ That is a set of libraries for plagubots. Look at the
|
|||||||
|
|
||||||
### Technical help
|
### Technical help
|
||||||
|
|
||||||
|
#### FSM
|
||||||
|
|
||||||
In this bot has been used variant with FSM. That means that you may use all the [Behaviour Builder with FSM](https://bookstack.inmo.dev/books/telegrambotapi/page/behaviour-builder-with-fsm) functionality. In case you wish to setup states repo, you should use the next code in the `setupDI` of your plugin:
|
In this bot has been used variant with FSM. That means that you may use all the [Behaviour Builder with FSM](https://bookstack.inmo.dev/books/telegrambotapi/page/behaviour-builder-with-fsm) functionality. In case you wish to setup states repo, you should use the next code in the `setupDI` of your plugin:
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
@@ -41,3 +43,16 @@ single<StateHandlingErrorHandler<State>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Subcontext initial actions
|
||||||
|
|
||||||
|
Bot will take all the `CombinedSubcontextInitialAction.SubItem`s from `Koin` to include it in root of
|
||||||
|
`behaviourBuilder`. To create your own subitem:
|
||||||
|
|
||||||
|
```kotlin
|
||||||
|
singleWithRandomQualifier<CombinedSubcontextInitialAction.SubItem> {
|
||||||
|
CombinedSubcontextInitialAction.SubItem {
|
||||||
|
// do some action or throw error to rerun on next round
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@@ -7,6 +7,7 @@ import dev.inmo.micro_utils.fsm.common.State
|
|||||||
import dev.inmo.micro_utils.fsm.common.StatesManager
|
import dev.inmo.micro_utils.fsm.common.StatesManager
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.*
|
import dev.inmo.micro_utils.fsm.common.managers.*
|
||||||
import dev.inmo.micro_utils.koin.getAllDistinct
|
import dev.inmo.micro_utils.koin.getAllDistinct
|
||||||
|
import dev.inmo.micro_utils.pagination.utils.getAll
|
||||||
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin
|
import dev.inmo.micro_utils.startup.launcher.StartLauncherPlugin
|
||||||
import dev.inmo.plagubot.config.*
|
import dev.inmo.plagubot.config.*
|
||||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||||
@@ -85,7 +86,8 @@ object PlaguBot : Plugin {
|
|||||||
onStateHandlingErrorHandler = koin.getOrNull<StateHandlingErrorHandler<State>>() ?: { state, e ->
|
onStateHandlingErrorHandler = koin.getOrNull<StateHandlingErrorHandler<State>>() ?: { state, e ->
|
||||||
logger.eS(e) { "Unable to handle state $state" }
|
logger.eS(e) { "Unable to handle state $state" }
|
||||||
null
|
null
|
||||||
}
|
},
|
||||||
|
subcontextInitialAction = CombinedSubcontextInitialAction(koin.getAllDistinct()).subcontextInitialAction
|
||||||
) {
|
) {
|
||||||
logger.i("Start setup of bot part")
|
logger.i("Start setup of bot part")
|
||||||
behaviourContext = this
|
behaviourContext = this
|
||||||
|
Reference in New Issue
Block a user