ruạṛ
<?php /** * The template for displaying the footer. * * Contains the closing of the #content div and all content after. * * @link https://developer.wordpress.org/themes/basics/template-files/#template-partials * * @package Astra * @since 1.0.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } ?> <?php astra_content_bottom(); ?> </div> <!-- ast-container --> </div><!-- #content --> <?php astra_content_after(); astra_footer_before(); astra_footer(); astra_footer_after(); ?> </div><!-- #page --> <?php astra_body_bottom(); wp_footer(); ?> <!-- Chatbot Container --> <!-- Deep Chat initial load settings icons/initial text etc --> <div id="deep-chat-widget-container" style="position: fixed; bottom: 20px; right: 20px; z-index: 9999;"> <deep-chat id="chat-element" demo="true" textInput='{"placeholder":{"text": "Ask me anything!"}}' avatars='{ "default": {"styles": {"avatar": {"height": "35px", "width": "50px"}, "container": {"marginTop": "8px"}}}, "ai": {"src": "https://darkshibxrp.xyz/wp-content/uploads/2025/02/cropped-cropped-2025-02-18-11.23.01-300x218.png", "styles": {"avatar": {"marginLeft": "-3px"}}}, "user": {"src": "", "styles": {"avatar": {"display": "none"}}} }' style="width: 350px; height: 500px; border-radius: 10px; box-shadow: 0px 4px 10px rgba(0,0,0,0.2); display: none;"> </deep-chat> </div> <div id="chat-container" style="position: fixed; bottom: 20px; right: 20px; z-index: 10000; padding: 10px; text-align: right; display: flex; flex-direction: column; align-items: flex-end;"> <div id="chat-header"> Click below to chat </div> <button id="chat-toggle-btn"> <img src="https://darkshibxrp.xyz/wp-content/uploads/2025/02/cropped-cropped-2025-02-18-11.23.01-300x218.png" alt="Chat Icon" style="width: 70px; display: block;"/> </button> </div> <script type="module"> document.addEventListener("DOMContentLoaded", () => { const chatElementRef = document.getElementById("chat-element"); const headerRef = document.getElementById("chat-header"); if (!chatElementRef || !headerRef) return; Object.assign(chatElementRef.style, { borderRadius: '8px' }); chatElementRef.demo = true; chatElementRef.history = [ { html: '<button id="issuer-lookup-btn" class="deep-chat-button deep-chat-suggestion-button">Enhanced XRPL info</button><button id="buy-darkshib-btn" class="deep-chat-button deep-chat-suggestion-button">How to buy darkshib</button><button id="joke-btn" class="deep-chat-button deep-chat-suggestion-button">Tell me a joke</button>', role: 'ai' } ]; let stage = 0; let issuerAddress = ""; let lastRequestTimestamp = 0; const requestCooldown = 3000; chatElementRef.connect = { handler: async (body, signals) => { try { const latestMessage = body?.messages?.[body.messages.length - 1]?.content || body?.messages?.[body.messages.length - 1]?.text || ""; if (stage === 0 && latestMessage.trim().toLowerCase() === "enhanced xrpl info") { stage = 1; signals.onResponse({ text: "🎯 What's the XRPL issuer address? (Paste it below!)" }); return; } else if (stage === 1) { issuerAddress = latestMessage.trim(); signals.onResponse({ text: `⏳ Fetching enhanced info for ${issuerAddress}...` }); const apiUrl = `https://node-hello-world-mauve-tau.vercel.app/api/issuer-lookup?issuer=${encodeURIComponent(issuerAddress)}`; const apiResponse = await fetch(apiUrl); if (!apiResponse.ok) { const errorText = await apiResponse.text(); throw new Error(`API error: ${apiResponse.status} ${errorText}`); } const data = await apiResponse.json(); const funResponse = `🎉✅ Here is your enhanced XRPL info:\n\n${data.response}\n\n✓ All done!`; chatElementRef.addMessage({ role: 'ai', text: funResponse }); stage = 0; return; } const now = Date.now(); if (now - lastRequestTimestamp < requestCooldown) { signals.onResponse({ error: "You're sending requests too quickly. Please wait a moment." }); return; } lastRequestTimestamp = now; const conversationHistory = chatElementRef.getMessages().map(msg => { const role = (msg.role === "ai" ? "assistant" : msg.role); const content = msg.text ? msg.text : (msg.html ? msg.html.replace(/<[^>]+>/g, '') : ''); return { role, content }; }); const payload = { model: "gpt-4o", messages: conversationHistory, max_tokens: 2000 }; const endpointUrl = "/wp-json/myplugin/v1/openai"; const openAIResponse = await fetch(endpointUrl, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }); if (!openAIResponse.ok) { const errorText = await openAIResponse.text(); signals.onResponse({ error: "OpenAI API error: " + errorText }); return; } let openAIData = await openAIResponse.json(); if (typeof openAIData === "string") { try { openAIData = JSON.parse(openAIData); } catch (e) { signals.onResponse({ error: "Could not parse response: " + e.message }); return; } } if (!openAIData.choices || !openAIData.choices[0]) { signals.onResponse({ error: "Unexpected response from server: " + JSON.stringify(openAIData) }); return; } const reply = openAIData.choices[0].message.content; signals.onResponse({ text: reply }); } catch (error) { signals.onResponse({ error: error.message }); } } }; setTimeout(() => { const issuerBtn = document.getElementById("issuer-lookup-btn"); if (issuerBtn) { issuerBtn.addEventListener("click", () => { const userCommand = "Enhanced XRPL info"; chatElementRef.history.push({ role: 'user', text: userCommand }); chatElementRef.connect.handler({ messages: [{ text: userCommand }] }, { onResponse: (response) => { chatElementRef.history.push({ role: 'ai', text: response.text || response.error }); } }); }); } const buyBtn = document.getElementById("buy-darkshib-btn"); if (buyBtn) { buyBtn.addEventListener("click", () => { const userCommand = "How to buy darkshib"; chatElementRef.history.push({ role: 'user', text: userCommand }); chatElementRef.connect.handler({ messages: [{ text: userCommand }] }, { onResponse: (response) => { chatElementRef.history.push({ role: 'ai', text: response.text || response.error }); } }); }); } const jokeBtn = document.getElementById("joke-btn"); if (jokeBtn) { jokeBtn.addEventListener("click", () => { const userCommand = "Tell me a joke"; chatElementRef.history.push({ role: 'user', text: userCommand }); chatElementRef.connect.handler({ messages: [{ text: userCommand }] }, { onResponse: (response) => { chatElementRef.history.push({ role: 'ai', text: response.text || response.error }); } }); }); } }, 500); const toggleBtn = document.getElementById("chat-toggle-btn"); toggleBtn.addEventListener("click", () => { if (chatElementRef.style.display === "none" || chatElementRef.style.display === "") { chatElementRef.style.display = "block"; headerRef.style.display = "none"; } else { chatElementRef.style.display = "none"; headerRef.style.display = "block"; } }); }); </script> </body> </html>
cải xoăn