Go to file
2022-07-11 12:40:24 +06:00
.github/workflows Create kdocs.yml 2022-07-10 01:44:10 +06:00
gradle Update libs.versions.toml 2022-07-11 12:40:24 +06:00
src/main/kotlin Update CommandsPlugin.kt 2022-07-09 21:57:31 +06:00
_config.yml Initial commit 2022-07-09 19:37:03 +06:00
.gitignore Initial commit 2022-07-09 19:37:03 +06:00
build.gradle Update build.gradle 2022-07-10 01:48:51 +06:00
changelog_parser.sh initialization 2022-07-09 20:49:33 +06:00
CHANGELOG.md Update CHANGELOG.md 2022-07-11 12:39:50 +06:00
github_release.gradle initialization 2022-07-09 20:49:33 +06:00
gradle.properties Update gradle.properties 2022-07-11 12:38:20 +06:00
gradlew Initial commit 2022-07-09 19:37:03 +06:00
gradlew.bat Initial commit 2022-07-09 19:37:03 +06:00
LICENSE Initial commit 2022-07-09 19:37:03 +06:00
publish.gradle initialization 2022-07-09 20:49:33 +06:00
publish.kpsb initialization 2022-07-09 20:49:33 +06:00
README.md Update README.md 2022-07-09 21:57:47 +06:00
settings.gradle initialization 2022-07-09 20:49:33 +06:00

PlaguBotCommandsPlugin

Maven Central

This plugin has been created for centralized work with commands in your plugins. You may pass your commands (even in runtime) and they will automatically appear in bot commands for users

How to use

End user should include in his plugins section next line:

...
"plugins": [
  ...,
  "dev.inmo.plagubot.plugins.commands.CommandsPlugin"
],
...

Then, in your plugin you should register your commands. Just pass them inside setupDI as BotCommandFullInfo:

// ... Your plugin code
    override fun Module.setupDI(database: Database, params: JsonObject) {
        // ...
        single { BotCommand("commandExample", "Command description").full() }
        // ...
    }
// ...

You may pass info full extension:

Runtime commands changing

In runtime you may change the commands of bot using CommandsKeeper. The instance of CommandsKeeper can be retrieved from koin via simple koin.get<CommandsKeeper>() or koin.commandsKeeper:

// ...
    override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
        val commandsKeeper = koin.commandsKeeper
        // ... Some your code
        commandsKeeper.addCommand(BotCommand("commandExample", "Command description"))
        // ... Some your code
    }
// ...

Just as in the code above (in setupDI) you may pass all the command environment and it will be automatically updated for bot.

How to include

Add dependency:

Gradle:

api "dev.inmo:plagubot.plugins.commands:$commands_version"

Maven:

<dependency>
    <groupId>dev.inmo</groupId>
    <artifactId>plagubot.plugins.commands</artifactId>
    <version>${commands_version}</version>
</dependency>