WIP: issue-routine-lock-idea2 #56

Draft
modulatingforce wants to merge 4 commits from issue-routine-lock-idea2 into issue-routine-lock
10 changed files with 1124 additions and 197 deletions

50
Cargo.lock generated
View file

@ -47,6 +47,19 @@ version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
[[package]]
name = "async-channel"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f28243a43d821d11341ab73c80bed182dc015c514b951616cf79bd4af39af0c3"
dependencies = [
"concurrent-queue",
"event-listener",
"event-listener-strategy",
"futures-core",
"pin-project-lite",
]
[[package]]
name = "async-recursion"
version = "1.1.0"
@ -323,6 +336,15 @@ dependencies = [
"tracing-error",
]
[[package]]
name = "concurrent-queue"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "console-api"
version = "0.6.0"
@ -486,6 +508,27 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "event-listener"
version = "5.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b5fb89194fa3cad959b833185b3063ba881dbfc7030680b314250779fb4cc91"
dependencies = [
"concurrent-queue",
"parking",
"pin-project-lite",
]
[[package]]
name = "event-listener-strategy"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "332f51cb23d20b0de8458b86580878211da09bcd4503cb579c225b3d124cabb3"
dependencies = [
"event-listener",
"pin-project-lite",
]
[[package]]
name = "eyre"
version = "0.6.12"
@ -522,6 +565,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
name = "forcebot_rs"
version = "0.1.0"
dependencies = [
"async-channel",
"async-recursion",
"async-trait",
"casual_logger",
@ -1122,6 +1166,12 @@ version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "parking"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae"
[[package]]
name = "parking_lot"
version = "0.12.1"

View file

@ -17,6 +17,7 @@ casual_logger = "0.6.5"
chrono = "0.4.35"
tokio-console = "0.1.10"
console-subscriber = "0.2.0"
async-channel = "2.2.0"
[lib]

View file

@ -43,12 +43,12 @@ use super::botmodules::StatusType;
#[derive(Clone, Debug)]
pub struct BotManagers {
pub identity: Arc<RwLock<IdentityManager>>,
pub chat: Chat,
pub chat: Arc<RwLock<Chat>>,
}
impl BotManagers {
pub fn init(
ratelimiters: HashMap<Channel, RateLimiter>,
ratelimiters: HashMap<Channel, Arc<RwLock<RateLimiter>>>,
client: TwitchIRCClient<TCPTransport<TLS>, StaticLoginCredentials>,
) -> BotManagers {
BotManagers {
@ -116,7 +116,7 @@ impl BotInstance {
client.join(chnl.to_owned()).unwrap();
let n = RateLimiter::new();
let n = Arc::new(RwLock::new(RateLimiter::new()));
ratelimiters.insert(Channel(String::from(chnl)), n);
}
@ -169,6 +169,7 @@ impl BotInstance {
match message {
ServerMessage::Notice(msg) => {
dbg!("NOTICE TRIGGERED",msg.clone());
botlog::notice(
format!("NOTICE : (#{:?}) {}", msg.channel_login, msg.message_text)
.as_str(),
@ -201,7 +202,18 @@ impl BotInstance {
);
Log::flush();
BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await;
let botarc = Arc::clone(&bot);
// let msgarc = Arc::new(RwLock::new(msg.clone()));
let msgtext = msg.message_text.clone();
dbg!("will spawn listener_main_prvmsg from runner",chrono::offset::Local::now(),msgtext.clone());
tokio::spawn( async move {
// let msgarc_c = msgarc.clone();
BotInstance::listener_main_prvmsg(botarc, &msg.clone()).await;
});
// BotInstance::listener_main_prvmsg(Arc::clone(&bot), &msg).await;
dbg!("completed spawn listener_main_prvmsg from runner",chrono::offset::Local::now(), msgtext);
}
ServerMessage::Whisper(msg) => {
botlog::debug(
@ -367,13 +379,13 @@ impl BotInstance {
Channel(msg.channel_login.to_string())).await;
if let StatusType::Disabled(a) = modstatus {
if let StatusType::Disabled(statuslvl) = modstatus {
// [x] Should only respond if a BotAdmin , Mod , SupMod , BroadCaster
// - Specifically it should respond only to those who may be able to enable the module
botlog::trace(
&format!("Identified cmd is associated with Disabled Module : StatusLvl = {:?}", a),
&format!("Identified cmd is associated with Disabled Module : StatusLvl = {:?}", statuslvl),
Some("BotInstance > listener_main_prvmsg()".to_string()),
Some(msg),
);
@ -397,9 +409,10 @@ impl BotInstance {
);
// Only respond to those with th ebelow User Roles
// [x] Need to add in Module as well
let outstr =
format!("sadg Module is disabled : {:?}",a);
format!("sadg Module is disabled : {:?} {:?}",c.module.clone(),statuslvl);
let params = ExecBodyParams {
@ -409,9 +422,11 @@ impl BotInstance {
curr_act : Some(Arc::clone(&act_clone)),
};
let params = Arc::new(RwLock::new(params));
// When sending a BotMsgTypeNotif, send_botmsg does Roles related validation as required
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outstr
),
params,
@ -468,7 +483,10 @@ impl BotInstance {
};
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
let params = Arc::new(RwLock::new(params));
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outstr.to_string()
),
params.clone(),
@ -499,7 +517,10 @@ impl BotInstance {
};
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
let params = Arc::new(RwLock::new(params));
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outstr.to_string()
),
params.clone(),
@ -516,6 +537,8 @@ impl BotInstance {
Some(msg),
);
dbg!("Running botcommand");
let a = Arc::clone(&bot);
c.execute(ExecBodyParams {
bot : a,

View file

@ -193,10 +193,10 @@ pub async fn init(mgr: Arc<ModulesManager>) {
let botclone = Arc::clone(&bot);
let botlock = botclone.read().await;
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
return;
@ -236,10 +236,10 @@ pub async fn init(mgr: Arc<ModulesManager>) {
ChangeResult::Success(a) => format!("YAAY Success : {}",a),
};
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
@ -374,10 +374,10 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// We should call a notification around here
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
return;
@ -421,10 +421,10 @@ pub async fn init(mgr: Arc<ModulesManager>) {
// We should call a notification around here
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
}

File diff suppressed because it is too large Load diff

View file

@ -214,11 +214,11 @@ async fn cmd_promote(params : ExecBodyParams) {
{ arg2 }
else if let Some(a) = arg1 {
if a.starts_with('-') {
botlock.botmgrs.chat.send_botmsg(
botlock.botmgrs.chat.read().await.send_botmsg(
super::chat::BotMsgType::Notif(
"Invalid Argument Flag".to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
return
} else { arg1 }
@ -294,10 +294,10 @@ async fn cmd_promote(params : ExecBodyParams) {
// We should call a notification around here
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
@ -432,11 +432,11 @@ async fn cmd_demote(params : ExecBodyParams) {
{ arg2 }
else if let Some(a) = arg1 {
if a.starts_with('-') {
botlock.botmgrs.chat.send_botmsg(
botlock.botmgrs.chat.read().await.send_botmsg(
super::chat::BotMsgType::Notif(
"Invalid Argument Flag".to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
return
} else { arg1 }
@ -519,10 +519,10 @@ async fn cmd_demote(params : ExecBodyParams) {
Some(&params.msg),
);
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
@ -545,6 +545,8 @@ async fn getroles(params : ExecBodyParams) {
*/
dbg!("In getroles command");
let mut argv = params.msg.message_text.split(' ');
@ -554,12 +556,24 @@ async fn getroles(params : ExecBodyParams) {
let targetuser = match arg1 {
None => {
dbg!("Expected Exit");
botlog::debug(
"Exittingcmd getroles - Invalid arguments ",
"Exitting cmd getroles - Invalid arguments ",
Some("identity.rs > init > getroles()".to_string()),
Some(&params.msg),
);
let botlock = params.bot.read().await;
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
"Invalid Arguments".to_string()
),
Arc::new(RwLock::new(params.clone())),
).await;
drop(botlock);
return
}, // exit if no arguments
@ -570,12 +584,15 @@ async fn getroles(params : ExecBodyParams) {
let targetchnl = arg2;
dbg!("In prior to bot read guard command");
let botlock = params.bot.read().await;
let id = botlock.get_identity();
let idlock = id.read().await;
dbg!("Pror to getspecialuserroles()");
let sproles = match targetchnl {
None => {
// [ ] If targetchnl is not provided, default to pulling the current channel
@ -669,14 +686,19 @@ async fn getroles(params : ExecBodyParams) {
Some(&params.msg),
);
botlock.botmgrs.chat.send_botmsg(super::chat::BotMsgType::Notif(
dbg!("Pror to getroles send_botmsg");
botlock.botmgrs.chat.read().await.send_botmsg(super::chat::BotMsgType::Notif(
outmsg.to_string()
),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
// [ ] NOTE : After the above, I should receive only the roles in the context of the current channel I received this ideally and maybe BotAdmin ; not outside
dbg!("End of getroles command");
}
@ -1544,6 +1566,8 @@ impl IdentityManager {
Note : Ideally this be called for a given chatter name ?
*/
dbg!("In getspecialuserroles()");
// [ ] !!! TODO: I don't think below is evaluating by given channel
botlog::debug(
&format!(
@ -1575,6 +1599,9 @@ impl IdentityManager {
};
dbg!("Before reading Vector Roles");
let rolesdb = Arc::clone(&self.special_roles_users);
let rolesdb_lock = rolesdb.read().await;
@ -1630,6 +1657,8 @@ impl IdentityManager {
}
}
dbg!("exit getspecialusreroles with",&evalsproles);
botlog::debug(
&format!("OUT > evalsproles {:?}", &evalsproles),
Some("IdentityManager > getspecialuserroles()".to_string()),

View file

@ -1,8 +1,14 @@
// Related : https://dev.twitch.tv/docs/irc/#rate-limits
const TIME_THRESHOLD_S: u64 = 30;
const TIME_MIN_S_F64: f64 = 1.0;
const MSG_THRESHOLD: u32 = 20;
const DUPMSG_MIN_SEND_S: f64 = 30.0;
use std::{sync::Arc, time::Instant};
use tokio::sync::RwLock;
use std::time::Instant;
use crate::core::botlog;
#[derive(Debug, Clone)]
@ -10,9 +16,10 @@ pub struct RateLimiter {
timer: Instant,
msgcounter: u32,
lastmsgtimer : Instant,
lastmsgdup : String,
}
#[derive(Debug)]
#[derive(Debug,Clone)]
pub enum LimiterResp {
Allow, // when it's evaluated to be within limits
Skip, // as outside of rate limits
@ -32,10 +39,20 @@ impl RateLimiter {
timer: Instant::now(),
msgcounter: 0,
lastmsgtimer: Instant::now(),
lastmsgdup : String::new(),
}
}
pub fn check_limiter(&mut self) -> LimiterResp {
fn dupmsg(&self,inmsg : String) -> bool {
dbg!("dubmsg()",&inmsg,&self.lastmsgdup);
if self.lastmsgdup == inmsg && self.lastmsgtimer.elapsed().as_secs_f64() < DUPMSG_MIN_SEND_S {
// duplicate detected
// self.lastmsgdup = String::new(); // update it as no longer duplicate
return true;
} else { return false; };
}
pub async fn check_limiter(&mut self,inmsg : String) -> LimiterResp {
let logstr = format!(
@ -49,32 +66,104 @@ impl RateLimiter {
);
let rsp = if self.timer.elapsed().as_secs() >= TIME_THRESHOLD_S {
self.timer = Instant::now();
self.msgcounter = 0;
/*
Documented Thesholds from https://dev.twitch.tv/docs/irc/#rate-limits
- [x] self.timer.elapsed().as_secs() >= TIME_THRESHOLD_S
>> initialize with LimiterResp::Allow
- [x] self.msgcounter < MSG_THRESHOLD &&
self.lastmsgtimer.elapsed().as_secs_f64() >= TIME_MIN_S_F64
>> LimiterResp::Allow
- [x] else
>> LimiterResp::Sleep(TIME_MIN_S_F64 - self.lastmsgtimer.elapsed().as_secs_f64() + 0.1)
*/
// let ratelimiter_ar = Arc::new(RwLock::new((*self).clone()));
let ratelimiter_ar = Arc::new(RwLock::new(self));
let mut rl_guard = ratelimiter_ar.write().await;
let rsp = if rl_guard.timer.elapsed().as_secs() >= TIME_THRESHOLD_S {
rl_guard.timer = Instant::now();
rl_guard.msgcounter = 0;
LimiterResp::Allow
} else if self.msgcounter < MSG_THRESHOLD &&
self.lastmsgtimer.elapsed().as_secs_f64() >= TIME_MIN_S_F64 {
} else if rl_guard.msgcounter < MSG_THRESHOLD &&
rl_guard.lastmsgtimer.elapsed().as_secs_f64() >= TIME_MIN_S_F64 {
LimiterResp::Allow
} else {
// when elapsed() < TIME_THRESHOLD_S && msgcounter >= MSG_THRESHOLD
// LimiterResp::Skip
LimiterResp::Sleep(TIME_MIN_S_F64 - self.lastmsgtimer.elapsed().as_secs_f64() + 0.1)
LimiterResp::Sleep(TIME_MIN_S_F64 - rl_guard.lastmsgtimer.elapsed().as_secs_f64() + 0.1)
};
// [ ] If rsp is still allow at this point, also do a dupcheck to adjust rsp to a sleep
dbg!(inmsg.clone());
dbg!(rl_guard.dupmsg(inmsg.clone()));
dbg!("Before Dup test",rsp.clone());
dbg!(matches!(rsp.clone(),LimiterResp::Allow));
// [-] Comment this area if removing Duplicate checking functionality
/* */
let rsp = if rl_guard.dupmsg(inmsg.clone()) && matches!(rsp,LimiterResp::Allow) {
//self.lastmsgdup = String::new();
// LimiterResp::Sleep(DUPMSG_MIN_SEND_S)
dbg!("Duplicate detected");
LimiterResp::Sleep(DUPMSG_MIN_SEND_S - rl_guard.lastmsgtimer.elapsed().as_secs_f64() + 0.1)
} else { rsp.clone() };
/* */
// => 04.02 - Don't update here
// // After Dup is checked, Set the lastmsgdup to latest message
// dbg!("Before Assigning Lastmsgdup",rl_guard.lastmsgdup.clone(),inmsg.clone(),rsp.clone());
// rl_guard.lastmsgdup = inmsg.clone();
// dbg!("After Assigning Lastmsgdup",rl_guard.lastmsgdup.clone(),inmsg.clone());
// [ ] Allows if sleep came up as negative
let rsp = match rsp {
LimiterResp::Sleep(sleeptime) if sleeptime < 0.0 => LimiterResp::Allow , // allow is sleeptime evaluated is negative
_ => rsp.clone(),
} ;
dbg!(rsp.clone());
botlog::trace(
&format!("Limiter Response : {:?} ; Elapsed (as_sec_f64) : {}",
rsp, self.lastmsgtimer.elapsed().as_secs_f64()),
rsp, rl_guard.lastmsgtimer.elapsed().as_secs_f64()),
Some("Rate Limiter Inner".to_string()),
None,
);
dbg!("check_limiter() > ratelimiter guard",rl_guard.clone());
drop(rl_guard);
rsp
}
pub fn increment_counter(&mut self) {
// pub fn increment_counter(&mut self) {
// self.msgcounter += 1;
// self.lastmsgtimer = Instant::now();
// }
pub async fn sent_msg(&mut self,msgstr : String) {
dbg!("sent_msg triggered",&msgstr);
// let ratelimiter_ar = Arc::new(RwLock::new((*self).clone()));
// let mut rl_guard = ratelimiter_ar.write().await;
dbg!("sent_msg > lastmsg before update",&self.lastmsgdup);
self.lastmsgdup = msgstr;
self.msgcounter += 1;
self.lastmsgtimer = Instant::now();
dbg!("sent_msg > lastmsg after update",&self.lastmsgdup);
// drop(rl_guard);
}
}

View file

@ -15,6 +15,7 @@ const OF_CMD_CHANNEL:Channel = Channel(String::new());
use rand::Rng;
use tokio::sync::RwLock;
use std::sync::Arc;
use crate::core::bot_actions::ExecBodyParams;
@ -130,10 +131,11 @@ async fn good_girl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("GoodGirl xdd "),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -170,22 +172,25 @@ async fn babygirl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: cafdk"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
sleep(Duration::from_secs_f64(0.5)).await;
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: have fun eating princess"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -194,10 +199,11 @@ async fn babygirl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: baby girl"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -225,5 +231,39 @@ async fn routinelike(params : ExecBodyParams) {
// lines are executed after in conjunction to the spawn
// spawn 5 independent spawns
let bot = Arc::clone(&params.bot);
let params_ar = Arc::new(RwLock::new(params.clone()));
let params_c = params_ar.clone();
for _ in 0..5 {
let bot_clone = bot.clone();
let params_cc = params_c.clone();
tokio::spawn( async move {
println!(">> SPAWNED Innterroutine triggered!");
sleep(Duration::from_secs_f64(5.0)).await;
let botlock = bot_clone.read().await;
let params_ccc = params_cc.clone();
let paramsguard = params_ccc.read().await;
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&paramsguard.msg,
String::from("SPAWNED GoodGirl xdd "),
params_cc,
).await;
drop(botlock);
drop(paramsguard);
});
};
}

View file

@ -17,6 +17,7 @@ const OF_CMD_CHANNEL:Channel = Channel(String::new());
use std::sync::Arc;
use chrono::{TimeZone,Local};
use tokio::sync::RwLock;
use crate::core::bot_actions::ExecBodyParams;
@ -116,7 +117,7 @@ async fn sayout(params : ExecBodyParams) {
botlog::trace(
&format!("[TRACE] Evaluated status of {} : {:?}",
trgchnl.to_string().clone(),botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await),
trgchnl.to_string().clone(),botlock.botmgrs.chat.read().await.client.get_channel_status(trgchnl.to_string().clone()).await),
Some("Chat > send_botmsg".to_string()),
None,
);
@ -156,10 +157,11 @@ async fn sayout(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say(
trgchnl.to_string(),
newoutmsg.to_string(),
params.clone(),
Arc::new(RwLock::new(params.clone())),
).await;
@ -179,10 +181,11 @@ async fn sayout(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("Invalid arguments"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;

View file

@ -289,12 +289,12 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
// let chosen_channel_ar = Arc::new(RwLock::new(chosen_channel));
// let params_clone = params.clone();
// let bot = Arc::clone(&params.blocking_read().bot);
// // let bot = Arc::clone(&params.blocking_read().bot);
// dbg!("in chat async function");
// // dbg!("in chat async function");
// let botlock = bot.blocking_read();
// // let botlock = bot.blocking_read();
// let channel_ar_clone = chosen_channel_ar.clone();
// let outmsg = if iterleft <= 1 {
@ -303,11 +303,24 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
// botlock.botmgrs.chat
// .say(
// channel_ar_clone.read().await.0.clone(),
// channel_ar_clone.blocking_read().0.clone(),
// outmsg,
// params_clone.read().await.clone()
// ).await;
// params_clone,
// );
let outmsg = if iterleft <= 1 {
// format!("{} I love you uwu~",iterleft)
let msgtxt = params.blocking_read().msg.message_text.clone();
// format!("{} {} I love you uwu~",iterleft,msgtxt)
format!("{} {}",iterleft,msgtxt)
} else { format!("{} Tomfoolery Clap",iterleft) };
botlock.botmgrs.chat.blocking_read()
.blocking_say(
chosen_channel.0.clone(),
outmsg,
Arc::new(RwLock::new(params.blocking_read().clone())),
);
}
}
@ -343,22 +356,66 @@ async fn countdown_chnl_v1(params : ExecBodyParams) {
let bot = Arc::clone(&params_ar.read().await.bot);
let botlock = bot.read().await;
// 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_ar.read().await.msg,
"Started Routine!".to_string(),
params_ar.read().await.clone()
).await;
// [ ] 04.01 - in an ASYNC context, ensure to raise a Blocking Spawn
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params_ar.read().await.msg,
// "Started Routine!".to_string(),
// Arc::new(RwLock::new(params_ar.read().await.clone()))
// );
// let jhandle = newr.clone().read().await.join_handle.clone().unwrap();
// let a = jhandle.write().await;
// a.
// sleep(Duration::from_secs(300)).await;
// let loopbodyspawn = tokio::task::spawn_blocking( move || {
// let botlock = bot.blocking_read();
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params_ar.blocking_read().msg,
// "Started Routine!".to_string(),
// Arc::new(RwLock::new(params_ar.blocking_read().clone()))
// );
// });
// loopbodyspawn.await.unwrap();
// let botlock = bot.read().await;
// botlock
// .botmgrs
// .chat
// .say_in_reply_to(
// &params_ar.blocking_read().msg,
// "Started Routine!".to_string(),
// Arc::new(RwLock::new(params_ar.blocking_read().clone()))
// ).await;
// drop(botlock);
let botlock = bot.read().await;
let params_guard = params_ar.read().await;
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
// &params_ar.blocking_read().msg,
&params_guard.msg,
"Started Routine!".to_string(),
Arc::new(RwLock::new(params_guard.clone()))
).await;
drop(botlock);
drop(params_guard);
}
@ -602,10 +659,11 @@ async fn test3_body(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params_ar.read().await.msg,
format!("Routine Result : {:?}",rsltstr),
params_clone.read().await.clone()
Arc::new(RwLock::new(params_clone.read().await.clone()))
).await;
// [x] Will not be handling JoinHandles here . If immediate abort() handling is required, below is an example that works
@ -669,10 +727,11 @@ async fn good_girl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("GoodGirl xdd "),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -709,10 +768,11 @@ async fn babygirl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: cafdk"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -721,10 +781,11 @@ async fn babygirl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: have fun eating princess"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;
@ -733,10 +794,11 @@ async fn babygirl(params : ExecBodyParams) {
botlock
.botmgrs
.chat
.read().await
.say_in_reply_to(
&params.msg,
String::from("16:13 notohh: baby girl"),
params.clone()
Arc::new(RwLock::new(params.clone()))
).await;