WIP: Basic Routine Functionality #40
2 changed files with 47 additions and 4 deletions
|
@ -795,7 +795,7 @@ impl Routine {
|
|||
|
||||
|
||||
|
||||
// [x] 4. If all other failure checks above works, ensure one more time that the attribute is implemented
|
||||
// [x] 4. If all other failure checks above works, ensure one more time that the atstribute is implemented
|
||||
// - If not, routine NOT IMPLEMENTED error
|
||||
|
||||
// if routine_attr.iter()
|
||||
|
|
|
@ -21,6 +21,7 @@ use rand::rngs::StdRng;
|
|||
use rand::seq::SliceRandom;
|
||||
use tokio::sync::RwLock;
|
||||
use std::borrow::Borrow;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::core::bot_actions::ExecBodyParams;
|
||||
|
@ -173,24 +174,63 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
|||
|
||||
if let BotAction::R(arr) = &*params.curr_act.read().await {
|
||||
|
||||
let iterleft = arr.read().await.remaining_iterations.unwrap_or(0);
|
||||
botlog::trace(
|
||||
"Before loading remaining iterations",
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
None,
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
|
||||
// let iterleft = arr.read().await.remaining_iterations.unwrap_or(0);
|
||||
|
||||
// let iterleft = if arr.read().await.remaining_iterations.is_none() { 0i64 }
|
||||
// else { arr.read().await.remaining_iterations.unwrap() };
|
||||
let iterleft = match arr.read().await.remaining_iterations {
|
||||
None => 0,
|
||||
Some(a) => a,
|
||||
};
|
||||
|
||||
|
||||
botlog::trace(
|
||||
"after loading remaining iterations",
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
None,
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
// [ ] get joined channels
|
||||
let joinedchannels = botlock.bot_channels.clone();
|
||||
|
||||
|
||||
fn pick_a_channel(chnlvec : Vec<Channel>) -> Channel {
|
||||
|
||||
|
||||
botlog::trace(
|
||||
"In Pick_a_Channel()",
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
None,
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
// More Information : https://docs.rs/rand/0.7.2/rand/seq/trait.SliceRandom.html#tymethod.choose
|
||||
|
||||
let mut rng = thread_rng();
|
||||
|
||||
// let joinedchannels = botlock.bot_channels.clone();
|
||||
// let joinedchannels = botlock.bot_channels.clone();
|
||||
(*chnlvec.choose(&mut rng).unwrap()).clone()
|
||||
}
|
||||
|
||||
|
||||
let chosen_channel = pick_a_channel(joinedchannels);
|
||||
|
||||
botlog::trace(
|
||||
format!("Picked a channel: {:?}", chosen_channel).as_str(),
|
||||
Some("Experiments003 > countdown_chnl()".to_string()),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
Log::flush();
|
||||
|
||||
let outmsg = if iterleft == 1 {
|
||||
format!("{} I love you uwu~",iterleft)
|
||||
} else { format!("{}",iterleft) };
|
||||
|
@ -247,7 +287,10 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
|
|||
params.clone()
|
||||
).await;
|
||||
|
||||
|
||||
// let jhandle = newr.clone().read().await.join_handle.clone().unwrap();
|
||||
// let a = jhandle.write().await;
|
||||
// a.
|
||||
// sleep(Duration::from_secs(300)).await;
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue