Skip to content

Commit

Permalink
ура убрал кринж
Browse files Browse the repository at this point in the history
  • Loading branch information
FunnyRain committed Feb 10, 2021
1 parent c654680 commit 787e9a7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cache/temp_wallIDS.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"isRemove":false,"deleteTime":1612882798,"temp":[110917,110916,110915,110913,110908,110903,110902,110899,110896,110893]}
{"isRemove":false,"deleteTime":1612882798,"temp":[110917,110916,110915,110913,110908,110903,110902,110899,110896,110893,110972,110970,110968,110966,110962]}
35 changes: 20 additions & 15 deletions src/Wall.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
/**
* Прошу прощения у матерей,
* Чьих возбудил я дочерей.
Expand All @@ -36,8 +41,8 @@ public function listen($owner_id, $call, int $sleep) {
* Короче извините за sleep(), но я хуй знает как сделать задержку пушто шлёт флуд контроль.
* Жду героя, который это исправит, а то мне стыдно :)
*/
sleep($sleep);
}
// Хахахаха нахуй это отсюда
// sleep($sleep);
}

}

0 comments on commit 787e9a7

Please sign in to comment.