PlaguBot/README.md

44 lines
1.9 KiB
Markdown
Raw Normal View History

2020-11-12 07:01:58 +00:00
# PlaguBot
2020-11-08 13:04:44 +00:00
2020-11-12 07:31:25 +00:00
## For users
2020-11-08 13:04:44 +00:00
2020-11-12 07:48:07 +00:00
Template: [![Use template](badges/use_template.svg)](https://github.com/InsanusMokrassar/PlaguBotBotTemplate/generate)
2020-11-12 07:45:23 +00:00
You can create your bot using
[this template](https://insanusmokrassar.github.io/PlaguBotBotTemplate/) by following of its instructions
2020-11-08 13:04:44 +00:00
2020-11-12 07:31:25 +00:00
## For developers
2020-11-08 13:04:44 +00:00
2020-11-12 07:45:23 +00:00
| Template: | [![Use template](badges/use_template.svg)](https://github.com/InsanusMokrassar/PlaguBotPluginTemplate/generate) |
|-----------|-----------------------------------------------------------------------------------------------------------------|
2022-01-06 06:46:23 +00:00
| Bot version: | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.bot/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.bot) |
| Plugin version: | [![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.plugin) |
2020-11-12 07:45:23 +00:00
2020-11-12 07:31:25 +00:00
That is a set of libraries for plagubots. Look at the
[PlaguBot Plugin template](https://insanusmokrassar.github.io/PlaguBotPluginTemplate/) to find how to create your bot.
### Technical help
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
single<StatesManager<State>> {
// setup your manager and return here
// Default is:
DefaultStatesManager(
InMemoryDefaultStatesManagerRepo()
)
}
```
Besides, you may setup handling errors lambda in the same function:
```kotlin
single<StateHandlingErrorHandler<State>> {
{ state, e ->
logger.eS(e) { "Unable to handle state $state" } // logging by default
null // you should return new state or null, default callback will return null
}
}
```