//! /sentance/ use super::*; pub async fn body(state: State, num: Option, mut output: mpsc::Sender) -> Result<(), gen::GenBodyError> { let string = { let chain = state.chain().read().await; if chain.is_empty() { return Ok(()); } match num { None => chain.generate_str(), Some(num) => (0..num).map(|_| chain.generate_str()).join("\n"), } }; debug!("Taking {:?} from {:?}" ,num, string); let filter = state.outbound_filter(); for sen in sanitise::Sentance::new_iter(&string).take(num.unwrap_or(1)) { output.send(filter.filter_owned(sen.to_owned())).await.map_err(|e| gen::GenBodyError(e.0))?; } Ok(()) }