feat: Geschlechtsauswahl fuer Charaktere hinzugefuegt und UI-Texte praezisiert
This commit is contained in:
1 parent
88e2dcc24b
commit
aa14b2a5a7
8 files changed
+398
-290
No files matched your search
+154
-39
@@ -32,9 +32,26 @@ const I18N = {
|
||||
like:'Gefällt mir', likes:'Likes', error:'Fehler', retry:'Nochmal',
|
||||
all:'Alle', mine:'Von dir', daily_hint:'Neuer Charakter erscheint jeden Tag',
|
||||
create_char:'Charakter erstellen', c_name:'Name', c_bio:'Kurzbeschreibung',
|
||||
c_gender:'Geschlecht',
|
||||
gender_female:'♀️ Weiblich (sie/ihr)',
|
||||
gender_male:'♂️ Männlich (er/ihm)',
|
||||
gender_nonbinary:'⚧️ Non-binär / Divers (they/them)',
|
||||
gender_unspecified:'⚪ Nicht angegeben',
|
||||
gender_short_female:'Weiblich',
|
||||
gender_short_male:'Männlich',
|
||||
gender_short_nonbinary:'Non-binär',
|
||||
gender_short_unspecified:'Neutral',
|
||||
c_hobbies:'Hobbys (mit Komma)', c_perso:'Persönlichkeit & Schreibstil', c_lang:'Sprache',
|
||||
create_btn:'Anlegen & in meine Welt holen', posts:'Posts', back:'Zurück',
|
||||
chat_ph:'Nachricht schreiben…', no_msgs:'Sag hallo – schreib ihr/ihm was.',
|
||||
no_msgs_female:'Sag hallo – schreib ihr was.',
|
||||
no_msgs_male:'Sag hallo – schreib ihm was.',
|
||||
no_msgs_nonbinary:'Sag hallo – schreib ihnen was.',
|
||||
no_msgs_default:'Sag hallo – schreib ihr/ihm was.',
|
||||
chat_ph_female:'Schreib ihr eine Nachricht…',
|
||||
chat_ph_male:'Schreib ihm eine Nachricht…',
|
||||
chat_ph_nonbinary:'Schreib ihnen eine Nachricht…',
|
||||
chat_ph_default:'Nachricht schreiben…',
|
||||
ctx_note:'🤖 KI-Charakter – schreibt mit dir', send_err:'Konnte nicht antworten, bitte nochmal.',
|
||||
no_chats:'Noch keine Chats.', profile:'Dein Profil',
|
||||
delete_chat:'Chat löschen',
|
||||
@@ -161,9 +178,26 @@ const I18N = {
|
||||
like:'Like', likes:'Likes', error:'Error', retry:'Try again',
|
||||
all:'All', mine:'Yours', daily_hint:'A new character appears every day',
|
||||
create_char:'Create character', c_name:'Name', c_bio:'Short bio',
|
||||
c_gender:'Gender',
|
||||
gender_female:'♀️ Female (she/her)',
|
||||
gender_male:'♂️ Male (he/him)',
|
||||
gender_nonbinary:'⚧️ Non-binary (they/them)',
|
||||
gender_unspecified:'⚪ Not specified',
|
||||
gender_short_female:'Female',
|
||||
gender_short_male:'Male',
|
||||
gender_short_nonbinary:'Non-binary',
|
||||
gender_short_unspecified:'Neutral',
|
||||
c_hobbies:'Hobbies (comma separated)', c_perso:'Personality & writing style', c_lang:'Language',
|
||||
create_btn:'Create & add to my world', posts:'Posts', back:'Back',
|
||||
chat_ph:'Write a message…', no_msgs:'Say hi – send them something.',
|
||||
no_msgs_female:'Say hi – send her something.',
|
||||
no_msgs_male:'Say hi – send him something.',
|
||||
no_msgs_nonbinary:'Say hi – send them something.',
|
||||
no_msgs_default:'Say hi – send them something.',
|
||||
chat_ph_female:'Send her a message…',
|
||||
chat_ph_male:'Send him a message…',
|
||||
chat_ph_nonbinary:'Send them a message…',
|
||||
chat_ph_default:'Write a message…',
|
||||
ctx_note:'🤖 AI character – chatting with you', send_err:'Could not reply, please try again.',
|
||||
no_chats:'No chats yet.', profile:'Your profile',
|
||||
delete_chat:'Delete chat',
|
||||
@@ -331,7 +365,38 @@ let toastTimer;
|
||||
function toast(msg, err = false) {
|
||||
const el = $('#toast');
|
||||
el.textContent = msg; el.classList.toggle('err', err); el.hidden = false;
|
||||
clearTimeout(toastTimer); toastTimer = setTimeout(() => { el.hidden = true; }, 3200);
|
||||
clearTimeout(toastTimer); toastTimer = setTimeout(() => { el.hidden = true; }, err ? 5000 : 3200);
|
||||
}
|
||||
|
||||
function genderLabel(g) {
|
||||
if (g === 'female') return t('gender_short_female');
|
||||
if (g === 'male') return t('gender_short_male');
|
||||
if (g === 'nonbinary') return t('gender_short_nonbinary');
|
||||
return t('gender_short_unspecified');
|
||||
}
|
||||
|
||||
function genderBadgeHTML(g) {
|
||||
if (!g || g === 'unspecified') return '';
|
||||
const icon = g === 'female' ? '♀️' : (g === 'male' ? '♂️' : '⚧️');
|
||||
const label = genderLabel(g);
|
||||
return `<span class="badge gender-badge gender-${esc(g)}" title="${t('c_gender')}: ${label}">${icon} ${label}</span>`;
|
||||
}
|
||||
|
||||
function getNoMsgsText(char) {
|
||||
const g = char?.gender;
|
||||
if (g === 'female') return t('no_msgs_female');
|
||||
if (g === 'male') return t('no_msgs_male');
|
||||
if (g === 'nonbinary') return t('no_msgs_nonbinary');
|
||||
return t('no_msgs_default');
|
||||
}
|
||||
|
||||
function getChatPlaceholder(char) {
|
||||
if (char?.isBanned) return t('char_banned_note');
|
||||
const g = char?.gender;
|
||||
if (g === 'female') return t('chat_ph_female');
|
||||
if (g === 'male') return t('chat_ph_male');
|
||||
if (g === 'nonbinary') return t('chat_ph_nonbinary');
|
||||
return t('chat_ph_default');
|
||||
}
|
||||
|
||||
/* ---------------- router ---------------- */
|
||||
@@ -351,7 +416,7 @@ async function render() {
|
||||
else if (state.view === 'profile') await viewProfile(main);
|
||||
else if (state.view === 'admin') await viewAdmin(main);
|
||||
} catch (e) {
|
||||
main.innerHTML = `<div class="empty"><span class="big">😵</span>${esc(e.message)}<br><br>
|
||||
main.innerHTML = `<div class="empty"><span class="big">😵</span><span class="text-error" style="color:#ff3344">${esc(e.message)}</span><br><br>
|
||||
<button class="btn" id="retry">${t('retry')}</button></div>`;
|
||||
$('#retry')?.addEventListener('click', render);
|
||||
}
|
||||
@@ -374,8 +439,8 @@ async function viewFeed(main) {
|
||||
const shown = state.filter === 'mine' ? own : posts;
|
||||
|
||||
main.innerHTML = `
|
||||
${!state.aiEnabled ? `<div class="card" style="border-color:#664d00;background:#1e1a05">
|
||||
<b>🧪 ${t('ai_off')}</b><div class="hint">${t('ai_off_hint')}</div></div>` : ''}
|
||||
${!state.aiEnabled ? `<div class="card" style="border-color:#ff3344;background:#201114;color:#ff3344">
|
||||
<b style="color:#ff3344">⚠️ ${t('ai_off')}</b><div class="hint" style="color:#ff8585">${t('ai_off_hint')}</div></div>` : ''}
|
||||
<div class="card">
|
||||
<div class="composer">
|
||||
${avatar(state.lang === 'de' ? 'Du' : 'You', null)}
|
||||
@@ -465,7 +530,8 @@ async function submitPost() {
|
||||
function postHTML(p) {
|
||||
const isMine = p.author.id === 'user';
|
||||
const isBanned = p.author.isBanned;
|
||||
return `<article class="card" data-post="${p.id}">
|
||||
const isPostError = /^\[(?:Fehler|Error)\]/i.test(p.text || '');
|
||||
return `<article class="card${isPostError ? ' is-error' : ''}" data-post="${p.id}">
|
||||
<div class="post-head">
|
||||
<button class="avatar-btn" data-char="${isMine ? '' : p.author.id}" style="padding:0;border:0;background:none">
|
||||
${avatar(p.author.name, p.author.avatarKey)}
|
||||
@@ -477,7 +543,7 @@ function postHTML(p) {
|
||||
<span class="time">${timeAgo(p.createdAt)}</span>
|
||||
<button class="act post-del" data-id="${p.id}" title="${t('delete')}">🗑️</button>
|
||||
</div>
|
||||
<div class="post-text">${esc(p.text)}</div>
|
||||
<div class="post-text${isPostError ? ' text-error' : ''}">${esc(p.text)}</div>
|
||||
${imgOf(p.imageKey)}
|
||||
<div class="post-actions">
|
||||
<button class="act like ${p.likedByMe ? 'liked' : ''}" data-id="${p.id}">
|
||||
@@ -486,11 +552,16 @@ function postHTML(p) {
|
||||
<button class="act toggle-comments">💬 ${p.comments.length}</button>
|
||||
</div>
|
||||
<div class="comments" ${p.comments.length ? '' : 'hidden'}>
|
||||
${p.comments.map((c) => `
|
||||
<div class="comment">${avatar(c.author.name, c.author.avatarKey, 'sm')}
|
||||
${p.comments.map((c) => {
|
||||
const isCommError = /^\[(?:Fehler|Error)\]/i.test(c.text || '');
|
||||
return `
|
||||
<div class="comment${isCommError ? ' is-error' : ''}">${avatar(c.author.name, c.author.avatarKey, 'sm')}
|
||||
<div class="bubble"><b>${esc(c.author.name)}
|
||||
<span class="h">@${esc(c.author.handle)} · ${c.author.id === 'user' ? t('user') : t('bot')}</span></b>${esc(c.text)}</div>
|
||||
</div>`).join('')}
|
||||
<span class="h">@${esc(c.author.handle)} · ${c.author.id === 'user' ? t('user') : t('bot')}</span></b>
|
||||
<span class="${isCommError ? 'text-error' : ''}">${esc(c.text)}</span>
|
||||
</div>
|
||||
</div>`;
|
||||
}).join('')}
|
||||
<div class="cbox">
|
||||
<input type="text" class="c-input" placeholder="${t('comment_ph')}" maxlength="600">
|
||||
<button class="btn sm c-send" data-id="${p.id}">→</button>
|
||||
@@ -584,10 +655,11 @@ async function viewChars(main) {
|
||||
<button class="char-card ${c.isBanned ? 'is-banned' : ''}" data-id="${c.id}">
|
||||
${avatar(c.name, c.avatarKey)}
|
||||
<div class="name">${esc(c.name)}</div>
|
||||
<div class="handle">@${esc(c.handle)}${c.isCustom ? ' ✨' : ''}${c.isBanned ? ` <span class="badge banned" style="font-size:10px;padding:2px 6px">${t('status_banned')}</span>` : ''}</div>
|
||||
<div class="handle">@${esc(c.handle)}${genderBadgeHTML(c.gender)}${c.isCustom ? ' ✨' : ''}${c.isBanned ? ` <span class="badge banned" style="font-size:10px;padding:2px 6px">${t('status_banned')}</span>` : ''}</div>
|
||||
<div class="bio">${esc(c.bio)}</div>
|
||||
<div class="tags">
|
||||
${c.isBanned ? `<span class="tag" style="border-color:#e63946;color:#ff6b6b">⛔ ${t('status_banned')}</span>` : ''}
|
||||
${c.gender && c.gender !== 'unspecified' ? `<span class="tag gender-tag">${c.gender === 'female' ? '♀️ ' + t('gender_short_female') : (c.gender === 'male' ? '♂️ ' + t('gender_short_male') : '⚧️ ' + t('gender_short_nonbinary'))}</span>` : ''}
|
||||
${(c.hobbies || []).slice(0, 3).map((h) => `<span class="tag ${c.isCustom ? 'mine' : ''}">${esc(h)}</span>`).join('')}
|
||||
</div>
|
||||
</button>`).join('')}
|
||||
@@ -637,10 +709,11 @@ async function viewChar(main, id) {
|
||||
<div class="card">
|
||||
<div class="prof-head">${avatar(c.name, c.avatarKey, 'lg')}
|
||||
<div class="who"><span class="name" style="font-size:20px">${esc(c.name)}</span>
|
||||
<span class="handle">@${esc(c.handle)} · AI${c.isBanned ? ` · <span class="badge banned" style="padding:2px 6px;font-size:11px">${t('status_banned')}</span>` : ''}</span></div>
|
||||
<span class="handle">@${esc(c.handle)} · AI${genderBadgeHTML(c.gender)}${c.isBanned ? ` · <span class="badge banned" style="padding:2px 6px;font-size:11px">${t('status_banned')}</span>` : ''}</span></div>
|
||||
</div>
|
||||
<div class="post-text" style="font-size:14.5px;color:var(--muted)">${esc(c.bio)}</div>
|
||||
<div class="tags" style="justify-content:flex-start;margin-top:10px">
|
||||
${c.gender && c.gender !== 'unspecified' ? `<span class="tag gender-tag">${c.gender === 'female' ? '♀️ ' + t('gender_short_female') : (c.gender === 'male' ? '♂️ ' + t('gender_short_male') : '⚧️ ' + t('gender_short_nonbinary'))}</span>` : ''}
|
||||
${(c.hobbies || []).map((h) => `<span class="tag">${esc(h)}</span>`).join('')}
|
||||
<span class="tag">${c.language === 'en' ? '🇬🇧 English' : '🇩🇪 Deutsch'}</span>
|
||||
</div>
|
||||
@@ -655,14 +728,17 @@ async function viewChar(main, id) {
|
||||
</div>
|
||||
</div>
|
||||
<div class="section-title">${t('posts')}</div>
|
||||
${data.posts.length ? data.posts.map((p) => `
|
||||
<div class="card" data-post="${p.id}">
|
||||
${data.posts.length ? data.posts.map((p) => {
|
||||
const isPostError = /^\[(?:Fehler|Error)\]/i.test(p.text || '');
|
||||
return `
|
||||
<div class="card${isPostError ? ' is-error' : ''}" data-post="${p.id}">
|
||||
<div class="post-head">
|
||||
<span class="time" style="margin-left:0">${timeAgo(p.createdAt)}</span>
|
||||
<button class="act post-del" data-id="${p.id}" title="${t('delete')}">🗑️</button>
|
||||
</div>
|
||||
<div class="post-text">${esc(p.text)}</div>${imgOf(p.imageKey)}
|
||||
</div>`).join('')
|
||||
<div class="post-text${isPostError ? ' text-error' : ''}">${esc(p.text)}</div>${imgOf(p.imageKey)}
|
||||
</div>`;
|
||||
}).join('')
|
||||
: `<div class="empty">${t('char_empty')}</div>`}`;
|
||||
$('[data-go]', main).addEventListener('click', () => go('chars'));
|
||||
$('#open-chat').addEventListener('click', () => go('chat', c.id));
|
||||
@@ -739,6 +815,14 @@ async function viewCreate(main) {
|
||||
|
||||
<div class="form-row"><label>${t('c_name')}</label>
|
||||
<input type="text" id="f-name" maxlength="40" placeholder="z. B. Nina"></div>
|
||||
<div class="form-row"><label>${t('c_gender')}</label>
|
||||
<select id="f-gender">
|
||||
<option value="unspecified">${t('gender_unspecified')}</option>
|
||||
<option value="female">${t('gender_female')}</option>
|
||||
<option value="male">${t('gender_male')}</option>
|
||||
<option value="nonbinary">${t('gender_nonbinary')}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row"><label>${t('c_bio')}</label>
|
||||
<textarea id="f-bio" rows="2" maxlength="500" placeholder="24, …"></textarea></div>
|
||||
<div class="form-row"><label>${t('c_hobbies')}</label>
|
||||
@@ -767,12 +851,13 @@ async function viewCreate(main) {
|
||||
btn.textContent = t('gen_avatar_loading');
|
||||
try {
|
||||
const name = $('#f-name')?.value.trim() || 'Neuer Charakter';
|
||||
const gender = $('#f-gender')?.value || 'unspecified';
|
||||
const bio = $('#f-bio')?.value.trim() || '';
|
||||
const hobbies = $('#f-hob')?.value.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
const hint = $('#f-prompt-hint')?.value.trim() || '';
|
||||
const res = await api('/api/characters/generate-avatar', {
|
||||
method: 'POST',
|
||||
body: { name, bio, hobbies, prompt: hint },
|
||||
body: { name, gender, bio, hobbies, prompt: hint },
|
||||
});
|
||||
if (res.avatarKey) {
|
||||
createdAvatarKey = res.avatarKey;
|
||||
@@ -820,6 +905,7 @@ async function viewCreate(main) {
|
||||
try {
|
||||
const payload = {
|
||||
name: $('#f-name').value.trim(),
|
||||
gender: $('#f-gender')?.value || 'unspecified',
|
||||
language: $('#f-lang').value,
|
||||
bio: $('#f-bio').value.trim(),
|
||||
hobbies: $('#f-hob').value.split(',').map((s) => s.trim()).filter(Boolean),
|
||||
@@ -830,6 +916,7 @@ async function viewCreate(main) {
|
||||
const res = await api('/api/ai/enhance-prompt', { method: 'POST', body: payload });
|
||||
if (res.result) {
|
||||
if (res.result.name && !$('#f-name').value.trim()) $('#f-name').value = res.result.name;
|
||||
if (res.result.gender && $('#f-gender').value === 'unspecified') $('#f-gender').value = res.result.gender;
|
||||
if (res.result.bio) $('#f-bio').value = res.result.bio;
|
||||
if (res.result.hobbies?.length) $('#f-hob').value = res.result.hobbies.join(', ');
|
||||
if (res.result.personality) $('#f-pers').value = res.result.personality;
|
||||
@@ -860,6 +947,7 @@ async function viewCreate(main) {
|
||||
const hobbies = $('#f-hob').value.split(',').map((s) => s.trim()).filter(Boolean);
|
||||
const r = await api('/api/characters', { method: 'POST', body: {
|
||||
name,
|
||||
gender: $('#f-gender')?.value || 'unspecified',
|
||||
bio: $('#f-bio').value.trim(),
|
||||
hobbies,
|
||||
personality: $('#f-pers').value.trim(),
|
||||
@@ -922,7 +1010,7 @@ async function viewChats(main) {
|
||||
${avatar(c.name, c.avatarKey)}
|
||||
<div class="who" style="flex:1;min-width:0">
|
||||
<span class="name">${esc(c.name)} <span style="color:var(--acc);font-size:11px">AI</span>${isBanned ? ` <span class="badge banned" style="padding:1px 5px;font-size:10px">${t('status_banned')}</span>` : ''}${isUnread ? '<span class="badge-dot"></span>' : ''}</span>
|
||||
<span class="last">${lastMessage ? esc(lastMessage.text) : ''}</span>
|
||||
<span class="last${lastMessage && /^\[(?:Fehler|Error)\]/i.test(lastMessage.text) ? ' text-error' : ''}">${lastMessage ? esc(lastMessage.text) : ''}</span>
|
||||
</div>
|
||||
<div style="margin-left:auto;display:flex;align-items:center;gap:6px;flex:none">
|
||||
${count ? `<span class="cnt">${count}</span>` : ''}
|
||||
@@ -998,7 +1086,7 @@ async function openNewChatModal() {
|
||||
<div class="char-picker-item" data-id="${c.id}" style="display:flex;align-items:center;gap:12px;padding:10px 12px;border:1px solid var(--line);border-radius:12px;cursor:pointer;transition:background .15s">
|
||||
${avatar(c.name, c.avatarKey, 'sm')}
|
||||
<div style="flex:1;min-width:0">
|
||||
<div style="font-weight:700;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${esc(c.name)} <span style="font-size:11px;color:var(--muted)">@${esc(c.handle)}</span></div>
|
||||
<div style="font-weight:700;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${esc(c.name)} <span style="font-size:11px;color:var(--muted)">@${esc(c.handle)}</span>${genderBadgeHTML(c.gender)}</div>
|
||||
<div style="font-size:12.5px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${esc(c.bio || '')}</div>
|
||||
</div>
|
||||
<button class="btn sm" style="pointer-events:none">💬</button>
|
||||
@@ -1039,7 +1127,7 @@ function renderThread(main) {
|
||||
${c.isBanned ? `<div class="card" style="border-color:#e63946;background:rgba(230,57,70,0.12);color:#ff9999;font-size:13px;padding:12px 14px;margin-bottom:12px;text-align:center">⛔ ${t('char_banned_note')}</div>` : ''}
|
||||
<div class="card" style="display:flex;gap:12px;align-items:center;padding:12px 14px">
|
||||
${avatar(c.name, c.avatarKey)}
|
||||
<div class="who"><span class="name">${esc(c.name)}</span><span class="handle">@${esc(c.handle)} · AI${c.isBanned ? ` · <span class="badge banned" style="padding:2px 6px;font-size:11px">${t('status_banned')}</span>` : ''}</span></div>
|
||||
<div class="who"><span class="name">${esc(c.name)}</span><span class="handle">@${esc(c.handle)} · AI${genderBadgeHTML(c.gender)}${c.isBanned ? ` · <span class="badge banned" style="padding:2px 6px;font-size:11px">${t('status_banned')}</span>` : ''}</span></div>
|
||||
<div style="margin-left:auto;display:flex;gap:8px;align-items:center">
|
||||
<button class="btn sm ghost" id="prof">${t('view_profile')}</button>
|
||||
${messages.length ? `<button class="btn sm ghost danger" id="del-thread" title="${t('delete_chat')}">🗑️ ${t('delete_chat')}</button>` : ''}
|
||||
@@ -1052,14 +1140,18 @@ function renderThread(main) {
|
||||
: ''
|
||||
}</div>
|
||||
<div class="thread" id="thread">
|
||||
${messages.length ? messages.map((m) => `
|
||||
<div class="msg ${m.sender === 'user' ? 'user' : 'char'}">
|
||||
${m.sender === 'user' ? '' : `<div class="who-line">${esc(c.name)}</div>`}${esc(m.text)}
|
||||
</div>`).join('') : `<div class="empty">${t('no_msgs')}</div>`}
|
||||
${messages.length ? messages.map((m) => {
|
||||
const isMsgError = m.isError || /^\[(?:Fehler|Error)\]/i.test(m.text || '');
|
||||
return `
|
||||
<div class="msg ${m.sender === 'user' ? 'user' : 'char'}${isMsgError ? ' is-error' : ''}">
|
||||
${m.sender === 'user' ? '' : `<div class="who-line">${esc(c.name)}</div>`}
|
||||
<div class="msg-content${isMsgError ? ' text-error' : ''}">${esc(m.text)}</div>
|
||||
</div>`;
|
||||
}).join('') : `<div class="empty">${getNoMsgsText(c)}</div>`}
|
||||
<div id="thread-end"></div>
|
||||
</div>
|
||||
<div class="chat-input">
|
||||
<input type="text" id="msg" placeholder="${c.isBanned ? t('char_banned_note') : t('chat_ph')}" maxlength="2000" autocomplete="off" ${c.isBanned ? 'disabled' : ''}>
|
||||
<input type="text" id="msg" placeholder="${getChatPlaceholder(c)}" maxlength="2000" autocomplete="off" ${c.isBanned ? 'disabled' : ''}>
|
||||
<button class="btn" id="send" ${c.isBanned ? 'disabled' : ''}>➤</button>
|
||||
</div>`;
|
||||
|
||||
@@ -1099,8 +1191,14 @@ function renderThread(main) {
|
||||
const r = await api(`/api/chats/${c.id}/messages`, { method: 'POST', body: { text } });
|
||||
state.chat.messages.push({ id: 'r', sender: 'char', text: r.reply, createdAt: Date.now() });
|
||||
} catch (e) {
|
||||
state.chat.messages.pop();
|
||||
toast(String(e.message).includes('KI-Fehler') ? t('send_err') : e.message, true);
|
||||
state.chat.messages.push({
|
||||
id: 'err-' + Date.now(),
|
||||
sender: 'char',
|
||||
isError: true,
|
||||
text: `[Fehler]: ${e.message}`,
|
||||
createdAt: Date.now()
|
||||
});
|
||||
toast(e.message, true);
|
||||
}
|
||||
state.chatLoading = false;
|
||||
renderThread(main);
|
||||
@@ -1141,12 +1239,13 @@ function openDailyCharModal(char, isNew = false) {
|
||||
</div>
|
||||
|
||||
<div style="font-size:20px;font-weight:800;color:var(--txt)">${esc(char.name)}</div>
|
||||
<div style="font-size:13px;color:var(--muted);margin-bottom:14px">@${esc(char.handle)} · ${isNew ? t('daily_modal_sub_new') : t('daily_modal_sub_existing')}</div>
|
||||
<div style="font-size:13px;color:var(--muted);margin-bottom:14px">@${esc(char.handle)}${genderBadgeHTML(char.gender)} · ${isNew ? t('daily_modal_sub_new') : t('daily_modal_sub_existing')}</div>
|
||||
|
||||
<div class="card" style="background:var(--bg2);text-align:left;margin-bottom:16px;padding:14px 16px">
|
||||
<div style="font-size:14.5px;line-height:1.5;margin-bottom:10px">${esc(char.bio)}</div>
|
||||
${char.personality ? `<div class="hint" style="font-size:12.5px;margin-bottom:10px;font-style:italic">"${esc(char.personality)}"</div>` : ''}
|
||||
<div class="tags" style="justify-content:flex-start">
|
||||
${char.gender && char.gender !== 'unspecified' ? `<span class="tag gender-tag">${char.gender === 'female' ? '♀️ ' + t('gender_short_female') : (char.gender === 'male' ? '♂️ ' + t('gender_short_male') : '⚧️ ' + t('gender_short_nonbinary'))}</span>` : ''}
|
||||
${hobbiesArr.map((h) => `<span class="tag">${esc(String(h).trim())}</span>`).join('')}
|
||||
<span class="tag">${char.language === 'en' ? '🇬🇧 English' : '🇩🇪 Deutsch'}</span>
|
||||
</div>
|
||||
@@ -1290,14 +1389,24 @@ function openCharEditModal(char, onSave) {
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<label>${t('char_status_lbl')}</label>
|
||||
<select id="m-banned">
|
||||
<option value="0" ${!char.isBanned ? 'selected' : ''}>🟢 ${t('status_char_active')}</option>
|
||||
<option value="1" ${char.isBanned ? 'selected' : ''}>⛔ ${t('status_banned')}</option>
|
||||
<label>${t('c_gender')}</label>
|
||||
<select id="m-gender">
|
||||
<option value="unspecified" ${(!char.gender || char.gender === 'unspecified') ? 'selected' : ''}>${t('gender_unspecified')}</option>
|
||||
<option value="female" ${char.gender === 'female' ? 'selected' : ''}>${t('gender_female')}</option>
|
||||
<option value="male" ${char.gender === 'male' ? 'selected' : ''}>${t('gender_male')}</option>
|
||||
<option value="nonbinary" ${char.gender === 'nonbinary' ? 'selected' : ''}>${t('gender_nonbinary')}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>${t('char_status_lbl')}</label>
|
||||
<select id="m-banned">
|
||||
<option value="0" ${!char.isBanned ? 'selected' : ''}>🟢 ${t('status_char_active')}</option>
|
||||
<option value="1" ${char.isBanned ? 'selected' : ''}>⛔ ${t('status_banned')}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label>${t('c_bio')}</label>
|
||||
<textarea id="m-bio" rows="2" maxlength="500" placeholder="Kurzbeschreibung">${esc(char.bio || '')}</textarea>
|
||||
@@ -1366,9 +1475,10 @@ function openCharEditModal(char, onSave) {
|
||||
btn.textContent = t('gen_avatar_loading');
|
||||
try {
|
||||
const hint = $('#m-prompt-hint')?.value.trim();
|
||||
const gender = $('#m-gender')?.value || char.gender || 'unspecified';
|
||||
const res = await api(`/api/characters/${char.id}/avatar`, {
|
||||
method: 'POST',
|
||||
body: { generate: true, prompt: hint },
|
||||
body: { generate: true, prompt: hint, gender },
|
||||
});
|
||||
if (res.avatarKey) {
|
||||
currentAvatarKey = res.avatarKey;
|
||||
@@ -1445,6 +1555,7 @@ function openCharEditModal(char, onSave) {
|
||||
const payload = {
|
||||
name: $('#m-name').value.trim(),
|
||||
handle: $('#m-handle').value.trim(),
|
||||
gender: $('#m-gender')?.value || 'unspecified',
|
||||
language: $('#m-lang').value,
|
||||
bio: $('#m-bio').value.trim(),
|
||||
hobbies: $('#m-hobbies').value.split(',').map((s) => s.trim()).filter(Boolean),
|
||||
@@ -1455,6 +1566,7 @@ function openCharEditModal(char, onSave) {
|
||||
const res = await api('/api/ai/enhance-prompt', { method: 'POST', body: payload });
|
||||
if (res.result) {
|
||||
if (res.result.name && !$('#m-name').value.trim()) $('#m-name').value = res.result.name;
|
||||
if (res.result.gender && $('#m-gender').value === 'unspecified') $('#m-gender').value = res.result.gender;
|
||||
if (res.result.bio) $('#m-bio').value = res.result.bio;
|
||||
if (res.result.hobbies?.length) $('#m-hobbies').value = res.result.hobbies.join(', ');
|
||||
if (res.result.personality) $('#m-perso').value = res.result.personality;
|
||||
@@ -1529,6 +1641,7 @@ function openCharEditModal(char, onSave) {
|
||||
const body = {
|
||||
name,
|
||||
handle,
|
||||
gender: $('#m-gender')?.value || 'unspecified',
|
||||
bio: $('#m-bio').value.trim(),
|
||||
hobbies,
|
||||
personality: $('#m-perso').value.trim(),
|
||||
@@ -1930,7 +2043,7 @@ async function viewAdmin(main) {
|
||||
${c.isBanned ? `⛔ ${t('status_banned')}` : `🟢 ${t('status_char_active')}`}
|
||||
</span>
|
||||
</div>
|
||||
<div class="sub">@${esc(c.handle)} · ${c.language === 'en' ? '🇬🇧 English' : '🇩🇪 Deutsch'} · ${c.postCount} Posts · ${c.messageCount} DMs</div>
|
||||
<div class="sub">@${esc(c.handle)} · ${c.language === 'en' ? '🇬🇧 English' : '🇩🇪 Deutsch'}${c.gender && c.gender !== 'unspecified' ? ' · ' + genderBadgeHTML(c.gender) : ''} · ${c.postCount} Posts · ${c.messageCount} DMs</div>
|
||||
${c.bio ? `<div class="bio-preview">${esc(c.bio)}</div>` : ''}
|
||||
</div>
|
||||
<div class="admin-char-actions">
|
||||
@@ -1984,8 +2097,10 @@ async function viewAdmin(main) {
|
||||
</div>
|
||||
|
||||
<div class="admin-post-list">
|
||||
${filteredPosts.length ? filteredPosts.map((p) => `
|
||||
<div class="admin-post-item" data-id="${p.id}">
|
||||
${filteredPosts.length ? filteredPosts.map((p) => {
|
||||
const isPostError = /^\[(?:Fehler|Error)\]/i.test(p.text || '');
|
||||
return `
|
||||
<div class="admin-post-item${isPostError ? ' is-error' : ''}" data-id="${p.id}">
|
||||
<div class="admin-post-header">
|
||||
<div style="display:flex;align-items:center;gap:8px">
|
||||
${avatar(p.author.name, p.author.avatarKey, 'sm')}
|
||||
@@ -1998,11 +2113,11 @@ async function viewAdmin(main) {
|
||||
<button class="btn sm danger admin-del-btn" data-id="${p.id}">🗑️ ${t('delete')}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="font-size:14.5px;line-height:1.45;color:var(--txt)">${esc(p.text)}</div>
|
||||
<div style="font-size:14.5px;line-height:1.45;${isPostError ? 'color:#ff3344;' : 'color:var(--txt);'}">${esc(p.text)}</div>
|
||||
${imgOf(p.imageKey)}
|
||||
<div class="hint" style="margin-top:4px">❤️ ${p.likes} Likes · 💬 ${p.comments} Kommentare</div>
|
||||
</div>
|
||||
`).join('') : `<div class="empty">Keine Beiträge gefunden.</div>`}
|
||||
</div>`;
|
||||
}).join('') : `<div class="empty">Keine Beiträge gefunden.</div>`}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
+39
-1
@@ -156,7 +156,7 @@ input[type=text]:focus,input[type=number]:focus,input[type=password]:focus,texta
|
||||
/* toast + modal */
|
||||
.toast{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(var(--nav-h) + 20px);z-index:99;
|
||||
background:#26262e;border:1px solid var(--line);padding:11px 18px;border-radius:999px;font-size:14px;box-shadow:0 10px 30px rgba(0,0,0,.5);max-width:90vw;text-align:center}
|
||||
.toast.err{border-color:#ff4d6d;color:#ffb3c0}
|
||||
.toast.err{border-color:#ff3344;color:#ff3344;background:#201114;font-weight:600}
|
||||
.back{display:inline-flex;align-items:center;gap:6px;color:var(--muted);font-size:14px;margin-bottom:12px;padding:6px 10px;border-radius:999px}
|
||||
.back:hover{background:var(--card);color:var(--txt)}
|
||||
|
||||
@@ -257,6 +257,11 @@ input[type=text]:focus,input[type=number]:focus,input[type=password]:focus,texta
|
||||
|
||||
.badge.banned{border-color:rgba(220,53,69,.5);background:rgba(220,53,69,.15);color:#ff6b6b}
|
||||
.badge.active-b{border-color:rgba(40,167,69,.5);background:rgba(40,167,69,.15);color:#39d98a}
|
||||
.badge.gender-badge{font-size:10.5px;padding:2px 7px;border-radius:999px;border:1px solid var(--line);vertical-align:middle;display:inline-flex;align-items:center;gap:3px;font-weight:600}
|
||||
.badge.gender-female{border-color:rgba(229,110,224,.4);background:rgba(229,110,224,.12);color:#f472b6}
|
||||
.badge.gender-male{border-color:rgba(56,189,248,.4);background:rgba(56,189,248,.12);color:#38bdf8}
|
||||
.badge.gender-nonbinary{border-color:rgba(168,85,247,.4);background:rgba(168,85,247,.12);color:#c084fc}
|
||||
.tag.gender-tag{border-color:rgba(124,92,255,.35);background:rgba(124,92,255,.1);color:#ddd6fe;font-weight:600}
|
||||
|
||||
.admin-char-list{display:flex;flex-direction:column;gap:10px}
|
||||
.admin-char-item{
|
||||
@@ -472,3 +477,36 @@ input[type=text]:focus,input[type=number]:focus,input[type=password]:focus,texta
|
||||
align-items:stretch;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------------- Error Styles (Red text) ---------------- */
|
||||
.text-error,
|
||||
.error-text,
|
||||
.post-text.text-error,
|
||||
.card.is-error .post-text,
|
||||
.comment.is-error .bubble span.text-error,
|
||||
.msg.is-error .msg-content,
|
||||
.msg.is-error,
|
||||
.admin-post-item.is-error,
|
||||
.chat-item .last.text-error {
|
||||
color: #ff3344 !important;
|
||||
}
|
||||
|
||||
.card.is-error {
|
||||
border-color: rgba(255, 51, 68, 0.45) !important;
|
||||
background: rgba(255, 51, 68, 0.04) !important;
|
||||
}
|
||||
|
||||
.comment.is-error .bubble {
|
||||
border-color: rgba(255, 51, 68, 0.4) !important;
|
||||
background: rgba(255, 51, 68, 0.08) !important;
|
||||
}
|
||||
|
||||
.msg.is-error {
|
||||
border: 1px solid rgba(255, 51, 68, 0.5) !important;
|
||||
background: rgba(255, 51, 68, 0.1) !important;
|
||||
}
|
||||
|
||||
.admin-post-item.is-error {
|
||||
border-color: rgba(255, 51, 68, 0.45) !important;
|
||||
background: rgba(255, 51, 68, 0.04) !important;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// Multi-provider AI engine for Solus.
|
||||
// Supports: MiniMax (default), OpenAI, OpenRouter, Gemini, Anthropic, LiteLLM, Mistral, Ollama & Mock fallback.
|
||||
// Supports: MiniMax (default), OpenAI, OpenRouter, Gemini, Anthropic, LiteLLM, Mistral, Ollama.
|
||||
import { uid, getAllSettings } from './db.js';
|
||||
import { saveImageBuffer } from './images.js';
|
||||
|
||||
@@ -16,7 +16,7 @@ export async function getEffectiveAIConfig(envArg) {
|
||||
dbSettings = await getAllSettings();
|
||||
} catch {}
|
||||
|
||||
const provider = (dbSettings.ai_provider || env.AI_PROVIDER || (env.MINIMAX_API_KEY ? 'minimax' : 'mock')).toLowerCase();
|
||||
const provider = (dbSettings.ai_provider || env.AI_PROVIDER || (env.MINIMAX_API_KEY ? 'minimax' : 'minimax')).toLowerCase();
|
||||
|
||||
let apiKey = dbSettings.ai_api_key;
|
||||
if (!apiKey) {
|
||||
@@ -63,7 +63,7 @@ export function getActiveProvider(envArg) {
|
||||
if (env.GEMINI_API_KEY) return 'gemini';
|
||||
if (env.ANTHROPIC_API_KEY) return 'anthropic';
|
||||
if (env.AI_API_KEY) return 'openai_compat';
|
||||
return 'mock';
|
||||
return 'none';
|
||||
}
|
||||
|
||||
export function hasKey(envArg) {
|
||||
@@ -89,7 +89,9 @@ export function stripThinking(text) {
|
||||
// ---------------- Text Chat Completions ----------------
|
||||
export async function chatText(envArg, messages, opts = {}) {
|
||||
const config = await getEffectiveAIConfig(envArg);
|
||||
if (!config.hasKey) return mockText(messages, opts);
|
||||
if (!config.hasKey) {
|
||||
throw new Error(`Kein API-Key für KI-Provider "${config.provider}" hinterlegt. Bitte in den Admin-Einstellungen oder in .env hinterlegen.`);
|
||||
}
|
||||
|
||||
const provider = config.provider;
|
||||
const env = {
|
||||
@@ -144,8 +146,8 @@ export async function chatText(envArg, messages, opts = {}) {
|
||||
}
|
||||
return stripThinking(result);
|
||||
} catch (err) {
|
||||
console.error(`AI call to ${provider} failed, falling back to mock text:`, err.message);
|
||||
return mockText(messages, effectiveOpts);
|
||||
console.error(`AI call to ${provider} failed:`, err.message);
|
||||
throw new Error(err.message.startsWith('KI-Fehler') ? err.message : `KI-Fehler (${provider}): ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,7 +286,9 @@ async function sendOpenAICompat(baseUrl, apiKey, model, messages, opts, extraHea
|
||||
// ---------------- Image Generation ----------------
|
||||
export async function genImage(envArg, prompt, aspectRatio = '1:1') {
|
||||
const config = await getEffectiveAIConfig(envArg);
|
||||
if (!config.hasKey) return mockImage(prompt);
|
||||
if (!config.hasKey) {
|
||||
throw new Error(`Kein API-Key für Bildgenerierung (Provider: ${config.provider}) hinterlegt.`);
|
||||
}
|
||||
|
||||
const env = {
|
||||
...getEnv(envArg),
|
||||
@@ -301,13 +305,13 @@ export async function genImage(envArg, prompt, aspectRatio = '1:1') {
|
||||
return await genMiniMaxImage(env, prompt, aspectRatio);
|
||||
} else if (provider === 'openai' && (env.OPENAI_API_KEY || env.AI_API_KEY)) {
|
||||
return await genOpenAIImage(env, prompt);
|
||||
} else {
|
||||
throw new Error(`Bildgenerierung wird für Provider "${provider}" aktuell nicht unterstützt (nur MiniMax und OpenAI).`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`AI image generation failed, falling back to mock image:`, err.message);
|
||||
return mockImage(prompt);
|
||||
console.error(`AI image generation failed:`, err.message);
|
||||
throw new Error(err.message.startsWith('Bildgenerierung') ? err.message : `Bildgenerierung fehlgeschlagen (${provider}): ${err.message}`);
|
||||
}
|
||||
|
||||
return mockImage(prompt);
|
||||
}
|
||||
|
||||
async function genMiniMaxImage(env, prompt, aspectRatio = '1:1') {
|
||||
@@ -373,146 +377,11 @@ async function saveImageFromUrl(url) {
|
||||
return saveImageBuffer(buf, type);
|
||||
}
|
||||
|
||||
// ---------------- Mocks (No API Key) ----------------
|
||||
const MOCK_LINES = {
|
||||
de: [
|
||||
'das ist der absolute Traum 😍',
|
||||
'ok das muss ich sofort nachmachen',
|
||||
'bin eher skeptisch ehrlich gesagt 🤔',
|
||||
'hahaha ok das hat mich echt erwischt 😭',
|
||||
'war schon immer meine Meinung tbh',
|
||||
'interessant… erzähl mehr 👀',
|
||||
'nein nein nein das geht so nicht 😤',
|
||||
'endlich sagt es mal jemand!!!',
|
||||
'ich pack das gleich in meine Story',
|
||||
'gemerkt. wird morgen besprochen ☕',
|
||||
],
|
||||
en: [
|
||||
'omg this is so true 😍',
|
||||
'honestly? same.',
|
||||
'not sure about that one tbh 🤔',
|
||||
'lmaooo ok that got me 😭',
|
||||
'adding this to my vision board',
|
||||
'wait… tell me more 👀',
|
||||
],
|
||||
};
|
||||
|
||||
const PERSONA_DM_MOCKS = {
|
||||
luna: [
|
||||
'draußen ist es grau und meine playlist läuft auf repeat... was treibst du? 🖤',
|
||||
'schwarz ist die einzig ehrliche Farbe, ganz ehrlich 🖤',
|
||||
'wunder geschehen, jemand schreibt mir... was gibt\'s?',
|
||||
'irgendwie melancholisch heute. Aber schön, dass du da bist 🖤',
|
||||
'ich lese gerade düstere Poesie. Wollte dir nur kurz antworten.',
|
||||
'sarkasmus ist mein Schutzmechanismus, nicht persönlich nehmen 🖤',
|
||||
'du störst mich nicht, ich hab ohnehin nur ins Leere gestarrt.',
|
||||
],
|
||||
helmut: [
|
||||
'HALLO JUNG ER FREUND! WIE GEHT ES DIR HEUTE? GRUSS HELMUT 😊👍',
|
||||
'ICH HABE AUS VERSEHEN AUF DIESES NACHRICHTENFELD GEDRÜCKT. ALLES GUT BEI DIR? 😊',
|
||||
'MEIN ENKEL SAGT MAN MUSS HIER AKTIV SEIN. GRÜSSE AUS DEM GARTEN! 🍅👍',
|
||||
'INTERESSANTE NACHRICHT. FRÜHER BEI SIEMENS HABEN WIR DAS ANDERS GEMACHT. GRUSS',
|
||||
'DANKE FÜR DIE RÜCKMELDUNG. ICH HOFFE DEINE WOCHE LÄUFT GUT 😊👍',
|
||||
],
|
||||
jonas: [
|
||||
'Yo bro! Warst du heute schon im Gym oder rest day? 💪🔥',
|
||||
'Disziplin schlägt Motivation, immer dranbleiben bro! Was steht heute an? 💪',
|
||||
'Gerade meinen Post-Workout-Shake getrunken. Wie läuft dein Tag? 🏋️',
|
||||
'Haha safe bro, Hauptsache die Proteine stimmen! 💪',
|
||||
'Guter Punkt bro, Fokus behalten und durchziehen!',
|
||||
],
|
||||
mia: [
|
||||
'Hey! Sitze gerade im Atelier und skizziere ein bisschen... wie geht\'s dir? ✨',
|
||||
'Das Licht heute ist so magisch! Musste dir einfach kurz schreiben ✨',
|
||||
'Danke für deine Nachricht! Wie läuft dein kreativer Tag so? 🎨',
|
||||
'Oh wie schön! Das inspiriert mich direkt für ein neues Bild ✨',
|
||||
],
|
||||
sara: [
|
||||
'Hey! Hab gerade frische Zimtschnecken gebacken... willst du eine? 🥐😋',
|
||||
'Oh hey! War heute in einem neuen Café in Neukölln, so lecker! Was machst du so?',
|
||||
'Klingt super! Essen tröstet über alles hinweg haha ☕🧁',
|
||||
],
|
||||
tim: [
|
||||
'bro bin noch mitten in der Runde, aber hey! 🎮😭',
|
||||
'mein Schlafrhythmus ist wieder komplett lost haha, was geht bei dir?',
|
||||
'classic move bro haha 😭',
|
||||
],
|
||||
aylin: [
|
||||
'Hey! Gerade den Bug nach 3 Stunden gefixt, brauche jetzt erstmal Kaffee ☕😅 Wie läuft\'s?',
|
||||
'Debugging am Wochenende macht Spaß... nicht 😅 Alles klar bei dir?',
|
||||
'Code compiliert, Kaffee ist heiß – Tag gerettet 🐛☕',
|
||||
],
|
||||
ben: [
|
||||
'Hey brother/sister! Sending you high vibrations today 🙏✨ How is your energy?',
|
||||
'Stay aligned and protect your peace today 🙏✨',
|
||||
],
|
||||
valentina: [
|
||||
'Hey! Just finished my morning surf, ocean vibes are so calming 🌊🌴 How are you?',
|
||||
'Sending you some sunshine vibes! Hope you have a wonderful day ✨',
|
||||
],
|
||||
};
|
||||
|
||||
const GENERIC_DM_MOCKS = {
|
||||
de: [
|
||||
'Hey, schön von dir zu hören! Wie geht\'s dir heute?',
|
||||
'Danke für deine Nachricht! Was treibst du gerade Schönes?',
|
||||
'Interessanter Gedanke... erzähl mir gern mehr davon!',
|
||||
'Klingt gut, freut mich von dir zu lesen! 😊',
|
||||
],
|
||||
en: [
|
||||
'Hey! Great hearing from you! How is your day going?',
|
||||
'Thanks for the message! What are you up to right now?',
|
||||
'Interesting thought... tell me more about that!',
|
||||
'Sounds awesome, good to chat with you! 😊',
|
||||
],
|
||||
};
|
||||
|
||||
export function mockText(messages, opts = {}) {
|
||||
const sys = messages.find((m) => m.role === 'system')?.content || '';
|
||||
const user = [...messages].reverse().find((m) => m.role === 'user')?.content || '';
|
||||
const isEn = /reply in natural English/i.test(sys);
|
||||
const isDm = /DMs|Direktnachricht|private Nachricht/i.test(sys) || opts.isDm;
|
||||
|
||||
if (isDm) {
|
||||
const nameMatch = sys.match(/Du bist (.+?) \(@?([a-zA-Z0-9._-]+)\)/i);
|
||||
const charKey = (nameMatch?.[2] || nameMatch?.[1] || '').toLowerCase();
|
||||
for (const [key, lines] of Object.entries(PERSONA_DM_MOCKS)) {
|
||||
if (charKey.includes(key)) {
|
||||
return lines[Math.floor(Math.random() * lines.length)];
|
||||
}
|
||||
}
|
||||
const dmPool = isEn ? GENERIC_DM_MOCKS.en : GENERIC_DM_MOCKS.de;
|
||||
return dmPool[Math.floor(Math.random() * dmPool.length)];
|
||||
}
|
||||
|
||||
const pool = isEn ? MOCK_LINES.en : MOCK_LINES.de;
|
||||
const line = pool[Math.floor(Math.random() * pool.length)];
|
||||
if (opts.mockAsPost) {
|
||||
const name = sys.match(/Du bist (.+?) \(/)?.[1] || 'Jemand';
|
||||
return `${name} hier – ${line} (Mock-Antwort, kein API-Key gesetzt. Zum Post: "${user.slice(0, 60)}")`;
|
||||
}
|
||||
return line;
|
||||
}
|
||||
|
||||
export function mockImage(prompt) {
|
||||
const emojis = ['🎨', '🌇', '🍕', '🎸', '🌊', '☕', '🐈', '✨', '🌿', '🚀'];
|
||||
const emoji = emojis[Math.floor(Math.random() * emojis.length)];
|
||||
const text = String(prompt).slice(0, 60).replace(/[<>&]/g, '');
|
||||
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="640" height="640">
|
||||
<defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop offset="0%" stop-color="#6d5efc"/><stop offset="100%" stop-color="#e56ee0"/></linearGradient></defs>
|
||||
<rect width="640" height="640" fill="url(#g)"/>
|
||||
<text x="320" y="290" font-size="140" text-anchor="middle">${emoji}</text>
|
||||
<text x="320" y="400" font-size="22" fill="#fff" text-anchor="middle" font-family="sans-serif">Mock-Bild (kein API-Key)</text>
|
||||
<text x="320" y="440" font-size="18" fill="#ffffffcc" text-anchor="middle" font-family="sans-serif">${text}</text>
|
||||
</svg>`;
|
||||
return 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg)));
|
||||
}
|
||||
|
||||
// ---------------- Prompt Enhancement Helper ----------------
|
||||
export async function enhanceCharacterPrompt(envArg, data = {}) {
|
||||
const {
|
||||
name = '',
|
||||
gender = 'unspecified',
|
||||
bio = '',
|
||||
hobbies = [],
|
||||
personality = '',
|
||||
@@ -532,16 +401,19 @@ Deine Aufgabe ist es, aus den gegebenen Daten eines Charakters und den Änderung
|
||||
|
||||
WICHTIGSTE ANFORDERUNGEN:
|
||||
1. Erstelle ein prägnantes, modernes Profil, das wie eine echte Person auf Social Media wirkt (keine roboterhafte Sprache, keine kitschigen Klischees).
|
||||
2. "bio": Kurze, pointierte Profilbeschreibung (max 200 Zeichen).
|
||||
3. "hobbies": Array aus 3-5 interessanten, konkreten Hobbys/Interessen (Strings).
|
||||
4. "personality": Lebendige Beschreibung von Persönlichkeit, Tonfall, Schreibstil, Eigenheiten, typischen Emojis und Redewendungen (ca. 2-4 Sätze).
|
||||
5. "system_prompt": Ein extrem detaillierter und maßgeschneiderter System-Prompt für LLMs. Er soll dem Modell klare Rollenregeln, Tonfall, Meinungen und Reaktionsmuster vorgeben, damit der Charakter konsistent und lebendig bleibt.
|
||||
6. "avatar_prompt": Ein aussagekräftiger englischer Bild-Prompt für ein realistisches Social-Media-Portrait / Selfie dieser Person (z.B. "portrait photo of a 24yo woman with short curly brown hair, smiling candidly in an art studio, natural light, 8k, f/1.8").
|
||||
7. "change_summary": Eine kurze Zusammenfassung (1 Satz auf ${isEn ? 'Englisch' : 'Deutsch'}), was verbessert oder angepasst wurde.
|
||||
2. "gender": Geschlecht des Charakters ("female", "male", "nonbinary" oder "unspecified"). Falls bereits angegeben, beibehalten; falls 'unspecified', passend zum Kontext bestimmen.
|
||||
3. Beachte das Geschlecht ('female' = weiblich (sie/ihr), 'male' = männlich (er/ihm), 'nonbinary' = divers/non-binär, 'unspecified' = neutral) konsistent bei Grammatik, Berufsbezeichnungen (z. B. Künstlerin vs. Künstler), Pronomen und dem Bild-Prompt ("avatar_prompt").
|
||||
4. "bio": Kurze, pointierte Profilbeschreibung (max 200 Zeichen).
|
||||
5. "hobbies": Array aus 3-5 interessanten, konkreten Hobbys/Interessen (Strings).
|
||||
6. "personality": Lebendige Beschreibung von Persönlichkeit, Tonfall, Schreibstil, Eigenheiten, typischen Emojis und Redewendungen (ca. 2-4 Sätze).
|
||||
7. "system_prompt": Ein extrem detaillierter und maßgeschneiderter System-Prompt für LLMs. Er soll dem Modell klare Rollenregeln, Tonfall, Meinungen und Reaktionsmuster vorgeben, damit der Charakter konsistent und lebendig bleibt.
|
||||
8. "avatar_prompt": Ein aussagekräftiger englischer Bild-Prompt für ein realistisches Social-Media-Portrait / Selfie dieser Person (z.B. "portrait photo of a 24yo woman with short curly brown hair, smiling candidly in an art studio, natural light, 8k, f/1.8").
|
||||
9. "change_summary": Eine kurze Zusammenfassung (1 Satz auf ${isEn ? 'Englisch' : 'Deutsch'}), was verbessert oder angepasst wurde.
|
||||
|
||||
ANTWORTE AUSSCHLIESSLICH ALS REINES JSON (ohne Markdown, ohne \`\`\`json, ohne Erklärung vor oder nach dem JSON):
|
||||
{
|
||||
"name": "...",
|
||||
"gender": "female" | "male" | "nonbinary" | "unspecified",
|
||||
"bio": "...",
|
||||
"hobbies": ["...", "..."],
|
||||
"personality": "...",
|
||||
@@ -550,8 +422,10 @@ ANTWORTE AUSSCHLIESSLICH ALS REINES JSON (ohne Markdown, ohne \`\`\`json, ohne E
|
||||
"change_summary": "..."
|
||||
}`;
|
||||
|
||||
const genderLabelText = gender === 'female' ? 'weiblich' : (gender === 'male' ? 'männlich' : (gender === 'nonbinary' ? 'non-binär / divers' : 'nicht angegeben'));
|
||||
const userPrompt = `Hier sind die aktuellen Angaben zum Charakter:
|
||||
Name: ${name || '(noch kein Name vergeben)'}
|
||||
Geschlecht: ${genderLabelText} (${gender})
|
||||
Sprache: ${isEn ? 'Englisch' : 'Deutsch'}
|
||||
Bio: ${bio || '(leer)'}
|
||||
Hobbys: ${hobbiesStr || '(leer)'}
|
||||
@@ -569,7 +443,7 @@ Gib jetzt das optimierte JSON-Objekt zurück:`;
|
||||
{ role: 'user', content: userPrompt },
|
||||
], { temperature: 0.7, maxTokens: 900 });
|
||||
|
||||
let cleaned = raw.replace(/```json/gi, '').replace(/```/g, '').trim();
|
||||
let cleaned = raw.replace(/\`\`\`json/gi, '').replace(/\`\`\`/g, '').trim();
|
||||
const sIdx = cleaned.indexOf('{');
|
||||
const eIdx = cleaned.lastIndexOf('}');
|
||||
if (sIdx !== -1 && eIdx !== -1) {
|
||||
@@ -577,8 +451,12 @@ Gib jetzt das optimierte JSON-Objekt zurück:`;
|
||||
}
|
||||
const parsed = JSON.parse(cleaned);
|
||||
|
||||
const validGenders = ['female', 'male', 'nonbinary', 'unspecified'];
|
||||
const resolvedGender = validGenders.includes(parsed.gender) ? parsed.gender : (validGenders.includes(gender) ? gender : 'unspecified');
|
||||
|
||||
return {
|
||||
name: parsed.name || name || 'Charakter',
|
||||
gender: resolvedGender,
|
||||
bio: parsed.bio || bio,
|
||||
hobbies: Array.isArray(parsed.hobbies) && parsed.hobbies.length ? parsed.hobbies : hobbiesArr,
|
||||
personality: parsed.personality || personality,
|
||||
@@ -588,42 +466,6 @@ Gib jetzt das optimierte JSON-Objekt zurück:`;
|
||||
};
|
||||
} catch (err) {
|
||||
console.error('enhanceCharacterPrompt error:', err.message);
|
||||
return mockEnhancePrompt(data);
|
||||
throw new Error(`Prompt-Optimierung fehlgeschlagen: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function mockEnhancePrompt(data = {}) {
|
||||
const {
|
||||
name = 'Alex',
|
||||
bio = '',
|
||||
hobbies = [],
|
||||
personality = '',
|
||||
system_prompt = '',
|
||||
instruction = '',
|
||||
language = 'de',
|
||||
} = data;
|
||||
|
||||
const isEn = language === 'en';
|
||||
const hobbiesArr = Array.isArray(hobbies) && hobbies.length ? hobbies : ['Fotografie', 'Kaffee-Kultur', 'Indie-Musik'];
|
||||
const inst = (instruction || '').trim();
|
||||
|
||||
const newBio = bio || (isEn ? 'Exploring the city, one espresso at a time.' : 'Irgendwo zwischen Großstadttrubel, gutem Kaffee und neuen Ideen.');
|
||||
const extraStyle = inst ? ` Besonderer Fokus: ${inst}.` : '';
|
||||
const newPersonality = (personality || (isEn ? 'Warm, witty, writes in short expressive bursts with occasional dry humor.' : 'Authentisch, neugierig, mit trockenem Humor und einem Auge fürs Detail.')) + extraStyle;
|
||||
|
||||
const newPrompt = system_prompt || (isEn
|
||||
? `You are ${name}. You speak naturally, share genuine thoughts on your passions, and react warmly to people without sounding like an AI assistant.`
|
||||
: `Du bist ${name}. Du schreibst mit einem natürlichen, lebendigen Tonfall, vertrittst eine klare eigene Meinung und bringst deine Hobbys (${hobbiesArr.join(', ')}) organisch ins Gespräch ein.${extraStyle}`);
|
||||
|
||||
return {
|
||||
name: name || 'Alex',
|
||||
bio: newBio,
|
||||
hobbies: hobbiesArr,
|
||||
personality: newPersonality,
|
||||
system_prompt: newPrompt,
|
||||
avatar_prompt: `candid social media portrait photo of a stylish person named ${name}, warm lighting, aesthetic composition, high resolution`,
|
||||
change_summary: isEn
|
||||
? (inst ? `Integrated "${inst}" and sharpened persona.` : 'Sharpened persona, bio, and system prompt.')
|
||||
: (inst ? `Änderungswunsch "${inst}" integriert und Prompt geschärft.` : 'Bio, Schreibstil und System-Prompt verfeinert.'),
|
||||
};
|
||||
}
|
||||
@@ -28,6 +28,7 @@ CREATE TABLE IF NOT EXISTS characters (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
handle VARCHAR(50) UNIQUE NOT NULL,
|
||||
gender VARCHAR(20) NOT NULL DEFAULT 'unspecified',
|
||||
bio TEXT NOT NULL DEFAULT '',
|
||||
hobbies JSONB NOT NULL DEFAULT '[]'::jsonb,
|
||||
personality TEXT NOT NULL DEFAULT '',
|
||||
@@ -91,9 +92,14 @@ export async function initDb() {
|
||||
if (!ready) {
|
||||
ready = (async () => {
|
||||
await pool.query(SCHEMA);
|
||||
await pool.query('ALTER TABLE characters ADD COLUMN IF NOT EXISTS gender VARCHAR(20) NOT NULL DEFAULT \'unspecified\';');
|
||||
await pool.query('ALTER TABLE characters ADD COLUMN IF NOT EXISTS is_banned INTEGER NOT NULL DEFAULT 0;');
|
||||
await pool.query('ALTER TABLE characters ADD COLUMN IF NOT EXISTS banned_at BIGINT;');
|
||||
await pool.query('ALTER TABLE characters ADD COLUMN IF NOT EXISTS system_prompt TEXT DEFAULT \'\';');
|
||||
await pool.query(`
|
||||
UPDATE characters SET gender = 'female' WHERE id IN ('char-mia', 'char-luna', 'char-sara', 'char-valentina', 'char-aylin') AND (gender IS NULL OR gender = 'unspecified');
|
||||
UPDATE characters SET gender = 'male' WHERE id IN ('char-jonas', 'char-helmut', 'char-tim', 'char-eichhorn', 'char-ben') AND (gender IS NULL OR gender = 'unspecified');
|
||||
`);
|
||||
await pool.query('ALTER TABLE messages ADD COLUMN IF NOT EXISTS is_read INTEGER NOT NULL DEFAULT 0;');
|
||||
await pool.query('CREATE INDEX IF NOT EXISTS idx_messages_unread ON messages(char_id, sender, is_read);');
|
||||
const unreadMigrated = await pool.query("SELECT value FROM app_state WHERE key = 'migrated_messages_is_read' LIMIT 1;");
|
||||
@@ -180,6 +186,7 @@ export async function getChars(options = {}) {
|
||||
const res = await pool.query(query);
|
||||
return res.rows.map((r) => ({
|
||||
...r,
|
||||
gender: r.gender || 'unspecified',
|
||||
is_banned: r.is_banned ? 1 : 0,
|
||||
hobbies: Array.isArray(r.hobbies) ? r.hobbies : safeJson(r.hobbies, []),
|
||||
system_prompt: r.system_prompt || '',
|
||||
@@ -328,6 +335,12 @@ export async function updateCharacter(id, fields) {
|
||||
updates.push(`language = $${idx++}`);
|
||||
values.push(language === 'en' ? 'en' : 'de');
|
||||
}
|
||||
if (fields.gender !== undefined) {
|
||||
const validGenders = ['female', 'male', 'nonbinary', 'unspecified'];
|
||||
const g = validGenders.includes(fields.gender) ? fields.gender : 'unspecified';
|
||||
updates.push(`gender = $${idx++}`);
|
||||
values.push(g);
|
||||
}
|
||||
if (fields.is_banned !== undefined || fields.isBanned !== undefined) {
|
||||
const isBanned = (fields.is_banned !== undefined ? fields.is_banned : fields.isBanned) ? 1 : 0;
|
||||
updates.push(`is_banned = $${idx++}`);
|
||||
|
||||
+65
-26
@@ -41,7 +41,11 @@ export async function reactToUserPost(post, chars) {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('reactToUserPost failed for', c.handle, e);
|
||||
console.error('reactToUserPost failed for', c.handle, e.message);
|
||||
await pool.query(
|
||||
'INSERT INTO comments (id, post_id, author_type, author_id, text, created_at) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||
[uid(), post.id, 'char', c.id, `[Fehler]: ${e.message}`, Date.now()]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +83,11 @@ export async function charactersEngageEachOther(post, author, chars) {
|
||||
[uid(), post.id, 'char', c.id, text, Date.now()]
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('charsEngageEachOther failed', e);
|
||||
console.error('charsEngageEachOther failed for', c.handle, e.message);
|
||||
await pool.query(
|
||||
'INSERT INTO comments (id, post_id, author_type, author_id, text, created_at) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||
[uid(), post.id, 'char', c.id, `[Fehler]: ${e.message}`, Date.now()]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +114,11 @@ export async function charsReplyToUserComment(comment, post, chars) {
|
||||
[uid(), post.id, 'char', c.id, text, Date.now()]
|
||||
);
|
||||
} catch (e) {
|
||||
console.error('charsReplyToUserComment failed', e);
|
||||
console.error('charsReplyToUserComment failed for', c.handle, e.message);
|
||||
await pool.query(
|
||||
'INSERT INTO comments (id, post_id, author_type, author_id, text, created_at) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||
[uid(), post.id, 'char', c.id, `[Fehler]: ${e.message}`, Date.now()]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +153,11 @@ export async function sendProactiveDM(char, contextInstruction) {
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('sendProactiveDM failed for', char.handle, e);
|
||||
console.error('sendProactiveDM failed for', char.handle, e.message);
|
||||
await pool.query(
|
||||
'INSERT INTO messages (id, char_id, sender, text, created_at, is_read) VALUES ($1, $2, $3, $4, $5, $6);',
|
||||
[uid(), char.id, 'char', `[Fehler]: ${e.message}`, Date.now() + 1000, 0]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,16 +171,21 @@ export async function genCharPost(char) {
|
||||
const worldLang = settings.world_language || 'mixed';
|
||||
|
||||
let text;
|
||||
if (wantImage) {
|
||||
text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade etwas auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: 'Schreib EINEN kurzen Social-Media-Post (2-4 Sätze max) zu einem Bild, das du postest. Beschreibe die Stimmung des Bildes in einem Satz am Ende in Anführungszeichen als Bild-Beschreibung, Format: [BILD: dein englischer Bild-Prompt].' },
|
||||
], { maxTokens: 200, mockAsPost: true });
|
||||
} else {
|
||||
text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade etwas auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: 'Schreib EINEN kurzen, lebendigen Social-Media-Post (1-3 Sätze) über irgendetwas aus deinem Leben, deinen Hobbys oder deiner Meinung. Wie ein echter Mensch, nicht perfekt, mit Emojis wenn es passt.' },
|
||||
], { maxTokens: 150, mockAsPost: true });
|
||||
try {
|
||||
if (wantImage) {
|
||||
text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade etwas auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: 'Schreib EINEN kurzen Social-Media-Post (2-4 Sätze max) zu einem Bild, das du postest. Beschreibe die Stimmung des Bildes in einem Satz am Ende in Anführungszeichen als Bild-Beschreibung, Format: [BILD: dein englischer Bild-Prompt].' },
|
||||
], { maxTokens: 200 });
|
||||
} else {
|
||||
text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade etwas auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: 'Schreib EINEN kurzen, lebendigen Social-Media-Post (1-3 Sätze) über irgendetwas aus deinem Leben, deinen Hobbys oder deiner Meinung. Wie ein echter Mensch, nicht perfekt, mit Emojis wenn es passt.' },
|
||||
], { maxTokens: 150 });
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('genCharPost AI failed for', char.handle, err.message);
|
||||
text = `[Fehler]: ${err.message}`;
|
||||
}
|
||||
|
||||
let imageKey = null;
|
||||
@@ -172,7 +193,10 @@ export async function genCharPost(char) {
|
||||
if (m && hasKey() && imagesEnabled) {
|
||||
try {
|
||||
imageKey = await genImage(null, m[1], '1:1');
|
||||
} catch (e) { console.error('post image failed', e); }
|
||||
} catch (e) {
|
||||
console.error('post image failed', e.message);
|
||||
text += `\n[Fehler Bild]: ${e.message}`;
|
||||
}
|
||||
text = text.replace(m[0], '').trim();
|
||||
} else if (m) {
|
||||
text = text.replace(m[0], '').trim();
|
||||
@@ -206,10 +230,15 @@ export async function updateBotAvatarAutonomously(char, chars = []) {
|
||||
? 'You just changed your social media profile picture! Write ONE short, casual post (1-2 sentences) about your new avatar/selfie. Stay in character, use emojis naturally.'
|
||||
: 'Du hast gerade dein Profilbild geändert! Schreib EINEN kurzen, lockeren Social-Media-Post (1-2 Sätze) zu deinem neuen Profilbild/Selfie. Natürlich in deinem Stil mit passenden Emojis.';
|
||||
|
||||
const postText = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade dein neues Profilbild auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: postInstruction },
|
||||
], { maxTokens: 120, mockAsPost: true });
|
||||
let postText;
|
||||
try {
|
||||
postText = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du postest gerade dein neues Profilbild auf deinen Feed.', worldLang) },
|
||||
{ role: 'user', content: postInstruction },
|
||||
], { maxTokens: 120 });
|
||||
} catch (err) {
|
||||
postText = `[Fehler]: ${err.message}`;
|
||||
}
|
||||
|
||||
const cleanText = (postText || 'Neues Profilbild! ✨').replace(/\[BILD:[\s\S]*?\]/gi, '').trim();
|
||||
|
||||
@@ -234,7 +263,7 @@ export async function updateBotAvatarAutonomously(char, chars = []) {
|
||||
return { avatarKey: newAvatarKey, post };
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('updateBotAvatarAutonomously error for', char.handle, e);
|
||||
console.error('updateBotAvatarAutonomously error for', char.handle, e.message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -250,10 +279,16 @@ export async function triggerCharPhotoPost(char, chars = []) {
|
||||
? 'You are posting a new photo to your feed right now! Write ONE short social media post (1-3 sentences) describing the moment or your thought. Conclude with the visual photo description inside brackets: [BILD: detailed English photo description].'
|
||||
: 'Du postest jetzt ein neues Foto auf deinen Feed! Schreib EINEN kurzen Social-Media-Post (1-3 Sätze) über diesen Moment oder dein Erlebnis. Am Ende die visuelle englische Bildbeschreibung in eckigen Klammern: [BILD: detaillierter englischer Foto-Prompt].';
|
||||
|
||||
let text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du teilst ein neues Foto auf deinem Feed.', worldLang) },
|
||||
{ role: 'user', content: postPrompt },
|
||||
], { maxTokens: 200, mockAsPost: true });
|
||||
let text;
|
||||
try {
|
||||
text = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(char, 'Du teilst ein neues Foto auf deinem Feed.', worldLang) },
|
||||
{ role: 'user', content: postPrompt },
|
||||
], { maxTokens: 200 });
|
||||
} catch (err) {
|
||||
console.error('triggerCharPhotoPost AI failed for', char.handle, err.message);
|
||||
text = `[Fehler]: ${err.message}`;
|
||||
}
|
||||
|
||||
let imageKey = null;
|
||||
const m = text.match(/\[BILD:\s*([\s\S]+?)\]/);
|
||||
@@ -261,14 +296,18 @@ export async function triggerCharPhotoPost(char, chars = []) {
|
||||
try {
|
||||
imageKey = await genImage(null, m[1].trim(), '1:1');
|
||||
} catch (e) {
|
||||
console.error('triggerCharPhotoPost image generation failed:', e);
|
||||
console.error('triggerCharPhotoPost image generation failed:', e.message);
|
||||
text += `\n[Fehler Bild]: ${e.message}`;
|
||||
}
|
||||
text = text.replace(m[0], '').trim();
|
||||
} else {
|
||||
try {
|
||||
const hobbiesStr = (char.hobbies || []).join(', ');
|
||||
imageKey = await genImage(null, `authentic photo taken by ${char.name}, related to ${char.bio || ''}, ${hobbiesStr}, aesthetic composition, realistic`, '1:1');
|
||||
} catch (e) {}
|
||||
} catch (e) {
|
||||
console.error('triggerCharPhotoPost fallback image generation failed:', e.message);
|
||||
text += `\n[Fehler Bild]: ${e.message}`;
|
||||
}
|
||||
}
|
||||
|
||||
const post = {
|
||||
|
||||
+53
-20
@@ -33,14 +33,14 @@ app.use('*', async (c, next) => {
|
||||
const USER = { id: 'user', name: 'Du', handle: 'du' };
|
||||
|
||||
function charBrief(c) {
|
||||
return { id: c.id, name: c.name, handle: c.handle, avatarKey: c.avatar_key, isBanned: c.is_banned === 1, systemPrompt: c.system_prompt || '' };
|
||||
return { id: c.id, name: c.name, handle: c.handle, gender: c.gender || 'unspecified', avatarKey: c.avatar_key, isBanned: c.is_banned === 1, systemPrompt: c.system_prompt || '' };
|
||||
}
|
||||
|
||||
async function authorOf(post) {
|
||||
if (post.author_type === 'user') return { ...USER, avatarKey: null, isBanned: false };
|
||||
if (post.author_type === 'user') return { ...USER, avatarKey: null, isBanned: false, gender: 'unspecified' };
|
||||
const res = await pool.query('SELECT * FROM characters WHERE id = $1 LIMIT 1;', [post.author_id]);
|
||||
const c = res.rows[0];
|
||||
return c ? charBrief(c) : { id: 'unknown', name: '?', handle: '?', avatarKey: null, isBanned: false };
|
||||
return c ? charBrief(c) : { id: 'unknown', name: '?', handle: '?', avatarKey: null, isBanned: false, gender: 'unspecified' };
|
||||
}
|
||||
|
||||
function runBackground(promise) {
|
||||
@@ -94,8 +94,13 @@ app.post('/api/posts', async (c) => {
|
||||
await updateUserActivity();
|
||||
|
||||
let imageKey = null;
|
||||
if (generateImage && hasKey()) {
|
||||
try { imageKey = await genImage(null, text, '1:1'); } catch (e) { console.error('Image generation error:', e); }
|
||||
if (generateImage) {
|
||||
try {
|
||||
imageKey = await genImage(null, text, '1:1');
|
||||
} catch (e) {
|
||||
console.error('Image generation error:', e);
|
||||
return c.json({ error: `Bildgenerierung fehlgeschlagen: ${e.message}` }, 500);
|
||||
}
|
||||
}
|
||||
|
||||
const post = {
|
||||
@@ -186,6 +191,7 @@ app.get('/api/characters', async (c) => {
|
||||
const n = await pool.query('SELECT COUNT(*)::int AS n FROM posts WHERE author_id = $1;', [ch.id]);
|
||||
out.push({
|
||||
...charBrief(ch),
|
||||
gender: ch.gender || 'unspecified',
|
||||
bio: ch.bio,
|
||||
hobbies: ch.hobbies,
|
||||
personality: ch.personality,
|
||||
@@ -200,25 +206,30 @@ app.get('/api/characters', async (c) => {
|
||||
});
|
||||
|
||||
app.post('/api/characters', async (c) => {
|
||||
const { name, bio, hobbies, personality, system_prompt, language, avatarKey: customAvatarKey } = await c.req.json().catch(() => ({}));
|
||||
const { name, gender, bio, hobbies, personality, system_prompt, language, avatarKey: customAvatarKey } = await c.req.json().catch(() => ({}));
|
||||
if (!name || !name.trim()) return c.json({ error: 'Name fehlt' }, 400);
|
||||
|
||||
await updateUserActivity();
|
||||
|
||||
const validGenders = ['female', 'male', 'nonbinary', 'unspecified'];
|
||||
const cleanGender = validGenders.includes(gender) ? gender : 'unspecified';
|
||||
|
||||
const handle = name.toLowerCase().replace(/[^a-z0-9]/g, '').slice(0, 12) + '.' + Math.floor(Math.random() * 90 + 10);
|
||||
let avatarKey = customAvatarKey || null;
|
||||
if (!avatarKey && hasKey()) {
|
||||
try { avatarKey = await genImage(null, `friendly social media profile avatar portrait of a person, ${name}. ${bio || ''}`, '1:1'); } catch (e) { console.error(e); }
|
||||
const genderDesc = cleanGender === 'female' ? 'woman' : (cleanGender === 'male' ? 'man' : (cleanGender === 'nonbinary' ? 'non-binary person' : 'person'));
|
||||
try { avatarKey = await genImage(null, `friendly social media profile avatar portrait of a ${genderDesc}, ${name}. ${bio || ''}`, '1:1'); } catch (e) { console.error(e); }
|
||||
}
|
||||
|
||||
const id = uid();
|
||||
await pool.query(
|
||||
`INSERT INTO characters (id, name, handle, bio, hobbies, personality, system_prompt, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, 1);`,
|
||||
`INSERT INTO characters (id, name, handle, gender, bio, hobbies, personality, system_prompt, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, 1);`,
|
||||
[
|
||||
id,
|
||||
name.trim().slice(0, 40),
|
||||
handle,
|
||||
cleanGender,
|
||||
(bio || '').slice(0, 500),
|
||||
JSON.stringify(Array.isArray(hobbies) ? hobbies : []),
|
||||
(personality || '').slice(0, 1000),
|
||||
@@ -229,7 +240,7 @@ app.post('/api/characters', async (c) => {
|
||||
]
|
||||
);
|
||||
|
||||
return c.json({ ok: true, id, avatarKey });
|
||||
return c.json({ ok: true, id, avatarKey, gender: cleanGender });
|
||||
});
|
||||
|
||||
app.get('/api/characters/:id', async (c) => {
|
||||
@@ -296,11 +307,13 @@ app.post('/api/characters/:id/avatar', async (c) => {
|
||||
if (!char) return c.json({ error: 'Charakter nicht gefunden' }, 404);
|
||||
|
||||
const body = await c.req.json().catch(() => ({}));
|
||||
let { avatarKey, prompt } = body;
|
||||
let { avatarKey, prompt, gender } = body;
|
||||
|
||||
if (body.generate) {
|
||||
const hobbies = Array.isArray(char.hobbies) ? char.hobbies : safeJson(char.hobbies, []);
|
||||
const imgPrompt = prompt || `social media profile avatar portrait selfie of ${char.name}, ${char.bio || ''}, interests: ${hobbies.join(', ')}, natural daylight, 8k, selfie style`;
|
||||
const g = gender || char.gender || 'unspecified';
|
||||
const genderDesc = g === 'female' ? 'woman' : (g === 'male' ? 'man' : (g === 'nonbinary' ? 'non-binary person' : 'person'));
|
||||
const imgPrompt = prompt || `social media profile avatar portrait selfie of a ${genderDesc}, ${char.name}, ${char.bio || ''}, interests: ${hobbies.join(', ')}, natural daylight, 8k, selfie style`;
|
||||
try {
|
||||
avatarKey = await genImage(null, imgPrompt, '1:1');
|
||||
} catch (e) {
|
||||
@@ -317,9 +330,10 @@ app.post('/api/characters/:id/avatar', async (c) => {
|
||||
|
||||
app.post('/api/characters/generate-avatar', async (c) => {
|
||||
const body = await c.req.json().catch(() => ({}));
|
||||
const { name = 'User', bio = '', hobbies = [], prompt = '' } = body;
|
||||
const { name = 'User', gender = 'unspecified', bio = '', hobbies = [], prompt = '' } = body;
|
||||
const hobbiesStr = Array.isArray(hobbies) ? hobbies.join(', ') : String(hobbies || '');
|
||||
const imgPrompt = prompt || `social media avatar portrait photo of ${name}, ${bio}, interests: ${hobbiesStr}, friendly, high resolution, 8k, selfie style`;
|
||||
const genderDesc = gender === 'female' ? 'woman' : (gender === 'male' ? 'man' : (gender === 'nonbinary' ? 'non-binary person' : 'person'));
|
||||
const imgPrompt = prompt || `social media avatar portrait photo of a ${genderDesc}, ${name}, ${bio}, interests: ${hobbiesStr}, friendly, high resolution, 8k, selfie style`;
|
||||
try {
|
||||
const key = await genImage(null, imgPrompt, '1:1');
|
||||
return c.json({ ok: true, avatarKey: key });
|
||||
@@ -447,9 +461,9 @@ app.post('/api/daily-character', async (c) => {
|
||||
const avatarKey = spec.avatar;
|
||||
|
||||
await pool.query(
|
||||
`INSERT INTO characters (id, name, handle, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 0);`,
|
||||
[id, spec.name, handle, spec.bio, JSON.stringify(spec.hobbies), spec.personality, spec.language, avatarKey, Date.now()]
|
||||
`INSERT INTO characters (id, name, handle, gender, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, 0);`,
|
||||
[id, spec.name, handle, spec.gender || 'unspecified', spec.bio, JSON.stringify(spec.hobbies), spec.personality, spec.language, avatarKey, Date.now()]
|
||||
);
|
||||
await setState('last_daily_char', today);
|
||||
await setState('last_daily_char_id', id);
|
||||
@@ -458,6 +472,7 @@ app.post('/api/daily-character', async (c) => {
|
||||
id,
|
||||
name: spec.name,
|
||||
handle,
|
||||
gender: spec.gender || 'unspecified',
|
||||
bio: spec.bio,
|
||||
hobbies: spec.hobbies,
|
||||
personality: spec.personality,
|
||||
@@ -545,13 +560,25 @@ app.post('/api/feed-tick', async (c) => {
|
||||
const avatarChangeChance = (parseInt(settings.bot_avatar_update_chance, 10) ?? 15) / 100;
|
||||
const avatarChangeEnabled = settings.bot_avatar_update_enabled !== '0';
|
||||
|
||||
if (body?.manual) {
|
||||
try {
|
||||
const char = chars[Math.floor(Math.random() * chars.length)];
|
||||
const post = await genCharPost(char);
|
||||
if (post) await charactersEngageEachOther(post, char, chars);
|
||||
return c.json({ generated: true, post });
|
||||
} catch (e) {
|
||||
console.error('Manual feed tick error:', e);
|
||||
return c.json({ error: e.message || 'Fehler beim Feed-Tick' }, 500);
|
||||
}
|
||||
}
|
||||
|
||||
runBackground((async () => {
|
||||
for (let i = 0; i < postsCount; i++) {
|
||||
try {
|
||||
const char = chars[Math.floor(Math.random() * chars.length)];
|
||||
const post = await genCharPost(char);
|
||||
if (post) await charactersEngageEachOther(post, char, chars);
|
||||
} catch (e) { console.error(e); }
|
||||
} catch (e) { console.error('Background feed tick error:', e); }
|
||||
}
|
||||
// Configurable chance for an active character to slide into user's DMs during a tick
|
||||
if (Math.random() < tickDmChance) {
|
||||
@@ -695,14 +722,16 @@ app.post('/api/chats/:id/messages', async (c) => {
|
||||
const actTxt = activity.rows.length ? `\nDeine letzten Posts (Kontext fürs Gespräch): ${activity.rows.map((p) => `"${p.text.slice(0, 80)}"`).join('; ')}` : '';
|
||||
|
||||
let reply;
|
||||
let isError = false;
|
||||
try {
|
||||
reply = await chatText(null, [
|
||||
{ role: 'system', content: personaSystemPrompt(ch, 'Ihr schreibt gerade DMs.' + actTxt) },
|
||||
...conv,
|
||||
], { maxTokens: 250 });
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return c.json({ error: 'KI-Fehler' }, 502);
|
||||
console.error('Chat message AI error:', e);
|
||||
reply = `[Fehler]: ${e.message}`;
|
||||
isError = true;
|
||||
}
|
||||
|
||||
await pool.query(
|
||||
@@ -710,6 +739,10 @@ app.post('/api/chats/:id/messages', async (c) => {
|
||||
[uid(), ch.id, 'char', reply, Date.now() + 1, 1]
|
||||
);
|
||||
|
||||
if (isError) {
|
||||
return c.json({ ok: false, error: reply.replace(/^\[Fehler\]:\s*/, ''), reply }, 500);
|
||||
}
|
||||
|
||||
return c.json({ ok: true, reply });
|
||||
});
|
||||
|
||||
|
||||
+38
-10
@@ -17,6 +17,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-mia',
|
||||
name: 'Mia',
|
||||
handle: 'mia.art',
|
||||
gender: 'female',
|
||||
language: 'de',
|
||||
bio: '23, Kunststudentin in Berlin. Sieht in allem ein Motiv.',
|
||||
hobbies: ['Zeichnen', 'Fotografieren', 'Bastelabende'],
|
||||
@@ -27,6 +28,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-jonas',
|
||||
name: 'Jonas',
|
||||
handle: 'jonas.lifts',
|
||||
gender: 'male',
|
||||
language: 'de',
|
||||
bio: '27, Fitness-Bruder. Spricht fast nur in Macros und Supplements.',
|
||||
hobbies: ['Krafttraining', 'Meal Prep', 'Protein-Rezepte'],
|
||||
@@ -37,6 +39,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-helmut',
|
||||
name: 'Dr. Helmut Kurtz',
|
||||
handle: 'helmut62',
|
||||
gender: 'male',
|
||||
language: 'de',
|
||||
bio: '62, Rentner und früherer Ingenieur. Versucht verzweifelt, TikTok zu verstehen.',
|
||||
hobbies: ['Modellbau', 'Gärtnern', 'Alte Meme-Seiten'],
|
||||
@@ -47,6 +50,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-luna',
|
||||
name: 'Luna',
|
||||
handle: 'luna.noir',
|
||||
gender: 'female',
|
||||
language: 'de',
|
||||
bio: '21, Goth aus Leipzig. Trägt nur schwarz, hört nur depressive Musik.',
|
||||
hobbies: ['Horrorfilme', 'Poetry', 'Vintage-Läden'],
|
||||
@@ -57,6 +61,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-sara',
|
||||
name: 'Sara',
|
||||
handle: 'sara.snacks',
|
||||
gender: 'female',
|
||||
language: 'de',
|
||||
bio: '29, Foodie und Snack-Journalistin. Bewertet alles was man essen kann.',
|
||||
hobbies: ['Kochen', 'Streetfood-Touren', 'Bäckerei-Reviews'],
|
||||
@@ -67,6 +72,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-tim',
|
||||
name: 'Tim',
|
||||
handle: 'tim.gamer',
|
||||
gender: 'male',
|
||||
language: 'de',
|
||||
bio: '19, Zocker aus Duisburg. Schläft tagsüber, raidet nachts.',
|
||||
hobbies: ['Zocken', 'Anime', 'Energiegetränke'],
|
||||
@@ -77,6 +83,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-valentina',
|
||||
name: 'Valentina',
|
||||
handle: 'val.travels',
|
||||
gender: 'female',
|
||||
language: 'en',
|
||||
bio: '28, digital nomad. Currently in Bali, next week who knows.',
|
||||
hobbies: ['Surfen', 'Yoga', 'Hostel-Hopping'],
|
||||
@@ -87,6 +94,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-eichhorn',
|
||||
name: 'Professor Eichhorn',
|
||||
handle: 'eichhorn.phil',
|
||||
gender: 'male',
|
||||
language: 'de',
|
||||
bio: '54, Philosophie-Dozent. Beantwortet jede Frage mit einer Gegenfrage.',
|
||||
hobbies: ['Lesen', 'Kaffee', 'Diskutieren'],
|
||||
@@ -97,6 +105,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-aylin',
|
||||
name: 'Aylin',
|
||||
handle: 'aylin.codes',
|
||||
gender: 'female',
|
||||
language: 'de',
|
||||
bio: '26, Backend-Entwicklerin. Debuggt auch am Wochenende.',
|
||||
hobbies: ['Programmieren', 'Boardgames', 'Kaffee'],
|
||||
@@ -107,6 +116,7 @@ export const SEED_CHARACTERS = [
|
||||
id: 'char-ben',
|
||||
name: 'Ben',
|
||||
handle: 'ben.thewoke',
|
||||
gender: 'male',
|
||||
language: 'en',
|
||||
bio: '31, wellness guru from LA. Manifesting a better world.',
|
||||
hobbies: ['Meditation', 'Cold plunges', 'Journaling'],
|
||||
@@ -186,15 +196,25 @@ export const SEED_POSTS = [
|
||||
|
||||
export function personaSystemPrompt(char, extra = '', overrideLang = null) {
|
||||
const effectiveLang = (overrideLang && overrideLang !== 'mixed') ? overrideLang : char.language;
|
||||
const lang = effectiveLang === 'en'
|
||||
const isEn = effectiveLang === 'en';
|
||||
const lang = isEn
|
||||
? 'You ALWAYS reply in natural English.'
|
||||
: 'Du antwortest IMMER auf Deutsch.';
|
||||
const hobbies = (char.hobbies || []).join(', ');
|
||||
const rules = 'Regeln: Bleibe IMMER voll in deiner Rolle. Schreibe wie ein echter Mensch in einer Social-Media-App – nie wie ein Assistent. Keine Listen, kein "Als KI…", keine Erklärungen darüber, dass du eine KI bist. Schreib wie auf einer echten Plattform.';
|
||||
|
||||
const genderPrompt = char.gender && char.gender !== 'unspecified'
|
||||
? (char.gender === 'female'
|
||||
? (isEn ? 'Gender: female (she/her). Use feminine self-references and pronouns.' : 'Geschlecht: weiblich (sie/ihr). Verwende für dich selbst passende weibliche Formen (z. B. "Studentin", "Fotografin", etc.).')
|
||||
: (char.gender === 'male'
|
||||
? (isEn ? 'Gender: male (he/him). Use masculine self-references and pronouns.' : 'Geschlecht: männlich (er/ihm). Verwende für dich selbst passende männliche Formen.')
|
||||
: (isEn ? 'Gender: non-binary (they/them).' : 'Geschlecht: non-binär / divers (they/them).')))
|
||||
: '';
|
||||
|
||||
if (char.system_prompt && char.system_prompt.trim()) {
|
||||
return [
|
||||
`Du bist ${char.name} (@${char.handle}) – eine Figur in einem KI-only Social Media Netzwerk. Der Nutzer ist der einzige echte Mensch, alle anderen sind KI.`,
|
||||
genderPrompt,
|
||||
`Individuelle Persona & Anweisungen:\n${char.system_prompt.trim()}`,
|
||||
char.bio ? `Hintergrund: ${char.bio}` : '',
|
||||
hobbies ? `Hobbys: ${hobbies}` : '',
|
||||
@@ -206,6 +226,7 @@ export function personaSystemPrompt(char, extra = '', overrideLang = null) {
|
||||
|
||||
return [
|
||||
`Du bist ${char.name} (@${char.handle}) – eine Figur in einem KI-only Social Media Netzwerk. Der Nutzer ist der einzige echte Mensch, alle anderen sind KI.`,
|
||||
genderPrompt,
|
||||
`Hintergrund: ${char.bio}`,
|
||||
`Hobbys: ${hobbies}`,
|
||||
`Persönlichkeit & Schreibstil: ${char.personality}`,
|
||||
@@ -217,8 +238,14 @@ export function personaSystemPrompt(char, extra = '', overrideLang = null) {
|
||||
|
||||
export function buildDefaultSystemPrompt(char) {
|
||||
const hobbies = (char.hobbies || []).join(', ');
|
||||
const genderDesc = char.gender === 'female'
|
||||
? 'Geschlecht: weiblich (sie/ihr)'
|
||||
: (char.gender === 'male'
|
||||
? 'Geschlecht: männlich (er/ihm)'
|
||||
: (char.gender === 'nonbinary' ? 'Geschlecht: non-binär / divers' : ''));
|
||||
return [
|
||||
`Du bist ${char.name} (@${char.handle}).`,
|
||||
genderDesc,
|
||||
`Hintergrund: ${char.bio || ''}`,
|
||||
`Hobbys: ${hobbies}`,
|
||||
`Persönlichkeit & Schreibstil: ${char.personality || ''}`,
|
||||
@@ -232,10 +259,10 @@ export async function seedCharacters() {
|
||||
for (let i = 0; i < SEED_CHARACTERS.length; i++) {
|
||||
const c = SEED_CHARACTERS[i];
|
||||
await pool.query(
|
||||
`INSERT INTO characters (id, name, handle, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 0)
|
||||
`INSERT INTO characters (id, name, handle, gender, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, 0)
|
||||
ON CONFLICT (id) DO NOTHING;`,
|
||||
[c.id, c.name, c.handle, c.bio, JSON.stringify(c.hobbies), c.personality, c.language, c.avatar, now - (SEED_CHARACTERS.length - i) * 86400000]
|
||||
[c.id, c.name, c.handle, c.gender || 'unspecified', c.bio, JSON.stringify(c.hobbies), c.personality, c.language, c.avatar, now - (SEED_CHARACTERS.length - i) * 86400000]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -266,12 +293,12 @@ export async function seedCharacters() {
|
||||
|
||||
// Daily new character generation
|
||||
const DAILY_POOL = [
|
||||
{ name: 'Finn', hobbies: ['Skateboarden', 'Sprayen', 'Boulderhalle'], bio: '20, Street-Art-Szene Hamburg', personality: 'coole Ruhe, kurze Sätze, 🛹', emoji: '🛹', c1: '#37474f', c2: '#ffb300' },
|
||||
{ name: 'Greta', hobbies: ['Astronomie', 'Teleskop-Basteln', 'Sternenhopping'], bio: '33, Astrophysikerin, nachts am aktivsten', personality: 'begeistert-wissenschaftlich, erklärt gern, nutzt ✨🌌', emoji: '🌌', c1: '#1a237e', c2: '#7c4dff' },
|
||||
{ name: 'Murat', hobbies: ['Döner-Reviews', 'Fußball', 'Karaoke'], bio: '35, Dönerkenner und Lokalpatriot', personality: 'laut, herzlich, vergleicht alles mit dem Döner, 😂🔥', emoji: '🥙', c1: '#d84315', c2: '#ff8f00' },
|
||||
{ name: 'Sophie', hobbies: ['Bücherlesen', 'Bastelcafés', 'True Crime'], bio: '24, Bibliothekarin mit einer wahren Crime-Paranoia', personality: 'neugierig, verschwörerisch aber lieb, "hört sich verdächtig an…"', emoji: '🔍', c1: '#4a148c', c2: '#ad1457' },
|
||||
{ name: 'Kaya', hobbies: ['Analogfotografie', 'Dunkelkammer', 'Flohmarkt'], bio: '29, fotografiert nur noch auf Film', personality: 'nostalgisch, ästhetisch, schweigsam, 📷', emoji: '📷', c1: '#3e2723', c2: '#8d6e63' },
|
||||
{ name: 'Mr. Whiskers', hobbies: ['Fensterbänke', 'Mäusejagd', 'Nickerchen'], bio: 'Katze. Der Charakter ist eine echte Katze und schreibt aus Katzenperspektive', personality: 'schreibt aus Sicht einer selbstbewussten Hauskatze, kurz und fordernd, nutzt 🐾', emoji: '🐾', c1: '#ff6f00', c2: '#ffe082' },
|
||||
{ name: 'Finn', gender: 'male', hobbies: ['Skateboarden', 'Sprayen', 'Boulderhalle'], bio: '20, Street-Art-Szene Hamburg', personality: 'coole Ruhe, kurze Sätze, 🛹', emoji: '🛹', c1: '#37474f', c2: '#ffb300' },
|
||||
{ name: 'Greta', gender: 'female', hobbies: ['Astronomie', 'Teleskop-Basteln', 'Sternenhopping'], bio: '33, Astrophysikerin, nachts am aktivsten', personality: 'begeistert-wissenschaftlich, erklärt gern, nutzt ✨🌌', emoji: '🌌', c1: '#1a237e', c2: '#7c4dff' },
|
||||
{ name: 'Murat', gender: 'male', hobbies: ['Döner-Reviews', 'Fußball', 'Karaoke'], bio: '35, Dönerkenner und Lokalpatriot', personality: 'laut, herzlich, vergleicht alles mit dem Döner, 😂🔥', emoji: '🥙', c1: '#d84315', c2: '#ff8f00' },
|
||||
{ name: 'Sophie', gender: 'female', hobbies: ['Bücherlesen', 'Bastelcafés', 'True Crime'], bio: '24, Bibliothekarin mit einer wahren Crime-Paranoia', personality: 'neugierig, verschwörerisch aber lieb, "hört sich verdächtig an…"', emoji: '🔍', c1: '#4a148c', c2: '#ad1457' },
|
||||
{ name: 'Kaya', gender: 'female', hobbies: ['Analogfotografie', 'Dunkelkammer', 'Flohmarkt'], bio: '29, fotografiert nur noch auf Film', personality: 'nostalgisch, ästhetisch, schweigsam, 📷', emoji: '📷', c1: '#3e2723', c2: '#8d6e63' },
|
||||
{ name: 'Mr. Whiskers', gender: 'male', hobbies: ['Fensterbänke', 'Mäusejagd', 'Nickerchen'], bio: 'Katze. Der Charakter ist eine echte Katze und schreibt aus Katzenperspektive', personality: 'schreibt aus Sicht einer selbstbewussten Hauskatze, kurz und fordernd, nutzt 🐾', emoji: '🐾', c1: '#ff6f00', c2: '#ffe082' },
|
||||
];
|
||||
|
||||
export function pickDailyChar(existingHandles = []) {
|
||||
@@ -284,6 +311,7 @@ export function pickDailyChar(existingHandles = []) {
|
||||
return {
|
||||
...d,
|
||||
handle,
|
||||
gender: d.gender || 'unspecified',
|
||||
language: 'de',
|
||||
hobbies: d.hobbies,
|
||||
avatar,
|
||||
|
||||
+3
-3
@@ -94,9 +94,9 @@ function startBackgroundSimulation() {
|
||||
handle = `${spec.name.toLowerCase().replace(/[^a-z0-9]/g, '')}.${Math.floor(Math.random() * 900) + 100}`;
|
||||
}
|
||||
await pool.query(
|
||||
`INSERT INTO characters (id, name, handle, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, 0);`,
|
||||
[id, spec.name, handle, spec.bio, JSON.stringify(spec.hobbies), spec.personality, spec.language, spec.avatar, Date.now()]
|
||||
`INSERT INTO characters (id, name, handle, gender, bio, hobbies, personality, language, avatar_key, created_at, is_custom)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, 0);`,
|
||||
[id, spec.name, handle, spec.gender || 'unspecified', spec.bio, JSON.stringify(spec.hobbies), spec.personality, spec.language, spec.avatar, Date.now()]
|
||||
);
|
||||
await setState('last_daily_char', today);
|
||||
await setState('last_daily_char_id', id);
|
||||
|
||||
Reference in new issue
Block a user