mirror of
https://github.com/InsanusMokrassar/PlaguBotCommandsPlugin.git
synced 2024-11-23 08:18:43 +00:00
.github/workflows | ||
gradle | ||
src/main/kotlin | ||
_config.yml | ||
.gitignore | ||
build.gradle | ||
changelog_parser.sh | ||
CHANGELOG.md | ||
github_release.gradle | ||
gradle.properties | ||
gradlew | ||
gradlew.bat | ||
LICENSE | ||
publish.gradle | ||
publish.kpsb | ||
README.md | ||
settings.gradle |
Replaced to the PlaguBotPlugins
PlaguBotCommandsPlugin
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 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>
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:
- Any BotCommandScope
- Some language code as
String
OR: - Any IetfLanguageCode
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.