parent
f582c36f97
commit
6912708cfb
7 changed files with 17 additions and 821 deletions
src/custom/experimental
|
@ -10,30 +10,22 @@
|
|||
|
||||
*/
|
||||
|
||||
// use rand::Rng;
|
||||
use std::sync::Arc;
|
||||
|
||||
use chrono::{TimeZone,Local};
|
||||
|
||||
// use twitch_irc::message::PrivmsgMessage;
|
||||
|
||||
use crate::core::bot_actions::ExecBodyParams;
|
||||
// use crate::core::botinstance::ChType::Channel;
|
||||
use crate::core::botinstance::Channel;
|
||||
// use ChType::Channel;
|
||||
use crate::core::botlog;
|
||||
// use crate::core::botmodules::BotAction;
|
||||
|
||||
use casual_logger::Log;
|
||||
|
||||
use crate::core::bot_actions::actions_util;
|
||||
// use crate::core::bot_actions::BotAR;
|
||||
use crate::core::botmodules::{BotActionTrait, BotCommand, BotModule, ModulesManager};
|
||||
|
||||
use crate::core::identity::UserRole::*;
|
||||
|
||||
// use tokio::time::{sleep, Duration};
|
||||
|
||||
pub async fn init(mgr: Arc<ModulesManager>) {
|
||||
|
||||
const OF_CMD_CHANNEL:Channel = Channel(String::new());
|
||||
|
@ -57,16 +49,13 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
|||
// 2. Add the BotAction to ModulesManager
|
||||
botc1.add_to_modmgr(Arc::clone(&mgr)).await;
|
||||
|
||||
// If enabling by defauling at instance level
|
||||
mgr.set_instance_enabled(BotModule(String::from("experiments002"))).await;
|
||||
|
||||
// [ ] #TODO - FOR SOME REASON, IF DISABLED BY DEFAULT, IT OVERFLOWS at RUNGTIME
|
||||
// If enabling by defauling at instance level , uncomment the following
|
||||
// mgr.set_instance_enabled(BotModule(String::from("experiments002"))).await;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
||||
async fn sayout(params : ExecBodyParams) {
|
||||
|
||||
|
||||
|
@ -77,32 +66,16 @@ async fn sayout(params : ExecBodyParams) {
|
|||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
[x] Get the parent module
|
||||
*/
|
||||
|
||||
let parent_module = params.get_parent_module().await;
|
||||
|
||||
|
||||
|
||||
let reply_parent = if let Some(Some(reply)) = params.msg.source.tags.0.get("reply-parent-msg-body") {
|
||||
Some(reply)
|
||||
} else { None }
|
||||
;
|
||||
|
||||
|
||||
// let reply_parent_usr = if let Some(Some(reply)) = msg.source.tags.0.get("reply-thread-parent-user-login") {
|
||||
// Some(reply)
|
||||
// } else { None }
|
||||
// ;
|
||||
|
||||
let reply_parent_ts = if let Some(Some(replyts)) = params.msg.source.tags.0.get("tmi-sent-ts") {
|
||||
|
||||
let a: i64 = replyts.parse().unwrap();
|
||||
let b = Local.timestamp_millis_opt(a).unwrap();
|
||||
// println!("Output : {}",b.to_string());
|
||||
// println!("Formatted : {}",b.format("%m-%d %H:%M") );
|
||||
Some(b.format("%m-%d %H:%M"))
|
||||
} else { None }
|
||||
;
|
||||
|
@ -145,35 +118,6 @@ async fn sayout(params : ExecBodyParams) {
|
|||
None,
|
||||
);
|
||||
|
||||
// // if botlock.botmgrs.chat.client.get_channel_status(trgchnl.to_string().clone()).await == (false,false) {
|
||||
// if !botlock.bot_channels.contains(&Channel(trgchnl.to_lowercase().to_string().clone())) {
|
||||
|
||||
// // in the case where the provided channel isn't something we're known to be connected to
|
||||
// botlog::warn(
|
||||
// &format!("A message attempted to send for a Non-Joined Channel : {}",trgchnl.to_string().clone()),
|
||||
// Some("Chat > send_botmsg".to_string()),
|
||||
// None,
|
||||
// );
|
||||
// // return ;
|
||||
|
||||
// if parent_module.clone().is_some() {
|
||||
|
||||
|
||||
// botlock
|
||||
// .botmgrs
|
||||
// .chat
|
||||
// .say_in_reply_to(
|
||||
// ¶ms.msg,
|
||||
// format!("Not a Joined Channel : {}",trgchnl),
|
||||
// // parent_module.clone().unwrap().clone()
|
||||
// params.clone(),
|
||||
// ).await;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// }
|
||||
|
||||
/*
|
||||
1. If a Reply ,
|
||||
[ ] Get Parent Content message - reply_parent
|
||||
|
@ -194,48 +138,26 @@ async fn sayout(params : ExecBodyParams) {
|
|||
|
||||
let newoutmsg = if let Some(srcmsg) = reply_parent {
|
||||
|
||||
// format!("{} from #{} says {} . Replying to: {} : {}",
|
||||
// msg.sender.name,msg.channel_login,outmsg, reply_parent_usr.unwrap(),srcmsg)
|
||||
// format!("{} from #{} says {} @ {} {} : {}",
|
||||
// msg.sender.name,
|
||||
// msg.channel_login,
|
||||
// outmsg,
|
||||
// reply_parent_ts.unwrap(),
|
||||
// reply_parent_usr.unwrap(),
|
||||
// srcmsg)
|
||||
format!("{} {} @ {} : {}",
|
||||
reply_parent_ts.unwrap(),
|
||||
params.msg.sender.name,
|
||||
params.msg.channel_login,
|
||||
srcmsg)
|
||||
} else {
|
||||
// format!("{} from #{} says : {}",
|
||||
// msg.sender.name,
|
||||
// msg.channel_login,
|
||||
// outmsg)
|
||||
format!("in {} - {} : {}",
|
||||
params.msg.channel_login,
|
||||
params.msg.sender.name,
|
||||
outmsg)
|
||||
};
|
||||
|
||||
|
||||
if parent_module.clone().is_some() {
|
||||
|
||||
|
||||
// uses chat.say_in_reply_to() for the bot controls for messages
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say(
|
||||
trgchnl.to_string(),
|
||||
newoutmsg.to_string(),
|
||||
// parent_module.unwrap().clone()
|
||||
params.clone(),
|
||||
).await;
|
||||
|
||||
}
|
||||
|
||||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say(
|
||||
trgchnl.to_string(),
|
||||
newoutmsg.to_string(),
|
||||
params.clone(),
|
||||
).await;
|
||||
|
||||
|
||||
},
|
||||
|
@ -257,30 +179,13 @@ async fn sayout(params : ExecBodyParams) {
|
|||
.say_in_reply_to(
|
||||
¶ms.msg,
|
||||
String::from("Invalid arguments"),
|
||||
// parent_module.unwrap().clone()
|
||||
params.clone()
|
||||
).await;
|
||||
|
||||
|
||||
// if parent_module.is_some() {
|
||||
|
||||
// // uses chat.say_in_reply_to() for the bot controls for messages
|
||||
// botlock
|
||||
// .botmgrs
|
||||
// .chat
|
||||
// .say_in_reply_to(
|
||||
// ¶ms.msg,
|
||||
// String::from("Invalid arguments"),
|
||||
// // parent_module.unwrap().clone()
|
||||
// params.clone()
|
||||
// ).await;
|
||||
|
||||
// }
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
Log::flush();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue