修改暂停回复时间
This commit is contained in:
parent
ce43a1e6db
commit
3f42d07aa1
@ -37,6 +37,11 @@ class AutoReplyPauseManager:
|
||||
logger.error(f"获取账号 {cookie_id} 暂停时间失败: {e},使用默认10分钟")
|
||||
pause_minutes = 10
|
||||
|
||||
# 如果暂停时间为0,表示不暂停
|
||||
if pause_minutes == 0:
|
||||
logger.info(f"【{cookie_id}】检测到手动发出消息,但暂停时间设置为0,不暂停自动回复")
|
||||
return
|
||||
|
||||
pause_duration_seconds = pause_minutes * 60
|
||||
pause_until = time.time() + pause_duration_seconds
|
||||
self.paused_chats[chat_id] = pause_until
|
||||
|
||||
@ -1211,7 +1211,7 @@ class DBManager:
|
||||
'user_id': result[2],
|
||||
'auto_confirm': bool(result[3]),
|
||||
'remark': result[4] or '',
|
||||
'pause_duration': result[5] if result[5] is not None else 10,
|
||||
'pause_duration': result[5] if result[5] is not None else 10, # 0是有效值,表示不暂停
|
||||
'created_at': result[6]
|
||||
}
|
||||
return None
|
||||
@ -1272,7 +1272,7 @@ class DBManager:
|
||||
self._execute_sql(cursor, "UPDATE cookies SET pause_duration = 10 WHERE id = ?", (cookie_id,))
|
||||
self.conn.commit()
|
||||
return 10
|
||||
return result[0] # 返回实际值,不使用or操作符
|
||||
return result[0] # 返回实际值,包括0(0表示不暂停)
|
||||
else:
|
||||
logger.warning(f"账号 {cookie_id} 未找到记录,使用默认值10分钟")
|
||||
return 10
|
||||
|
||||
@ -1068,6 +1068,11 @@ class MessageNotificationIn(BaseModel):
|
||||
|
||||
|
||||
class SystemSettingIn(BaseModel):
|
||||
value: str
|
||||
description: Optional[str] = None
|
||||
|
||||
|
||||
class SystemSettingCreateIn(BaseModel):
|
||||
key: str
|
||||
value: str
|
||||
description: Optional[str] = None
|
||||
@ -2167,9 +2172,9 @@ def update_cookie_pause_duration(cid: str, update_data: PauseDurationUpdate, cur
|
||||
if cid not in user_cookies:
|
||||
raise HTTPException(status_code=403, detail="无权限操作该Cookie")
|
||||
|
||||
# 验证暂停时间范围(1-60分钟)
|
||||
if not (1 <= update_data.pause_duration <= 60):
|
||||
raise HTTPException(status_code=400, detail="暂停时间必须在1-60分钟之间")
|
||||
# 验证暂停时间范围(0-60分钟,0表示不暂停)
|
||||
if not (0 <= update_data.pause_duration <= 60):
|
||||
raise HTTPException(status_code=400, detail="暂停时间必须在0-60分钟之间(0表示不暂停)")
|
||||
|
||||
# 更新暂停时间
|
||||
success = db_manager.update_cookie_pause_duration(cid, update_data.pause_duration)
|
||||
|
||||
@ -319,7 +319,7 @@
|
||||
<i class="bi bi-question-circle ms-1"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="top"
|
||||
title="检测到手动发出消息后,自动回复暂停的时间长度(分钟)。如果在暂停期间再次手动发出消息,会重新开始计时。"></i>
|
||||
title="检测到手动发出消息后,自动回复暂停的时间长度(分钟)。设置为0表示不暂停。如果在暂停期间再次手动发出消息,会重新开始计时。"></i>
|
||||
</th>
|
||||
<th style="width: 18%">操作</th>
|
||||
</tr>
|
||||
|
||||
@ -1269,8 +1269,8 @@ async function loadCookies() {
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<div class="pause-duration-cell" data-cookie-id="${cookie.id}">
|
||||
<span class="pause-duration-display" onclick="editPauseDuration('${cookie.id}', ${cookie.pause_duration || 10})" title="点击编辑暂停时间" style="cursor: pointer; color: #6c757d; font-size: 0.875rem;">
|
||||
<i class="bi bi-clock me-1"></i>${cookie.pause_duration || 10}分钟
|
||||
<span class="pause-duration-display" onclick="editPauseDuration('${cookie.id}', ${cookie.pause_duration !== undefined ? cookie.pause_duration : 10})" title="点击编辑暂停时间" style="cursor: pointer; color: #6c757d; font-size: 0.875rem;">
|
||||
<i class="bi bi-clock me-1"></i>${cookie.pause_duration === 0 ? '不暂停' : (cookie.pause_duration || 10) + '分钟'}
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
@ -7797,16 +7797,16 @@ function editPauseDuration(cookieId, currentDuration) {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'number';
|
||||
input.className = 'form-control form-control-sm';
|
||||
input.value = currentDuration || 10;
|
||||
input.value = currentDuration !== undefined ? currentDuration : 10;
|
||||
input.placeholder = '请输入暂停时间...';
|
||||
input.style.fontSize = '0.875rem';
|
||||
input.min = 1;
|
||||
input.min = 0;
|
||||
input.max = 60;
|
||||
input.step = 1;
|
||||
|
||||
// 保存原始内容和原始值
|
||||
const originalContent = pauseCell.innerHTML;
|
||||
const originalValue = currentDuration || 10;
|
||||
const originalValue = currentDuration !== undefined ? currentDuration : 10;
|
||||
|
||||
// 标记是否已经进行了编辑
|
||||
let hasChanged = false;
|
||||
@ -7818,7 +7818,7 @@ function editPauseDuration(cookieId, currentDuration) {
|
||||
|
||||
// 监听输入变化
|
||||
input.addEventListener('input', () => {
|
||||
const newValue = parseInt(input.value) || 10;
|
||||
const newValue = input.value === '' ? 10 : parseInt(input.value);
|
||||
hasChanged = newValue !== originalValue;
|
||||
});
|
||||
|
||||
@ -7827,12 +7827,12 @@ function editPauseDuration(cookieId, currentDuration) {
|
||||
console.log('savePauseDuration called, isProcessing:', isProcessing, 'hasChanged:', hasChanged); // 调试信息
|
||||
if (isProcessing) return; // 防止重复调用
|
||||
|
||||
const newDuration = parseInt(input.value) || 10;
|
||||
const newDuration = input.value === '' ? 10 : parseInt(input.value);
|
||||
console.log('newDuration:', newDuration, 'originalValue:', originalValue); // 调试信息
|
||||
|
||||
// 验证范围
|
||||
if (newDuration < 1 || newDuration > 60) {
|
||||
showToast('暂停时间必须在1-60分钟之间', 'warning');
|
||||
if (isNaN(newDuration) || newDuration < 0 || newDuration > 60) {
|
||||
showToast('暂停时间必须在0-60分钟之间(0表示不暂停)', 'warning');
|
||||
input.focus();
|
||||
return;
|
||||
}
|
||||
@ -7860,7 +7860,7 @@ function editPauseDuration(cookieId, currentDuration) {
|
||||
// 更新显示
|
||||
pauseCell.innerHTML = `
|
||||
<span class="pause-duration-display" onclick="editPauseDuration('${cookieId}', ${newDuration})" title="点击编辑暂停时间" style="cursor: pointer; color: #6c757d; font-size: 0.875rem;">
|
||||
<i class="bi bi-clock me-1"></i>${newDuration}分钟
|
||||
<i class="bi bi-clock me-1"></i>${newDuration === 0 ? '不暂停' : newDuration + '分钟'}
|
||||
</span>
|
||||
`;
|
||||
showToast('暂停时间更新成功', 'success');
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
🎉1.新增qq直接回复闲鱼消息,无需在进入闲鱼;
|
||||
①回复哪条消息引用即可
|
||||
②系统设置维护qq回复秘钥
|
||||
|
||||
③在qq上给机器人发送 咸鱼绑定 key:url 其中key是你系统设置配置的秘钥,url 是你公网服务器的 ip加端口,例如 zheshimiyao:http://10.12.13.14:8080
|
||||
④如果没有公网,可联系我购买内网穿透服务,2块一个月,物美价廉
|
||||
🎉2.支持自动回复暂停时间支持设置为0;
|
||||
Loading…
Reference in New Issue
Block a user