diff --git a/core/cron.php b/core/cron.php
index 2ea2bf5..79bc61c 100644
--- a/core/cron.php
+++ b/core/cron.php
@@ -12,7 +12,6 @@
try {
(new MQ())->run();
- Core\MQTasks::sendBash();// test bash loading
} catch (Throwable $t) {
SystemFunctions::sendTelegram('CRON: Произошла ошибка' . PHP_EOL . $t->getMessage() . PHP_EOL . 'File: ' . $t->getFile() . PHP_EOL . 'Line: ' . $t->getLine());
echo 'Error: ' . $t->getMessage() . ' / line: ' . $t->getLine();
diff --git a/core/lib/Core/MQTasks.class.php b/core/lib/Core/MQTasks.class.php
index 55aa836..9ec320a 100644
--- a/core/lib/Core/MQTasks.class.php
+++ b/core/lib/Core/MQTasks.class.php
@@ -145,4 +145,36 @@
sleep(5);
return 'bashMeta: Добавлено ' . $i . ', обновлено ' . $j . ' записей из ' . count($result);
}
+
+ public static function anekdot()
+ {
+ /** @var DB $DB */
+ $DB = DB::getInstance();
+
+ $file = file_get_contents('https://www.anekdot.ru/rss/randomu.html');
+ $file = explode('JSON.parse(\'', $file)[1];
+ $file = explode('\');', $file)[0];
+ $file = stripcslashes($file);
+ $arJokes = json_decode($file);
+
+ if(empty($arJokes)) {
+ throw new CoreException('Ошибка получения данных с сайта');
+ }
+ $i = 0;
+ foreach($arJokes as $joke) {
+ $hash = md5($joke);
+ $joke = str_replace('
', PHP_EOL, $joke);
+ $res = $DB->query('SELECT * FROM jokes WHERE hash="' . $hash . '"');
+ if (!$res) {
+ $i++;
+ $itemId = $DB->addItem('jokes', ['hash' => $hash, 'text' => $joke]);
+ //sendTelegram('Добавлена шутка ID ' . $itemId . '' . PHP_EOL . $joke);
+ }
+ }
+
+
+
+ sleep(2);
+ return 'Добавлено ' . $i . ' шуток из ' . count($arJokes);
+ }
}
\ No newline at end of file
diff --git a/core/lib/Core/Models/MQ.class.php b/core/lib/Core/Models/MQ.class.php
index c1667ae..9586084 100644
--- a/core/lib/Core/Models/MQ.class.php
+++ b/core/lib/Core/Models/MQ.class.php
@@ -61,7 +61,7 @@
/**
* Лимит количества одновременно выполняемых задач
*/
- const WORKERS_LIMIT = 10;
+ const WORKERS_LIMIT = 2;
/**
* @var DB|null $DB Объект базы