feat: Add advanced engagement submenu with user targeting and engagement types

- Replace simple 'Engage Random User' button with expandable submenu
- Add user ID input field for targeting specific users
- Add engagement type selection: random, activity-based, general, status-based
- Update API endpoints to accept user_id and engagement_type parameters
- Modify autonomous functions to support targeted engagement
- Maintain backward compatibility with random user/type selection as default
This commit is contained in:
2025-12-16 23:13:19 +02:00
parent dfcda72cc8
commit b38bdf2435
3 changed files with 217 additions and 40 deletions

View File

@@ -702,7 +702,38 @@
</select>
</div>
<button onclick="triggerAutonomous('general')">Say Something General</button>
<button onclick="triggerAutonomous('engage')">Engage Random User</button>
<!-- Engage User Submenu -->
<div style="margin-bottom: 1rem;">
<button onclick="toggleEngageSubmenu()">Engage User ▼</button>
<div id="engage-submenu" style="display: none; margin-left: 1rem; margin-top: 0.5rem; padding: 1rem; background: #1e1e1e; border: 1px solid #444; border-radius: 4px;">
<div style="margin-bottom: 0.5rem;">
<label for="engage-user-id" style="display: block; margin-bottom: 0.3rem;">User ID (leave empty for random):</label>
<input type="text" id="engage-user-id" placeholder="User ID" style="width: 200px;">
</div>
<div style="margin-bottom: 0.5rem;">
<label style="display: block; margin-bottom: 0.3rem;">Engagement Type:</label>
<div style="margin-left: 0.5rem;">
<label style="display: block; margin-bottom: 0.2rem;">
<input type="radio" name="engage-type" value="random" checked> Random (auto-detect)
</label>
<label style="display: block; margin-bottom: 0.2rem;">
<input type="radio" name="engage-type" value="activity"> Activity-based (comment on what they're doing)
</label>
<label style="display: block; margin-bottom: 0.2rem;">
<input type="radio" name="engage-type" value="general"> General conversation
</label>
<label style="display: block; margin-bottom: 0.2rem;">
<input type="radio" name="engage-type" value="status"> Status-based (online/idle/invisible)
</label>
</div>
</div>
<button onclick="triggerEngageUser()">🚀 Engage User</button>
</div>
</div>
<button onclick="triggerAutonomous('tweet')">Share Tweet</button>
<button onclick="triggerAutonomous('reaction')">React to Message</button>
<button onclick="triggerAutonomous('join-conversation')">Detect and Join Conversation</button>
@@ -1967,6 +1998,65 @@ async function triggerAutonomous(actionType) {
}
}
// Toggle Engage User Submenu
function toggleEngageSubmenu() {
const submenu = document.getElementById('engage-submenu');
if (submenu.style.display === 'none') {
submenu.style.display = 'block';
} else {
submenu.style.display = 'none';
}
}
// Trigger Engage User with parameters
async function triggerEngageUser() {
const selectedServer = document.getElementById('server-select').value;
const userId = document.getElementById('engage-user-id').value.trim();
const engageType = document.querySelector('input[name="engage-type"]:checked').value;
try {
let endpoint = '/autonomous/engage';
const params = new URLSearchParams();
// Add guild_id if a specific server is selected
if (selectedServer !== 'all') {
params.append('guild_id', selectedServer);
}
// Add user_id if specified
if (userId) {
params.append('user_id', userId);
}
// Add engagement_type if not random
if (engageType !== 'random') {
params.append('engagement_type', engageType);
}
if (params.toString()) {
endpoint += `?${params.toString()}`;
}
const response = await fetch(endpoint, {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
const result = await response.json();
if (response.ok) {
showNotification(result.message || 'Engagement triggered successfully');
// Optionally collapse the submenu after successful trigger
// toggleEngageSubmenu();
} else {
throw new Error(result.message || 'Failed to trigger engagement');
}
} catch (error) {
console.error('Failed to trigger user engagement:', error);
showNotification(error.message || 'Failed to trigger engagement', 'error');
}
}
// Profile Picture Management
async function changeProfilePicture() {
const selectedServer = document.getElementById('server-select').value;