WIP: Basic Routine Functionality #40
2 changed files with 25 additions and 24 deletions
|
@ -620,10 +620,10 @@ pub struct Routine {
|
|||
pub module : BotModule , // from() can determine this if passed parents_params
|
||||
pub channel : Channel , // Requiring some channel context
|
||||
exec_body: bot_actions::actions_util::ExecBody,
|
||||
parent_params : ExecBodyParams ,
|
||||
pub parent_params : ExecBodyParams ,
|
||||
pub join_handle : Option<Arc<RwLock<JoinHandle<RoutineAR>>>> ,
|
||||
start_time : Option<DateTime<Local>> ,
|
||||
complete_iterations : i64 ,
|
||||
pub complete_iterations : i64 ,
|
||||
remaining_iterations : Option<i64> ,
|
||||
routine_attr : Vec<RoutineAttr> ,
|
||||
}
|
||||
|
|
|
@ -89,19 +89,6 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
|
||||
async fn rtestbody(params : ExecBodyParams) {
|
||||
|
||||
// let bot = Arc::clone(¶ms.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(
|
||||
// ¶ms.msg.clone(),
|
||||
// String::from("Inner Routine Loop Message"),
|
||||
// params.clone()
|
||||
// ).await;
|
||||
|
||||
let logmsg_botact = match *params.curr_act.read().await {
|
||||
BotAction::C(_) => "command",
|
||||
|
@ -110,20 +97,27 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
} ;
|
||||
|
||||
botlog::trace(
|
||||
// format!("Params > Curr_act : {:?}", params.curr_act).as_str(), // BotAction doesn't imblement debug
|
||||
format!("Params > Curr_act type : {:?}", logmsg_botact).as_str(),
|
||||
Some("Experiments003 > test3 command body".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
for _ in 0..5 {
|
||||
println!("tester");
|
||||
sleep(Duration::from_secs_f64(0.5)).await;
|
||||
if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
for curriter in 0..5 {
|
||||
println!("tester - Routine - Completed Iterations : {}",
|
||||
arr.read().await.complete_iterations);
|
||||
println!("tester - Custom Loop - Completed Iterations : {}",
|
||||
curriter);
|
||||
sleep(Duration::from_secs_f64(0.5)).await;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
botlog::debug(
|
||||
format!("RTESTBODY : module - {:?} ; channel - {:?}",
|
||||
module,channel
|
||||
|
@ -149,7 +143,8 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
|
||||
// [ ] before execute , be sure to adjust curr_act
|
||||
|
||||
let mut params_mut = params.clone();
|
||||
// let mut params_mut = params.clone();
|
||||
let mut params_mut = params;
|
||||
// let newr_ar = Arc::new(RwLock::new(newr));
|
||||
let newr_ar = newr.clone();
|
||||
|
||||
|
@ -163,6 +158,12 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
// let mut newr_lock = newr_ar.write().await;
|
||||
|
||||
// let rslt = newr_ar.write().await.start().await;
|
||||
|
||||
|
||||
{
|
||||
newr_ar.write().await.parent_params = params_mut.clone();
|
||||
}
|
||||
|
||||
let rslt = Routine::start(newr_ar.clone()).await;
|
||||
|
||||
// let rslt = newr_ar.read().await.start().await;
|
||||
|
@ -178,12 +179,12 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
rsltstr
|
||||
).as_str(),
|
||||
Some("experiment003 > test3_body".to_string()),
|
||||
Some(¶ms.msg),
|
||||
Some(¶ms_mut.msg),
|
||||
);
|
||||
|
||||
Log::flush();
|
||||
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
let bot = Arc::clone(¶ms_mut.bot);
|
||||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
|
@ -192,9 +193,9 @@ async fn test3_body(params : ExecBodyParams) {
|
|||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(
|
||||
¶ms.msg,
|
||||
¶ms_mut.msg,
|
||||
format!("Routine Result : {:?}",rsltstr),
|
||||
params.clone()
|
||||
params_mut.clone()
|
||||
).await;
|
||||
|
||||
// [x] Will not be handling JoinHandles here . If immediate abort() handling is required, below is an example that works
|
||||
|
|
Loading…
Reference in a new issue