ChatAssistant

ChatAssistant test

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/536368/1591164/ChatAssistant.js

  1. Tabs.ChatAssistant = {
  2. init: function() {
  3. var div = document.createElement('div');
  4. div.className = 'tabContent';
  5. div.style.display = 'none';
  6. return div;
  7. },
  8.  
  9. paint: function() {
  10. // Create response options
  11. var responseOptions = Object.keys(this.cannedResponses).map(key => `
  12. <option value="${key}">${this.cannedResponses[key]}</option>
  13. `).join('');
  14.  
  15. var m = `
  16. <div class="divHeader" align="center">Chat Assistant</div>
  17. <br>
  18. <div align="center">
  19. <select id="cannedResponseSelect" class="btInput">
  20. <option value="">-- Select Response --</option>
  21. ${responseOptions}
  22. </select>
  23. <br><br>
  24. <textarea id="chatInput" rows="3" cols="50" class="btInput"></textarea>
  25. <br>
  26. <button id="sendButton" class="buttonv2 std blue">Send to Global</button>
  27. </div>
  28. `;
  29.  
  30. // Create div if it doesn't exist
  31. if (!this.myDiv) {
  32. this.myDiv = document.createElement('div');
  33. this.myDiv.className = 'tabContent';
  34. }
  35. this.myDiv.innerHTML = m;
  36.  
  37. // Event listeners
  38. var self = this;
  39. $("#cannedResponseSelect").change(function() {
  40. self.insertCannedResponse();
  41. });
  42. $("#sendButton").click(function() {
  43. self.sendMessage();
  44. });
  45. },
  46.  
  47. insertCannedResponse: function() {
  48. var selectedKey = $("#cannedResponseSelect").val();
  49. var cannedResponse = this.cannedResponses[selectedKey] || "";
  50. $("#chatInput").val(cannedResponse);
  51. },
  52.  
  53. sendMessage: function() {
  54. var message = $("#chatInput").val().trim();
  55. if (message === "") {
  56. return;
  57. }
  58.  
  59. // Send message to global chat
  60. unsafeWindow.cm.sendGlobalChat(message);
  61.  
  62. $("#chatInput").val(""); // Clear input
  63. },
  64.  
  65. // Canned responses
  66. cannedResponses: {
  67. "help": translate("I need help with..."),
  68. "resources": translate("I'm looking for resources. Does anyone have..."),
  69. // ... other canned responses ...
  70. }
  71. };

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址