WIP: Child fn should be able to access BotAction Header #46

Closed
modulatingforce wants to merge 2 commits from botaction-header-accessible-by-child-fn into master

Example Use Case

// botmodules.rs

pub struct Routine {
    pub name : String ,
    pub module : BotModule , 
    pub channel : Channel ,
   exec_body: bot_actions::actions_util::ExecBody,
// ...

}

// experiments003.rs

// test3_body is the execution body of the BotCommand
async fn test3_body(params : ExecBodyParams) {

// ...

// To Define a Routine during the BotCommand, some of the below is defined
// Including the exec_body for the Routine
// 
// ISSUE : While we define the Routine Below, Desired is we pass the Routine BotAction
//   as well to the below rtest() - ideally whenever it is executed

    let exec_body = actions_util::asyncbox(rtestbody);

    async fn rtestbody(params : ExecBodyParams) {

        let bot = Arc::clone(&params.bot);

        let botlock = bot.read().await;

        // uses chat.say_in_reply_to() for the bot controls for messages
        botlock
        .botmgrs
        .chat
        .say_in_reply_to(
            &params.msg.clone(), 
            String::from("Inner Routine Loop Message"),
            params.clone()
        ).await;
    }

// ...


Thought this was addressed here - #43
But that mostly covered scenarios that pulled data from the Parent BotAction : So in the case of a BotCommand Triggering a Routine , the BotCommand information is what that PR addressed

In this PR , we should make it available for the child function to also pull the current BotAction header


Relatively High Priority . This is a blocker of Routine functionality as enhanced Routines should be able to pull from current Routine settings, such as Channel (in case the routine should change channels)


Plan of Action :

  • Code in Recommended Solution area - around Exec()
  • Code a Experimental Module that Uses this & Runtime tests
  • Unit tests?
Example Use Case ```rust // botmodules.rs pub struct Routine { pub name : String , pub module : BotModule , pub channel : Channel , exec_body: bot_actions::actions_util::ExecBody, // ... } ``` ```rust // experiments003.rs // test3_body is the execution body of the BotCommand async fn test3_body(params : ExecBodyParams) { // ... // To Define a Routine during the BotCommand, some of the below is defined // Including the exec_body for the Routine // // ISSUE : While we define the Routine Below, Desired is we pass the Routine BotAction // as well to the below rtest() - ideally whenever it is executed let exec_body = actions_util::asyncbox(rtestbody); async fn rtestbody(params : ExecBodyParams) { let bot = Arc::clone(&params.bot); let botlock = bot.read().await; // uses chat.say_in_reply_to() for the bot controls for messages botlock .botmgrs .chat .say_in_reply_to( &params.msg.clone(), String::from("Inner Routine Loop Message"), params.clone() ).await; } // ... ``` Thought this was addressed here - https://git.flake.sh/modulatingforce/forcebot_rs/pulls/43 But that mostly covered scenarios that pulled data from the Parent BotAction : So in the case of a BotCommand Triggering a Routine , the BotCommand information is what that PR addressed In this PR , we should make it available for the child function to also pull the current BotAction header --- Relatively High Priority . This is a blocker of `Routine` functionality as enhanced Routines should be able to pull from current Routine settings, such as Channel (in case the routine should change channels) --- # Plan of Action : - [ ] Code in Recommended Solution area - around `Exec()` - [ ] Code a Experimental Module that Uses this & Runtime tests - [ ] Unit tests?
modulatingforce added the
Priority
High
Kind/Enhancement
labels 2024-03-26 16:54:36 -04:00
modulatingforce self-assigned this 2024-03-26 16:54:36 -04:00
modulatingforce added 1 commit 2024-03-26 16:57:46 -04:00
Merge branch 'main' into routines-functionality
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
34c3c8af7a
modulatingforce added 2 commits 2024-03-26 19:40:25 -04:00
testcmd to check botact header
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful
9cb8e514c6
modulatingforce added a new dependency 2024-03-26 19:47:41 -04:00
Author
Owner

Final Recommendation : No Change from This PR

  • The Change in #43 essentially took care of the desired logic at a high top level where BotCommand and Listeners would be called anyway

  • The Code suggestions identified here were found to be Redundant

  • At first, This PR was raised as there was a concern the functionality was not working for BotAction members for Routines (a separate Open PR #40 )

    • Code Recommendation there is that Routine functionality would need to be reviewed : Where bot code executes Child Functions and passes on an ExecBodyParams , just before, consider reconstructing parent_act

** Note : I may keep the branch open for a bit to compare as I experimented a bit with ownership

# Final Recommendation : No Change from This PR - The Change in https://git.flake.sh/modulatingforce/forcebot_rs/pulls/43 essentially took care of the desired logic at a high top level where `BotCommand` and `Listeners` would be called anyway - The Code suggestions identified here were found to be Redundant - At first, This PR was raised as there was a concern the functionality was not working for BotAction members for `Routines` (a separate Open PR https://git.flake.sh/modulatingforce/forcebot_rs/pulls/40 ) - Code Recommendation there is that `Routine` functionality would need to be reviewed : Where bot code executes Child Functions and passes on an `ExecBodyParams` , just before, consider reconstructing `parent_act` --- ** Note : I may keep the branch open for a bit to compare as I experimented a bit with ownership
modulatingforce added the
Reviewed
Won't Fix
Status
Need More Info
labels 2024-03-26 19:49:51 -04:00
modulatingforce added this to the Rust Learning project 2024-03-26 19:50:51 -04:00
Author
Owner

Considered Closed

Considered Closed
modulatingforce closed this pull request 2024-03-27 10:50:14 -04:00
modulatingforce deleted branch botaction-header-accessible-by-child-fn 2024-03-27 10:50:34 -04:00
modulatingforce removed the
Status
Need More Info
label 2024-03-27 15:36:11 -04:00
All checks were successful
ci/woodpecker/pr/cargo-checks Pipeline was successful

Pull request closed

Sign in to join this conversation.
No reviewers
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.

Blocks
#40 WIP: Basic Routine Functionality}
modulatingforce/forcebot_rs
Reference: modulatingforce/forcebot_rs#46
No description provided.