Add files via upload

This commit is contained in:
Cola-Echo
2025-12-23 15:20:30 +08:00
committed by GitHub
parent 1fe6d34355
commit 3824a441f6
6 changed files with 75 additions and 464 deletions

40
chat.js
View File

@@ -17,7 +17,6 @@ import { startVoiceCall } from './voice-call.js';
import { startVideoCall } from './video-call.js';
import { showOpenRedPacket, generateRedPacketId } from './red-packet.js';
import { showReceiveTransferPage, generateTransferId } from './transfer.js';
import { getSelectedTime, clearSelectedTime } from './chat-func-panel.js';
// 当前聊天的联系人索引
export let currentChatIndex = -1;
@@ -1393,6 +1392,7 @@ export async function sendMessage(messageText, isMultipleMessages = false, isVoi
const now = new Date();
const timeStr = `${now.getFullYear()}-${(now.getMonth()+1).toString().padStart(2,'0')}-${now.getDate().toString().padStart(2,'0')} ${now.getHours().toString().padStart(2,'0')}:${now.getMinutes().toString().padStart(2,'0')}`;
const msgTimestamp = Date.now();
let messagesToSend = [];
if (isMultipleMessages && Array.isArray(messageText)) {
@@ -1413,8 +1413,6 @@ export async function sendMessage(messageText, isMultipleMessages = false, isVoi
// 清除引用
clearQuote();
const msgTimestamp = Date.now();
for (let i = 0; i < messagesToSend.length; i++) {
const msg = messagesToSend[i];
// 只有第一条消息带引用
@@ -1453,15 +1451,6 @@ export async function sendMessage(messageText, isMultipleMessages = false, isVoi
? `[用户发送了语音消息,内容是:${messagesToSend.join('\n')}]`
: messagesToSend.join('\n');
// 如果有选择的时间,添加时间上下文
const selectedTime = getSelectedTime();
if (selectedTime) {
const timeDate = new Date(selectedTime);
const timeStr = `${timeDate.getFullYear()}${timeDate.getMonth() + 1}${timeDate.getDate()}${timeDate.getHours().toString().padStart(2, '0')}:${timeDate.getMinutes().toString().padStart(2, '0')}`;
combinedMessage = `[当前时间:${timeStr}]\n${combinedMessage}`;
clearSelectedTime();
}
// 如果有引用,添加引用上下文
if (quote) {
let quoteDesc;
@@ -1981,15 +1970,6 @@ export async function sendStickerMessage(stickerUrl, description = '') {
? `[用户发送了一个表情包:${description}]`
: '[用户发送了一个表情包]';
// 如果有选择的时间,添加时间上下文
const selectedTime = getSelectedTime();
if (selectedTime) {
const timeDate = new Date(selectedTime);
const timeStr = `${timeDate.getFullYear()}${timeDate.getMonth() + 1}${timeDate.getDate()}${timeDate.getHours().toString().padStart(2, '0')}:${timeDate.getMinutes().toString().padStart(2, '0')}`;
aiPrompt = `[当前时间:${timeStr}]\n${aiPrompt}`;
clearSelectedTime();
}
const aiResponse = await callAI(contact, aiPrompt);
// 只有用户还在当前聊天时才隐藏打字指示器
@@ -2371,15 +2351,6 @@ export async function sendPhotoMessage(description) {
const { callAI } = await import('./ai.js');
let aiPrompt = `[用户发送了一张照片,图片描述:${polishedDescription}]`;
// 如果有选择的时间,添加时间上下文
const selectedTime = getSelectedTime();
if (selectedTime) {
const timeDate = new Date(selectedTime);
const timeStr = `${timeDate.getFullYear()}${timeDate.getMonth() + 1}${timeDate.getDate()}${timeDate.getHours().toString().padStart(2, '0')}:${timeDate.getMinutes().toString().padStart(2, '0')}`;
aiPrompt = `[当前时间:${timeStr}]\n${aiPrompt}`;
clearSelectedTime();
}
const aiResponse = await callAI(contact, aiPrompt);
// 只有用户还在当前聊天时才隐藏打字指示器
@@ -2861,15 +2832,6 @@ export async function sendBatchMessages(messages) {
const { callAI } = await import('./ai.js');
let combinedPrompt = promptParts.join('\n');
// 如果有选择的时间,添加时间上下文
const selectedTime = getSelectedTime();
if (selectedTime) {
const timeDate = new Date(selectedTime);
const timeStr = `${timeDate.getFullYear()}${timeDate.getMonth() + 1}${timeDate.getDate()}${timeDate.getHours().toString().padStart(2, '0')}:${timeDate.getMinutes().toString().padStart(2, '0')}`;
combinedPrompt = `[当前时间:${timeStr}]\n${combinedPrompt}`;
clearSelectedTime();
}
const aiResponse = await callAI(contact, combinedPrompt);
// 只有用户还在当前聊天时才隐藏打字指示器