From ddf39ee9f551b4aab2b215732cab172ce7aca793 Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Fri, 9 Mar 2018 13:50:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D0=BE=D0=B1=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=BF=D1=80=D0=B5=D0=B4=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bot.php | 5 +++++ 1 file changed, 5 insertions(+) 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; }