From 508ae759e747483153b133c882f28f441a4dbaa3 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 21 Dec 2023 07:50:29 +0200 Subject: [PATCH] implement user post K value detection --- src/cli/bot.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cli/bot.php b/src/cli/bot.php index 12c4065..2cb6445 100644 --- a/src/cli/bot.php +++ b/src/cli/bot.php @@ -135,6 +135,24 @@ foreach ($config->feed as $feed) ) ); + // Get post k + $k = 0; + + if ($posts = $client->getPosts([$feed->target], 1)) + { + if (isset($posts[0]['userpost']['k'])) + { + $k = (int) $posts[0]['userpost']['k'] + 1; + } + } + + if (!$k) + { + echo _('Could not get user post K value') . PHP_EOL; + + continue; + } + // Send each message to the twister account foreach ($query->fetchAll() as $queue) { @@ -142,7 +160,7 @@ foreach ($config->feed as $feed) $twister->newPostMessage( $feed->target, - time(), //int $k, + $k, $queue->message, $errors );