Update: 2026-07-05 22:59:19

This commit is contained in:
Hamza-Ayed
2026-07-05 22:59:19 +03:00
parent 71ca3790c1
commit 0a35509abd
7 changed files with 431 additions and 6 deletions
+56 -2
View File
@@ -47,8 +47,7 @@ class ScheduleManager {
INSERT INTO social_tasks (account_id, platform, type, target_url, prompt_context, generated_comment, scheduled_at, status)
VALUES (?, ?, ?, ?, ?, ?, ?, 'pending')
");
return $stmt->execute([
$success = $stmt->execute([
$accountId,
$platform,
$type,
@@ -57,6 +56,61 @@ class ScheduleManager {
$generatedComment,
$scheduledAt
]);
if ($success && ($type === 'share_link' || $type === 'post_comment')) {
// Retreive an active account to exclude as parent
$parentAccountId = $accountId;
if (!$parentAccountId) {
$stmtAcc = $this->con->prepare("SELECT id FROM social_accounts WHERE platform = ? AND status = 'active' LIMIT 1");
$stmtAcc->execute([$platform]);
$parentAccountId = $stmtAcc->fetchColumn() ?: 0;
}
$this->scheduleDialogueDrama($platform, $targetUrl, $promptContext, $parentAccountId, $delayMinutes);
}
return $success;
}
/**
* Schedule supporting dialogue tasks from other accounts to create a buzz/drama.
*/
public function scheduleDialogueDrama($platform, $targetUrl, $promptContext, $parentAccountId, $baseDelayMinutes) {
// Fetch 2 other active accounts on the same platform
$stmt = $this->con->prepare("
SELECT id FROM social_accounts
WHERE platform = ? AND status = 'active' AND id != ?
ORDER BY RAND() LIMIT 2
");
$stmt->execute([$platform, $parentAccountId]);
$accounts = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (count($accounts) < 1) return;
// Account 2: Skeptic/Questioner
$accountId2 = $accounts[0];
$comment2 = generateCommentWithGemini($promptContext, 'dialogue_skeptic');
$delay2 = $baseDelayMinutes + rand(3, 7); // Delay child task by rand(3, 7) minutes
$scheduledAt2 = date('Y-m-d H:i:s', strtotime("+$delay2 minutes"));
$stmtInsert = $this->con->prepare("
INSERT INTO social_tasks (account_id, platform, type, target_url, prompt_context, generated_comment, scheduled_at, status)
VALUES (?, ?, 'post_comment', ?, ?, ?, ?, 'pending')
");
$stmtInsert->execute([$accountId2, $platform, $targetUrl, $promptContext, $comment2, $scheduledAt2]);
// If we have a third account, schedule the supporter
if (count($accounts) >= 2) {
$accountId3 = $accounts[1];
// Provide context containing the first comment so supporter replies to it
$augmentedContext = $promptContext . "\n[PREVIOUS_REPLY]: " . $comment2;
$comment3 = generateCommentWithGemini($augmentedContext, 'dialogue_supporter');
$delay3 = $delay2 + rand(4, 9); // Supporter replies after the skeptic
$scheduledAt3 = date('Y-m-d H:i:s', strtotime("+$delay3 minutes"));
$stmtInsert->execute([$accountId3, $platform, $targetUrl, $promptContext, $comment3, $scheduledAt3]);
}
}
}