function processPVQueue() { $tasks = loadJSON(PV_TASKS_FILE); $sent = 0; // اول session رو زنده نگه دار $accounts = loadJSON(ACCOUNTS_FILE); foreach ($accounts as $acc) { $phone = $acc['phone'] ?? ''; if (empty($phone)) continue; $m = forceReconnect($phone); if ($m) { try { $m->getSelf(); } catch (Exception $e) {} } } // بعد پیام‌ها رو بفرست foreach ($tasks as $tid => $t) { if ($sent >= 1) break; if (($t['status'] ?? '') != 'running') continue; if ($t['sent'] >= $t['total']) continue; $last = !empty($t['last_sent']) ? strtotime($t['last_sent']) : 0; if ($t['sent'] > 0 && (time() - $last) < 60) continue; sendNextPV($tid); $sent++; } }