diff --git a/bot.php b/bot.php index 6d51b2b..57e7dfe 100644 --- a/bot.php +++ b/bot.php @@ -30,6 +30,11 @@ function ellipse($str,$n_chars,$crop_str='[...]') { $cut_index=strpos($buff,' ',$n_chars); $buff=substr($buff,0,($cut_index===false? $n_chars: $cut_index+1)).$crop_str; + // then cut for last newline or dot + $cut_index_a=strpos($buff,'.',$n_chars); + $cut_index_b=strpos($buff,PHP_EOL,$n_chars); + $cut_index = max((int) $cut_index_a, (int) $cut_index_b); + $buff=substr($buff,0,($cut_index===false? $n_chars: $cut_index+1)).$crop_str; } return $buff; }