mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-12-04 21:30:06 +00:00
add support of subcontext initial actions
This commit is contained in:
parent
d9488f8ccd
commit
856ae65fa8
@ -2,6 +2,11 @@
|
||||
|
||||
## 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
|
||||
|
||||
* `Versions`:
|
||||
|
15
README.md
15
README.md
@ -19,6 +19,8 @@ That is a set of libraries for plagubots. Look at the
|
||||
|
||||
### 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:
|
||||
|
||||
```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.managers.*
|
||||
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.plagubot.config.*
|
||||
import dev.inmo.tgbotapi.bot.TelegramBot
|
||||
@ -85,7 +86,8 @@ object PlaguBot : Plugin {
|
||||
onStateHandlingErrorHandler = koin.getOrNull<StateHandlingErrorHandler<State>>() ?: { state, e ->
|
||||
logger.eS(e) { "Unable to handle state $state" }
|
||||
null
|
||||
}
|
||||
},
|
||||
subcontextInitialAction = CombinedSubcontextInitialAction(koin.getAllDistinct()).subcontextInitialAction
|
||||
) {
|
||||
logger.i("Start setup of bot part")
|
||||
behaviourContext = this
|
||||
|
Loading…
Reference in New Issue
Block a user