[ENH] Define Commands as a type of trait or class? #4

Closed
opened 2023-11-29 01:17:11 -05:00 by modulatingforce · 3 comments

In the py implementation of forcebot, we can define a command prefix that is listened to, and if determined to be a command, call a function that uses that command

I want something similar with perhaps traits so that a developer can concentrate more of the implementation of the command body without needing to consider for example the command prefix etc

Commands should have the following defined :

  • a Bot Command Prefix
  • the command name
  • [optional] help text
  • Execution Body
  • SpecialRoles - Required Fixed Elevated Roles to run the command

Considering medium priority. This will help ease designing and implementing future commands quickly

Review for Completion

In the py implementation of forcebot, we can define a command prefix that is listened to, and if determined to be a command, call a function that uses that command I want something similar with perhaps traits so that a developer can concentrate more of the implementation of the command body without needing to consider for example the command prefix etc Commands should have the following defined : - a Bot Command Prefix - the command name - [optional] help text - Execution Body - SpecialRoles - Required Fixed Elevated Roles to run the command --- Considering medium priority. This will help ease designing and implementing future commands quickly ## Review for Completion - [ ] Before I close out this issue, I must create a separate create a Separate Issue for at least SpecialRoles , as the requirement in Milestone : https://git.flake.sh/modulatingforce/forcebot_rs/milestone/1 includes `BotAction` that would be restrained by User Controls
modulatingforce added the
Kind/Feature
label 2023-11-29 01:17:11 -05:00
modulatingforce added this to the Rust Learning project 2023-11-29 01:17:11 -05:00
modulatingforce added the
Priority
Medium
label 2023-11-29 01:17:22 -05:00
modulatingforce added this to the Prototype 1.0 milestone 2023-12-10 16:39:31 -05:00
Author
Owner

Update :

To Address This Issue :

Custom Module Developers can :

  • Define BotModule s & BotAction s , that are Added to a BotInstance 's ModuleManager
  • They are not required to define any traits
  • (FUTURE RELEASE) Within their custom module, they will be able to define functions that would be associated with their BotAction

This was by By Commit e587a6f24a

  • ModuleManager general working prototype definition as an object catalogs loaded BotAction s and their BotModule s

    • NOTE : There are some requirements that are not implemented yet, and should be in FUTURE RELEASE section
  • Developer HOWTO Documentation for setting up custom BotModule s and add them to the bot :

  • (FUTURE RELEASE)

    • BotCommand s with SpecialRoles field (?)
      • This makes sense to me, but successful execution of a BotCommand should be validated with ModuleManager (if Enabled for the context) and IdentityModule to if the command is permissible based on the caller's UserRoles
      • (?) However, I think developing this field and BotCommand association can be addressed in a separate Issue if required?
    • BotCommand s with ExecutionBody field
      • This is in the pipeline
      • (?) If required, this can be in a separate Issue
  • NOTE : Before I close out this issue, I must create a separate create a Separate Issue for at least SpecialRoles , as the requirement in Milestone : https://git.flake.sh/modulatingforce/forcebot_rs/milestone/1 includes BotAction that would be restrained by User Controls

Update : To Address This Issue : *Custom Module Developers* can : - Define `BotModule` s & `BotAction` s , that are Added to a `BotInstance` 's `ModuleManager` - They are not required to define any traits - **(FUTURE RELEASE)** Within their custom module, they will be able to define functions that would be associated with their `BotAction` ---- This was by By Commit https://git.flake.sh/modulatingforce/forcebot_rs/commit/e587a6f24a885be09524497bebb85e5390f48a38 - `ModuleManager` general working prototype definition as an object catalogs loaded `BotAction` s and their `BotModule` s - NOTE : There are some requirements that are not implemented yet, and should be in FUTURE RELEASE section - Developer HOWTO Documentation for setting up custom `BotModule` s and add them to the bot : - https://git.flake.sh/modulatingforce/forcebot_rs/src/branch/main/src/help/HOWTO/Add_Modules_BotActions.md - **(FUTURE RELEASE)** - `BotCommand` s with `SpecialRoles` field (?) - This makes sense to me, but successful execution of a BotCommand should be validated with `ModuleManager` (if `Enabled` for the context) and `IdentityModule` to if the command is permissible based on the caller's `UserRoles` - (?) However, I think developing this field and BotCommand association can be addressed in a separate Issue if required? - `BotCommand` s with `ExecutionBody` field - This is in the pipeline - (?) If required, this can be in a separate Issue - [ ] NOTE : Before I close out this issue, I must create a separate create a Separate Issue for at least SpecialRoles , as the requirement in Milestone : https://git.flake.sh/modulatingforce/forcebot_rs/milestone/1 includes `BotAction` that would be restrained by User Controls
modulatingforce self-assigned this 2023-12-22 13:28:16 -05:00
Author
Owner

Created the following for implementing exec_body : #7

Created the following for implementing `exec_body` : https://git.flake.sh/modulatingforce/forcebot_rs/issues/7
Author
Owner

Considering completed

As of latest code, BotCommands can be defined and added to the bot's ModulesManager . Example below

    // 1. Define the BotAction
    let botc1 = BotCommand {
        module: BotModule(String::from("experiments001")),
        command: String::from("test1"), // command call name
        alias: vec![String::from("tester1"), String::from("testy1")], // String of alternative names
        exec_body: actions_util::asyncbox(testy),
        help: String::from("Test Command tester"),
        required_roles: vec![identity::UserRole::BotAdmin],
    };

    // 2. Add the BotAction to ModulesManager
    botc1.add_to_modmgr(Arc::clone(&mgr)).await;
Considering completed As of latest code, `BotCommand`s can be defined and added to the bot's `ModulesManager` . Example below ```rust // 1. Define the BotAction let botc1 = BotCommand { module: BotModule(String::from("experiments001")), command: String::from("test1"), // command call name alias: vec![String::from("tester1"), String::from("testy1")], // String of alternative names exec_body: actions_util::asyncbox(testy), help: String::from("Test Command tester"), required_roles: vec![identity::UserRole::BotAdmin], }; // 2. Add the BotAction to ModulesManager botc1.add_to_modmgr(Arc::clone(&mgr)).await; ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: modulatingforce/forcebot_rs#4
No description provided.