From 9ec2f619b72b2160ad9c78d6c6521d42d0b55649 Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sat, 25 Nov 2023 20:20:23 +0100 Subject: [PATCH] Fix --- docs | 2 +- examples/tgstories_dl_bot.php | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs b/docs index b1968e08e..1e38683e7 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit b1968e08ee33430f535100e7dd9c1e1f8bc9a2bb +Subproject commit 1e38683e7f0464c86cb5084c360dc1753b28d130 diff --git a/examples/tgstories_dl_bot.php b/examples/tgstories_dl_bot.php index 6f9f0422c..3a347ae29 100644 --- a/examples/tgstories_dl_bot.php +++ b/examples/tgstories_dl_bot.php @@ -136,16 +136,18 @@ final class StoriesEventHandler extends SimpleEventHandler // Sort by date usort($stories, static fn ($a, $b) => $a['date'] <=> $b['date']); - $result = "Total stories: ".count($stories)."\n\n"; - foreach ($stories as $story) { - $cur = "- ID {$story['id']}, posted ".date(DATE_RFC850, $story['date']); - if (isset($story['caption'])) { - $cur .= ', "'.self::markdownEscape($story['caption']).'"'; + $message = $message->reply("Total stories: ".count($stories)); + foreach (array_chunk($stories, 50) as $sub) { + $result = ''; + foreach ($sub as $story) { + $cur = "- ID {$story['id']}, posted ".date(DATE_RFC850, $story['date']); + if (isset($story['caption'])) { + $cur .= ', "'.self::markdownEscape($story['caption']).'"'; + } + $result .= "$cur; [click here to download »]({$this->userInstance->getDownloadLink($story)})\n"; } - $result .= "$cur; [click here to download »]({$this->userInstance->getDownloadLink($story)})\n"; + $message = $message->reply($result, parseMode: ParseMode::MARKDOWN); } - - $message->reply($result, parseMode: ParseMode::MARKDOWN); } }