Update from Git Manager GUI

This commit is contained in:
2026-03-30 20:42:44 +02:00
parent 85d12e832d
commit e417f31c99
3 changed files with 303 additions and 87 deletions

View File

@@ -110,26 +110,39 @@ function mm_assistant_query() {
$player_name = mm_extract_player_name( $q );
foreach ( $active as $intent => $score ) {
// Ban-Intent dominant → Regeln nicht zusätzlich auslösen
if ( $intent === 'rules' && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 25 ) {
continue;
// Wenn Discord-Intent erkannt wurde, NUR diesen ausführen
if (isset($active['discord'])) {
$result = mm_handle_intent('discord', $q, $q_lc, $player_name, $bot);
if ($result) {
$parts[] = $result;
}
} elseif (isset($active['team'])) {
$result = mm_handle_intent('team', $q, $q_lc, $player_name, $bot);
if ($result) {
$parts[] = $result;
}
} else {
foreach ( $active as $intent => $score ) {
// Ban-Intent dominant → Regeln nicht zusätzlich auslösen
if ( $intent === 'rules' && isset( $intents['ban_check'] ) && $intents['ban_check'] >= 25 ) {
continue;
}
// Ban-Intent dominant → Shop/Ticket/Forum nicht zusätzlich auslösen
if ( in_array( $intent, array( 'shop', 'ticket', 'forum' ), true )
&& isset( $intents['ban_check'] ) && $intents['ban_check'] >= 40 ) {
continue;
}
// Player-History dominant → Server-Status nicht zusätzlich auslösen
if ( $intent === 'server_status'
&& isset( $intents['player_history'] ) && $intents['player_history'] >= 15 ) {
continue;
}
$result = mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot );
if ( $result ) {
$parts[] = $result;
}
}
}
// Ban-Intent dominant → Shop/Ticket/Forum nicht zusätzlich auslösen
if ( in_array( $intent, array( 'shop', 'ticket', 'forum' ), true )
&& isset( $intents['ban_check'] ) && $intents['ban_check'] >= 40 ) {
continue;
}
// Player-History dominant → Server-Status nicht zusätzlich auslösen
if ( $intent === 'server_status'
&& isset( $intents['player_history'] ) && $intents['player_history'] >= 15 ) {
continue;
}
$result = mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot );
if ( $result ) {
$parts[] = $result;
}
}
if ( empty( $parts ) ) {
$parts[] = mm_fallback_response( $bot );
@@ -163,7 +176,19 @@ function mm_score_intents( $q_lc, $q_raw ) {
'forum' => 0,
'gallery' => 0,
'faq' => 0,
'discord' => 0,
'team' => 0,
];
// Team
foreach ([
'team', 'teammitglieder', 'admins', 'moderatoren', 'wer ist im team', 'wer sind die admins', 'wer sind die moderatoren', 'serverteam', 'staff', 'supporter', 'admin', 'mod', 'leitung', 'server leitung', 'wer ist staff', 'wer ist admin', 'wer ist mod'
] as $kw) {
if (strpos($q_lc, $kw) !== false) $scores['team'] += 20;
}
// Discord
foreach (['discord', 'dc', 'discord link', 'discord einladung', 'discord server', 'discord invite'] as $kw) {
if (strpos($q_lc, $kw) !== false) $scores['discord'] += 20;
}
// Server-Status
foreach ( ['ip', 'adresse', 'join', 'einloggen', 'verbinden', 'server ip',
@@ -250,9 +275,12 @@ function mm_score_intents( $q_lc, $q_raw ) {
$scores['gallery'] += 20;
}
// FAQ
foreach ( ['faq', 'häufige frage', 'frequently', 'oft gefragt'] as $kw ) {
if ( strpos( $q_lc, $kw ) !== false ) $scores['faq'] += 10;
// FAQ: Mehr Keywords und höheres Scoring, damit typische Fragen wie "Wie ...?", "Was ...?", "Wieso ...?", "Erklärung ..." erkannt werden
foreach ([
'faq', 'häufige frage', 'frequently', 'oft gefragt',
'wie ', 'was ', 'wieso ', 'wo ', 'wer ', 'hilfe', 'erklärung', 'funktioniert', 'bedeutet', 'nutzen', 'benutzen', 'erkläre', 'erklärt', 'erfahre', 'erfahren', 'frage', 'fragen', 'hilfe', 'problem', 'tipp', 'tipps', 'anleitung', 'erläutere', 'erläutert', 'erläutern', 'erläutere', 'erläutert', 'erläutern', 'beschreibe', 'beschreibt', 'beschreiben', 'beschreibe', 'beschreibt', 'beschreiben', 'wie kann', 'wie mache', 'wie mache ich', 'wie funktioniert', 'wie nutze', 'wie benutze', 'wie setze', 'wie entferne', 'wie öffne', 'wie melde', 'wie erreiche', 'wie akzeptiere', 'wie fordere', 'wie wechsle', 'wie sehe', 'wie teleportiere', 'wie sende', 'wie setze ich', 'wie entferne ich', 'wie öffne ich', 'wie melde ich', 'wie erreiche ich', 'wie akzeptiere ich', 'wie fordere ich', 'wie wechsle ich', 'wie sehe ich', 'wie teleportiere ich', 'wie sende ich'
] as $kw) {
if ( strpos( $q_lc, $kw ) !== false ) $scores['faq'] += 18;
}
return $scores;
@@ -274,8 +302,87 @@ function mm_handle_intent( $intent, $q, $q_lc, $player_name, $bot ) {
case 'forum': return mm_intent_forum( $q );
case 'gallery': return mm_intent_gallery( $bot, $q_lc );
case 'faq': return mm_intent_faq( $q );
case 'discord': return mm_intent_discord( $bot );
case 'team': return mm_intent_team();
}
}
// ============================================================
// INTENT: TEAM
// ============================================================
function mm_intent_team() {
$query = new WP_Query( array(
'post_type' => 'team_member',
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC',
) );
if ( ! $query->have_posts() ) {
return [
'source' => 'team',
'title' => '👥 Team',
'content' => 'Es wurden noch keine Teammitglieder eingetragen.',
];
}
$html = '<div style="background:#fff;border-radius:14px;padding:20px 18px 12px 18px;box-shadow:0 2px 12px rgba(0,0,0,0.07);max-width:440px;margin:0 auto;">';
$html .= '<div style="font-size:1.3em;font-weight:700;margin-bottom:18px;color:#2563eb;letter-spacing:0.5px;">👥 Team</div>';
while ( $query->have_posts() ) {
$query->the_post();
$name = get_the_title();
$rank = get_post_meta( get_the_ID(), '_team_member_rank', true );
$uuid = get_post_meta( get_the_ID(), '_team_member_uuid', true );
$img = get_the_post_thumbnail_url( get_the_ID(), 'medium' );
$desc = get_the_excerpt();
$avatar = '';
if ( $uuid ) {
$avatar = 'https://visage.surgeplay.com/bust/' . esc_attr( $uuid ) . '.png';
} elseif ( $img ) {
$avatar = $img;
}
$html .= '<div style="display:flex;align-items:center;gap:18px;margin-bottom:22px;padding:14px 0;border-bottom:1px solid #e5e7eb;">';
if ( $avatar ) {
$html .= '<img src="' . esc_url( $avatar ) . '" alt="' . esc_attr( $name ) . '" style="width:64px;height:64px;border-radius:12px;background:#f1f5f9;box-shadow:0 1px 6px rgba(0,0,0,0.08);object-fit:cover;">';
} else {
$html .= '<div style="width:64px;height:64px;border-radius:12px;background:#e5e7eb;display:flex;align-items:center;justify-content:center;font-size:2em;color:#888;">' . esc_html( mb_substr( $name, 0, 1 ) ) . '</div>';
}
$html .= '<div>';
$html .= '<div style="font-size:1.18em;font-weight:700;color:#23272e;line-height:1.2;">' . esc_html( $name ) . '</div>';
if ( $rank ) {
$html .= '<div style="font-size:1.07em;color:#1d4ed8;font-weight:600;margin-top:2px;">' . esc_html( $rank ) . '</div>';
}
if ( $desc ) {
$html .= '<div style="font-size:1em;color:#444;opacity:.97;max-width:340px;margin-top:2px;">' . esc_html( $desc ) . '</div>';
}
$html .= '</div>';
$html .= '</div>';
}
$html .= '</div>';
wp_reset_postdata();
return [
'source' => 'team',
'title' => '👥 Team',
'content' => $html,
];
}
// ============================================================
// INTENT: DISCORD
// ============================================================
function mm_intent_discord( $bot ) {
$discord = $bot['link_discord'] ?? '';
if ( ! empty( $discord ) ) {
return [
'source' => 'discord',
'title' => '💬 Discord',
'content' => 'Hier ist der Discord-Einladungslink:<br><a href="' . esc_url( $discord ) . '" target="_blank">' . esc_html( $discord ) . '</a>',
];
} else {
return [
'source' => 'discord',
'title' => '💬 Discord',
'content' => 'Es wurde kein Discord-Link im Backend hinterlegt.',
];
}
return null;
}
// ============================================================
@@ -1889,17 +1996,21 @@ function mm_intent_faq( $q ) {
if ( empty( $results ) ) return null;
$html = [];
$html = '<div style="background:#fff;border-radius:12px;padding:16px 14px 10px 14px;box-shadow:0 2px 8px rgba(0,0,0,0.04);max-width:480px;margin:0 auto;">';
foreach ( $results as $post ) {
$excerpt = get_the_excerpt( $post->ID );
$html[] = '❓ <b>' . esc_html( $post->post_title ) . '</b>'
. ( $excerpt ? '<br>' . wp_trim_words( $excerpt, 40, '…' ) : '' );
$title = esc_html( $post->post_title );
$content = apply_filters( 'the_content', $post->post_content );
$html .= '<div style="margin-bottom:18px;padding-bottom:10px;border-bottom:1px solid #e5e7eb;">';
$html .= '<div style="font-size:1.08em;font-weight:600;color:#23272e;margin-bottom:4px;">' . $title . '</div>';
$html .= '<div style="font-size:1em;color:#444;opacity:.97;line-height:1.6;">' . $content . '</div>';
$html .= '</div>';
}
$html .= '</div>';
return [
'source' => 'faq',
'title' => 'FAQ',
'content' => implode( '<br><br>', $html ),
'title' => 'FAQ',
'content' => $html,
];
}