ExecBodyParams
This commit is contained in:
parent
616d1f564f
commit
203f6af869
6 changed files with 124 additions and 101 deletions
src/custom/experimental
|
@ -17,6 +17,7 @@ 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;
|
||||
|
@ -61,14 +62,16 @@ pub async fn init(mgr: Arc<ModulesManager>) {
|
|||
}
|
||||
|
||||
|
||||
async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
||||
// async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
||||
async fn sayout(params : ExecBodyParams) {
|
||||
|
||||
|
||||
/*
|
||||
usage :
|
||||
<target channel> <message>
|
||||
*/
|
||||
|
||||
let reply_parent = if let Some(Some(reply)) = msg.source.tags.0.get("reply-parent-msg-body") {
|
||||
let reply_parent = if let Some(Some(reply)) = params.msg.source.tags.0.get("reply-parent-msg-body") {
|
||||
Some(reply)
|
||||
} else { None }
|
||||
;
|
||||
|
@ -79,7 +82,7 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
// } else { None }
|
||||
// ;
|
||||
|
||||
let reply_parent_ts = if let Some(Some(replyts)) = msg.source.tags.0.get("tmi-sent-ts") {
|
||||
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();
|
||||
|
@ -93,7 +96,7 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
|
||||
|
||||
let argrslt =
|
||||
if let Some((_,str1)) = msg.message_text.split_once(' ') {
|
||||
if let Some((_,str1)) = params.msg.message_text.split_once(' ') {
|
||||
if reply_parent.is_none() {
|
||||
if let Some((channelstr,msgstr)) = str1.split_once(' ') {
|
||||
Some((channelstr,msgstr))
|
||||
|
@ -114,7 +117,7 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
match argrslt {
|
||||
Some((trgchnl,outmsg)) => {
|
||||
|
||||
let bot = Arc::clone(&bot);
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
|
@ -141,7 +144,7 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(&msg, format!("Not a Joined Channel : {}",trgchnl))
|
||||
.say_in_reply_to(¶ms.msg, format!("Not a Joined Channel : {}",trgchnl))
|
||||
.await;
|
||||
|
||||
|
||||
|
@ -178,8 +181,8 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
// srcmsg)
|
||||
format!("{} {} @ {} : {}",
|
||||
reply_parent_ts.unwrap(),
|
||||
msg.sender.name,
|
||||
msg.channel_login,
|
||||
params.msg.sender.name,
|
||||
params.msg.channel_login,
|
||||
srcmsg)
|
||||
} else {
|
||||
// format!("{} from #{} says : {}",
|
||||
|
@ -187,8 +190,8 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
// msg.channel_login,
|
||||
// outmsg)
|
||||
format!("in {} - {} : {}",
|
||||
msg.channel_login,
|
||||
msg.sender.name,
|
||||
params.msg.channel_login,
|
||||
params.msg.sender.name,
|
||||
outmsg)
|
||||
};
|
||||
|
||||
|
@ -206,10 +209,10 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
botlog::debug(
|
||||
"sayout had issues trying to parse arguments",
|
||||
Some("experiment002 > sayout".to_string()),
|
||||
Some(&msg),
|
||||
Some(¶ms.msg),
|
||||
);
|
||||
|
||||
let bot = Arc::clone(&bot);
|
||||
let bot = Arc::clone(¶ms.bot);
|
||||
|
||||
let botlock = bot.read().await;
|
||||
|
||||
|
@ -217,7 +220,7 @@ async fn sayout(bot: BotAR, msg: PrivmsgMessage) {
|
|||
botlock
|
||||
.botmgrs
|
||||
.chat
|
||||
.say_in_reply_to(&msg, String::from("Invalid arguments"))
|
||||
.say_in_reply_to(¶ms.msg, String::from("Invalid arguments"))
|
||||
.await;
|
||||
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue