Skip to content

feat(larklang): 自动删除文本结尾的空行 - #1352

Merged
This-is-XiaoDeng merged 12 commits into
mainfrom
feat/larklang-trim-trailing-newlines
Aug 16, 2026
Merged

feat(larklang): 自动删除文本结尾的空行#1352
This-is-XiaoDeng merged 12 commits into
mainfrom
feat/larklang-trim-trailing-newlines

Conversation

@This-is-XiaoDeng

Copy link
Copy Markdown
Member

改动内容

在 larklang 的 get_text() 返回文本时,自动清理结尾的空行(包括仅含空白字符的行),避免 YAML 块标量(如 |)保留的换行符导致消息末尾出现多余空行。

实现方式

  • 新增辅助函数 remove_trailing_blank_lines():用 splitlines() 拆行后从末尾弹出空行再重新拼接
  • get_text() 的 format 成功/失败两条返回路径上都应用清理
  • 不影响文本中间的空行,也不影响 [缺失: ...] 兜底文案

测试

新增 tests/test_larklang_trailing_blank_lines.py,覆盖:

  • 单/多个结尾换行
  • 仅含空白字符的结尾空行
  • 中间空行不受影响
  • 空字符串边界情况

pytest tests/test_larklang_trailing_blank_lines.py 通过 ✅

This-is-XiaoDeng and others added 7 commits August 8, 2026 10:36
…tream

Imports `ActionFailed` and moves token consumption to after a
successful send, so a failed delivery no longer burns tokens or
increments the consecutive-message counter.

When the QQ adapter returns error code 40034005 (expired
`reply_message_id`), the message is resent without its reply reference
and a warning is appended via the new `message.reply_skipped`
translation key, making the skipped reply visible to users instead of
silently dropping the whole send.
…ning

Refine the `MessageQueueItem` type to include an extra string field and
mark `mq_text` as optional via `NotRequired` in `CachedMessage`. Remove
the `reply_skipped` translation and its append logic in the processor
since reply references are no longer skipped; this simplifies the
message dispatch flow and aligns type annotations with actual usage.
get_text() 返回的文本现在会清理结尾的空行(含仅含空白字符的行),
避免 YAML 块标量(如 |)保留的换行符导致消息末尾出现多余空行。
不影响文本中间内容。

新增 remove_trailing_blank_lines 辅助函数及对应单元测试。
@github-actions
github-actions Bot requested review from montmorill and xxtg666 August 12, 2026 10:36
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@This-is-XiaoDeng
This-is-XiaoDeng merged commit 5a67436 into main Aug 16, 2026
5 checks passed
@This-is-XiaoDeng
This-is-XiaoDeng deleted the feat/larklang-trim-trailing-newlines branch August 16, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants