https://github.com/insanusmokrassar/plagubot
Plugins-oriented bot
https://github.com/insanusmokrassar/plagubot
dev-inmo-tgbotapi kotlin kotlin-jvm ktgbotapi
Last synced: about 1 month ago
JSON representation
Plugins-oriented bot
- Host: GitHub
- URL: https://github.com/insanusmokrassar/plagubot
- Owner: InsanusMokrassar
- License: mit
- Created: 2020-11-08T13:04:41.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-09-14T15:25:01.000Z (8 months ago)
- Last Synced: 2024-09-15T01:02:54.561Z (8 months ago)
- Topics: dev-inmo-tgbotapi, kotlin, kotlin-jvm, ktgbotapi
- Language: Kotlin
- Homepage: https://docs.inmo.dev/plagubot/
- Size: 337 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# PlaguBot
## For users
Template: [](https://github.com/InsanusMokrassar/PlaguBotBotTemplate/generate)
You can create your bot using
[this template](https://insanusmokrassar.github.io/PlaguBotBotTemplate/) by following of its instructions## For developers
| Template: | [](https://github.com/InsanusMokrassar/PlaguBotPluginTemplate/generate) |
|-----------|-----------------------------------------------------------------------------------------------------------------|
| Bot version: | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.bot) |
| Plugin version: | [](https://maven-badges.herokuapp.com/maven-central/dev.inmo/plagubot.plugin) |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
#### 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
single> {
// setup your manager and return here
// Default is:
DefaultStatesManager(
InMemoryDefaultStatesManagerRepo()
)
}
```Besides, you may setup handling errors lambda in the same function:
```kotlin
single> {
{ 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
}
}
```#### 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 {
// do some action or throw error to rerun on next round
}
}
```