pub async fn send_dumb(msg: DumbMessage) -> Result<()> {
    let chan: String = env_channel()?;
    let hook_url: &str = &env_hook_url()?;
    let hook_user: String = env_username();

    let slack = Slack::new(hook_url)?;
    let mut p = PayloadBuilder::new()
        .channel(chan)
        .icon_emoji(":shipcat:")
        .username(hook_user);

    let mut a = AttachmentBuilder::new(msg.text.clone()); // <- fallback
    if let Some(c) = msg.color {
        a = a.color(c)
    }
    // All text constructed for first attachment goes in this vec:
    let mut texts = vec![Text(msg.text.into())];

    // Optional replacement link
    if let Some(link) = msg.link {
        let split: Vec<&str> = link.split('|').collect();
        // Full sanity check here as it could come from the CLI
        if split.len() > 2 {
            bail!("Link {} not in the form of url|description", link);
        }
        let desc = if split.len() == 2 {
            split[1].into()
        } else {
            link.clone()
        };
        let addr = if split.len() == 2 {
            split[0].into()
        } else {
            link.clone()
        };
        texts.push(Link(SlackLink::new(&addr, &desc)));
    } else {
        // Auto link/text from originator if no ink set
        texts.push(infer_ci_links());
    }

    // Pass the texts array to slack_hook
    a = a.text(texts.as_slice());
    let ax = vec![a.build()?];
    p = p.attachments(ax);

    // Send everything. Phew.
    slack.send(&p.build()?).await?;
    Ok(())
}
/// Send entry point for `shipcat slack`
Send entry point for `shipcat slack`
Send entry point for ` shipcat slack `
pub async fn send_dumb(msg: DumbMessage) -> Result<()> {
    let chan: String = env_channel()?;
    let hook_url: &str = &env_hook_url()?;
    let hook_user: String = env_username();
    let slack = Slack::new(hook_url)?;
    let mut p = PayloadBuilder::new()
        .channel(chan)
        .icon_emoji(":shipcat:")
        .username(hook_user);
    let mut a = AttachmentBuilder::new(msg.text.clone()); // <- fallback
    if let Some(c) = msg.color {
        a = a.color(c)
    }
    // All text constructed for first attachment goes in this vec:
    let mut texts = vec![Text(msg.text.into())];
    // Optional replacement link
    if let Some(link) = msg.link {
        let split: Vec<&str> = link.split('|').collect();
        // Full sanity check here as it could come from the CLI
        if split.len() > 2 {
            bail!("Link {} not in the form of url|description", link);
        }
        let desc = if split.len() == 2 {
            split[1].into()
        } else {
            link.clone()
        };
        let addr = if split.len() == 2 {
            split[0].into()
        } else {
            link.clone()
        };
        texts.push(Link(SlackLink::new(&addr, &desc)));
    } else {
        // Auto link/text from originator if no ink set
        texts.push(infer_ci_links());
    }
    // Pass the texts array to slack_hook
    a = a.text(texts.as_slice());
    let ax = vec![a.build()?];
    p = p.attachments(ax);
    // Send everything. Phew.
    slack.send(&p.build()?).await?;
    Ok(())
}
pub async fn send_dumb ( msg : DumbMessage ) -> Result < ( ) > { let chan : String = env_channel ( ) ? ; let hook_url : & str = & env_hook_url ( ) ? ; let hook_user : String = env_username ( ) ; let slack = Slack :: new ( hook_url ) ? ; let mut p = PayloadBuilder :: new ( ) . channel ( chan ) . icon_emoji ( " " ) . username ( hook_user ) ; let mut a = AttachmentBuilder :: new ( msg . text . clone ( ) ) ; // <- fallback if let Some ( c ) = msg . color { a = a . color ( c ) } // All text constructed for first attachment goes in this vec: let mut texts = vec ! [ Text ( msg text into ( ) ) ] ; // Optional replacement link if let Some ( link ) = msg . link { let split : Vec < & str > = link . split ( '|' ) . collect ( ) ; // Full sanity check here as it could come from the CLI if split . len ( ) > 2 { bail ! ( " " link ) ; } let desc = if split . len ( ) == 2 { split [ 1 ] . into ( ) } else { link . clone ( ) } ; let addr = if split . len ( ) == 2 { split [ 0 ] . into ( ) } else { link . clone ( ) } ; texts . push ( Link ( SlackLink :: new ( & addr , & desc ) ) ) ; } else { // Auto link/text from originator if no ink set texts . push ( infer_ci_links ( ) ) ; } // Pass the texts array to slack_hook a = a . text ( texts . as_slice ( ) ) ; let ax = vec ! [ a build ( ) ] ; p = p . attachments ( ax ) ; // Send everything. Phew. slack . send ( & p . build ( ) ? ) . await ? ; Ok ( ( ) ) }
Send entry point for `shipcat slack`
Send entry point for ` shipcat slack `
msg
DumbMessage
msg
DumbMessage