diff --git a/cache/temp_wallIDS.json b/cache/temp_wallIDS.json index 231a36e..43a3180 100644 --- a/cache/temp_wallIDS.json +++ b/cache/temp_wallIDS.json @@ -1 +1 @@ -{"isRemove":false,"deleteTime":1612882798,"temp":[110917,110916,110915,110913,110908,110903,110902,110899,110896,110893]} \ No newline at end of file +{"isRemove":false,"deleteTime":1612882798,"temp":[110917,110916,110915,110913,110908,110903,110902,110899,110896,110893,110972,110970,110968,110966,110962]} \ No newline at end of file diff --git a/src/Wall.php b/src/Wall.php index 45069c9..776672c 100644 --- a/src/Wall.php +++ b/src/Wall.php @@ -4,29 +4,34 @@ class Wall { private $user; private $cache; + private $update_time; public function __construct(User $user) { $this->user = $user; $this->cache = new Cache('temp_wallIDS.json', 30); + $this->update_time = time(); } public function listen($owner_id, $call, int $sleep) { - while ($data = $this->user->VkApiRequest()->api('wall.get', [ - 'owner_id' => $owner_id, - 'count' => 10, - 'filter' => 'owner' - ])) { - $items = $data['items']; - if (count($items) == 0) continue; - - foreach ($items as $key => $item) { + while (true) { + if (time() >= $this->update_time) { + $data = $this->user->VkApiRequest()->api('wall.get', [ + 'owner_id' => $owner_id, + 'count' => 5, + 'filter' => 'owner' + ]); + $items = $data['items']; + if (count($items) == 0) continue; - if (!in_array($item['id'], $this->cache->get()['temp'])) { - $this->cache->set($item['id']); - $call($item); + foreach ($items as $key => $item) { + if (!in_array($item['id'], $this->cache->get()['temp'])) { + $this->cache->set($item['id']); + $call($item); + } } - + $this->update_time = strtotime("+ {$sleep} seconds"); } + } /** * Прошу прощения у матерей, * Чьих возбудил я дочерей. @@ -36,8 +41,8 @@ public function listen($owner_id, $call, int $sleep) { * Короче извините за sleep(), но я хуй знает как сделать задержку пушто шлёт флуд контроль. * Жду героя, который это исправит, а то мне стыдно :) */ - sleep($sleep); - } + // Хахахаха нахуй это отсюда + // sleep($sleep); } } \ No newline at end of file