Changeset 3335155
- Timestamp:
- 07/28/2025 06:57:00 AM (7 months ago)
- Location:
- replypilot-ai
- Files:
-
- 33 added
- 4 edited
-
tags/1.7 (added)
-
tags/1.7/LICENSE.txt (added)
-
tags/1.7/admin.php (added)
-
tags/1.7/ai-chatbot.php (added)
-
tags/1.7/ai-generator.php (added)
-
tags/1.7/assets (added)
-
tags/1.7/assets/chat.png (added)
-
tags/1.7/assets/css (added)
-
tags/1.7/assets/css/chatbot-style.css (added)
-
tags/1.7/assets/css/style.css (added)
-
tags/1.7/assets/fontawesome (added)
-
tags/1.7/assets/fontawesome/css (added)
-
tags/1.7/assets/fontawesome/css/all.min.css (added)
-
tags/1.7/assets/fontawesome/webfonts (added)
-
tags/1.7/assets/fontawesome/webfonts/fa-solid-900.ttf (added)
-
tags/1.7/assets/fontawesome/webfonts/fa-solid-900.woff2 (added)
-
tags/1.7/assets/icon-256x256.png (added)
-
tags/1.7/assets/js (added)
-
tags/1.7/assets/js/replypilot-ai.js (added)
-
tags/1.7/assets/js/script.js (added)
-
tags/1.7/autoreply-comments.php (added)
-
tags/1.7/custom-handle-ai-reply.php (added)
-
tags/1.7/forum-functions (added)
-
tags/1.7/forum-functions/Asgaros-Forum.php (added)
-
tags/1.7/forum-functions/ForumWP.php (added)
-
tags/1.7/forum-functions/bbpress-auto-reply.php (added)
-
tags/1.7/forum-functions/buddypress-auto-reply.php (added)
-
tags/1.7/forum-functions/wpForo-Forum.php (added)
-
tags/1.7/includes (added)
-
tags/1.7/includes/functions.php (added)
-
tags/1.7/index.php (added)
-
tags/1.7/readme.txt (added)
-
tags/1.7/replypilot-ai.php (added)
-
trunk/ai-chatbot.php (modified) (3 diffs)
-
trunk/assets/js/script.js (modified) (7 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/replypilot-ai.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
replypilot-ai/trunk/ai-chatbot.php
r3322100 r3335155 84 84 $conversation_id = $wpdb->insert_id; 85 85 86 setcookie("replypilot_conversation_id", $conversation_id, time() + 1296000, "/"); // 15 days 86 87 // Add welcome message to conversation 87 88 if ($conversation_id) { … … 219 220 220 221 $body = json_decode($response['body'], true); 221 error_log(print_r($body, true));222 222 if (isset($body['candidates'][0]['content']['parts'][0]['text'])) { 223 223 … … 469 469 } 470 470 } 471 472 add_action('wp_ajax_replypilot_get_chatbot_messages', 'replypilot_get_chatbot_messages_callback'); 473 add_action('wp_ajax_nopriv_replypilot_get_chatbot_messages', 'replypilot_get_chatbot_messages_callback'); 474 475 function replypilot_get_chatbot_messages_callback() { 476 check_ajax_referer('replypilot_ai_chatbot_nonce', 'nonce'); 477 478 global $wpdb; 479 $conversation_id = isset($_POST['conversation_id']) ? sanitize_text_field(wp_unslash($_POST['conversation_id'])) : ''; 480 if (empty($conversation_id)) { 481 wp_send_json_error(['message' => 'Missing conversation ID']); 482 } 483 $messages = $wpdb->get_results( 484 $wpdb->prepare("SELECT * FROM {$wpdb->prefix}replypilot_chatbot_messages WHERE conversation_id = %s ORDER BY sent_at ASC", $conversation_id), 485 ARRAY_A 486 ); 487 // Escape output 488 $escaped_messages = array_map(function($message) { 489 return [ 490 'message_type' => esc_html($message['message_type']), 491 'content' => esc_html($message['content']), 492 'sent_at' => esc_html($message['sent_at']), 493 ]; 494 }, $messages); 495 496 wp_send_json_success(['messages' => $escaped_messages]); 497 } 498 -
replypilot-ai/trunk/assets/js/script.js
r3322100 r3335155 1 1 jQuery(document).ready(function ($) { 2 3 function get_chatbot_Cookie(name) { 4 const value = `; ${document.cookie}`; 5 const parts = value.split(`; ${name}=`); 6 if (parts.length === 2) return parts.pop().split(';').shift(); 7 } 8 9 function chatbotfetchMessages(conversation_id) { 10 fetch(replypilotChatbot.ajaxurl, { 11 method: 'POST', 12 headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, 13 body: new URLSearchParams({ 14 action: 'replypilot_get_chatbot_messages', 15 nonce: replypilotChatbot.nonce, 16 conversation_id: conversation_id 17 }) 18 }) 19 .then(res => res.json()) 20 .then(data => { 21 if (data.success) { 22 dataset = data.data.messages; 23 sessionStorage.setItem("replypilot_chatHistory", JSON.stringify(dataset)); 24 for (msgdata of dataset) { 25 addMessage(msgdata.message_type, msgdata.content, undefined, msgdata.sent_at); 26 } 27 } else { 28 console.error(data.message); 29 } 30 }); 31 } 32 2 33 // Chatbot state 34 const userid = get_chatbot_Cookie("replypilot_conversation_id"); 3 35 let chatHistory = []; 4 let isOpen = false;5 let conversationId = null;36 let isOpen = userid ? true : false; 37 let conversationId = userid ?? null; 6 38 let userData = null; 7 39 8 40 // Initialize chatbot 9 41 function initChatbot() { 42 const history = JSON.parse(sessionStorage.getItem("replypilot_chatHistory")); 43 if (isOpen) { 44 if (history) { 45 for (msgdata of history) { 46 addMessage(msgdata.message_type, msgdata.content, undefined, msgdata.sent_at); 47 } 48 } else { 49 chatbotfetchMessages(userid) 50 } 51 } 10 52 11 53 // Close button … … 13 55 14 56 // Handle sending messages 15 $('#replypilot-chatbot-send').on('click', function () { 16 sendMessage();57 $('#replypilot-chatbot-send').on('click', function () { 58 sendMessage(); 17 59 }); 18 60 … … 30 72 $(document).on('click', '#replypilot-chatbot-toggle', function () { 31 73 if (!isOpen && (!userData || !conversationId)) { 32 33 74 showUserDataForm(); 34 75 } else { 35 76 toggleChatbot(); 36 77 } 37 38 78 }); 39 79 … … 46 86 47 87 // Toggle chatbot open/close 48 function toggleChatbot( ) {49 if ( isOpen) {88 function toggleChatbot(end = false) { 89 if (!isOpen && end) { 50 90 $('#replypilot-chatbot-container').addClass('closed'); 51 91 if (conversationId) { … … 104 144 conversation_id: conversationId 105 145 }; 146 106 147 // Hide form and show chat 107 148 hideUserDataForm(); … … 129 170 130 171 // Add message to chat 131 function addMessage(sender, message, services = []) { 172 function addMessage(sender, message, services = [], data = null) { 173 174 if (!data) { 175 const history = JSON.parse(sessionStorage.getItem("replypilot_chatHistory")) || []; 176 history.push({ message_type: sender, content: message, sent_at: new Date() }); 177 sessionStorage.setItem("replypilot_chatHistory", JSON.stringify(history)); 178 } 132 179 133 180 message = message.replace(/\*\*/g, ''); 134 181 message = message.replace(/\n/g, '<br>'); 135 const timestamp = new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); 182 date = data ? new Date(data) : new Date(); 183 const timestamp = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }); 136 184 const messageClass = sender === 'user' ? 'replypilot-user-message' : 'replypilot-bot-message'; 137 185 let buttonsHtml = '<div class="replypilot-service-buttons">'; … … 215 263 $('#replypilot-chatbot-messages').find(".replypilot-service-btn").prop("disabled", true); 216 264 }); 217 218 219 265 // Initialize 220 266 initChatbot(); 267 221 268 }); 222 269 -
replypilot-ai/trunk/readme.txt
r3322100 r3335155 1 1 === ReplyPilot AI === 2 2 Contributors: techbeeps, gurjeet6090 3 Tags: free comment reply, free chatbot, chatbot, comment bot,ai chatbot3 Tags:ai assistant, chatbot, comment bot,ai chatbot,auto reply 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1. 67 Stable tag: 1.7 8 8 License: GPL-2.0+ 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 140 140 141 141 == Changelog == 142 = 1.7 = 143 * Now user can refresh the page and close the browser but still the chat history will be back". 144 142 145 = 1.6 = 143 146 * Send Chatbot button conflict fixed". … … 164 167 == Upgrade Notice == 165 168 166 = 1. 4=167 * New Feature: Added user interface to show question suggestions.169 = 1.7 = 170 * New Feature: Now user can refresh the page and close the browser but still the chat history will be back. 168 171 169 172 -
replypilot-ai/trunk/replypilot-ai.php
r3322100 r3335155 4 4 Plugin URI: https://replypilot.techbeeps.com/ 5 5 Description: AI-powered plugin that auto-generates human-like replies to user comments and provides a real-time chatbot on your website. 6 Version: 1. 66 Version: 1.7 7 7 Author: Techbeeps 8 8 Author URI: https://techbeeps.co.in/ … … 16 16 } 17 17 18 define('REPLYPILOT_AI_TBS', '1. 6');18 define('REPLYPILOT_AI_TBS', '1.7'); 19 19 define('REPLYPILOT_AI_TBS_PATH', plugin_dir_path(__FILE__)); 20 20 define('REPLYPILOT_AI_TBS_URL', __FILE__);
Note: See TracChangeset
for help on using the changeset viewer.