Shortens a message text if necessary according to the configuration. Adds "[...]" to the end of the shortened text. Returns the resulting text and a bool telling whether a truncation was done.
(context: &Context, text: String)
| 139 | /// |
| 140 | /// Returns the resulting text and a bool telling whether a truncation was done. |
| 141 | pub(crate) async fn truncate_msg_text(context: &Context, text: String) -> Result<(String, bool)> { |
| 142 | if context.get_config_bool(Config::Bot).await? { |
| 143 | return Ok((text, false)); |
| 144 | } |
| 145 | // Truncate text if it has too many lines |
| 146 | Ok(truncate_by_lines( |
| 147 | text, |
| 148 | constants::DC_DESIRED_TEXT_LINES, |
| 149 | constants::DC_DESIRED_TEXT_LINE_LEN, |
| 150 | )) |
| 151 | } |
| 152 | |
| 153 | /* ****************************************************************************** |
| 154 | * date/time tools |
no test coverage detected