fix: 非 TTY 环境保留一句随机情话(修复后保人味)

上一版加载动画修复在非 TTY(聊天前端/管道)只输出静态提示,
导致聊天界面完全看不到情话、没了"人味"。

- 非 TTY 分支改为:请求开始时输出一句随机情话(💭 前缀),
  只打一次、不跑逐帧 \r 动画,零残帧污染
- love.txt 读取时过滤 http/https 行,避免把反战标语/网址当情话甩出
- 真 TTY 逐帧情话+spinner 动画、TUI 模式均不受影响
This commit is contained in:
shuiyu67 committed 2026-08-07 19:35:08 +08:00
1 parent c81914ab87
commit 1c52482497
1 file changed
+5 -3
+5 -3
View File
@@ -972,7 +972,9 @@ multi 操作支持一次修改多处:
if os.path.exists(love_file_path):
try:
with open(love_file_path, 'r', encoding='utf-8') as f:
love_sentences = [line.strip() for line in f.readlines() if line.strip()]
love_sentences = [line.strip() for line in f.readlines()
if line.strip()
and not line.strip().lower().startswith(('http://', 'https://'))]
except Exception:
pass
if not love_sentences:
@@ -1019,10 +1021,10 @@ multi 操作支持一次修改多处:
# ── 动画线程 ──
def show_animation():
# 非 TTY:只输出一行静态提示,不跑逐帧 \r 动画(避免残帧进入捕获流)
# 非 TTY:不跑逐帧 \r 动画(避免残帧进入捕获流),但保留一句随机情话保人味
if not is_tty:
try:
print("⏳ AI 正在思考中…", flush=True)
print(f"💭 {random.choice(love_sentences)}", flush=True)
except Exception:
pass
return