@hfyjq/crannia 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +48 -45
  3. package/README.md +1 -1
  4. package/THIRD-PARTY-FRONTEND.md +5266 -5266
  5. package/THIRD-PARTY-PYTHON-linux.md +174 -0
  6. package/THIRD-PARTY-PYTHON.md +176 -162
  7. package/THIRD-PARTY.md +323 -316
  8. package/apps/desktop/quotes.txt +56 -56
  9. package/bus/core.py +677 -671
  10. package/bus/loaders/channel_loader.py +64 -64
  11. package/bus/loaders/provider_loader.py +4 -7
  12. package/bus/loaders/skill_loader.py +46 -27
  13. package/bus/loaders/skill_md.py +9 -9
  14. package/bus/mcp_disabled.py +4 -6
  15. package/bus/quarantine.py +10 -13
  16. package/bus/registry.py +2315 -2284
  17. package/bus/skill_state.py +124 -124
  18. package/channels/cli_channel/handler.py +3 -3
  19. package/channels/cli_channel/manifest.yaml +5 -5
  20. package/channels/dingtalk_channel/handler.py +32 -32
  21. package/channels/dingtalk_channel/manifest.yaml +12 -12
  22. package/channels/feishu_channel/handler.py +33 -33
  23. package/channels/feishu_channel/manifest.yaml +12 -12
  24. package/channels/qq_bot_channel/__init__.py +1 -1
  25. package/channels/qq_bot_channel/handler.py +24 -24
  26. package/channels/qq_bot_channel/manifest.yaml +4 -4
  27. package/channels/telegram_channel/__init__.py +1 -1
  28. package/channels/telegram_channel/handler.py +21 -21
  29. package/channels/telegram_channel/manifest.yaml +4 -4
  30. package/channels/telegram_channel/media.py +231 -231
  31. package/channels/textfmt.py +58 -58
  32. package/channels/wechat_channel/__init__.py +1 -1
  33. package/channels/wechat_channel/converter.py +1 -1
  34. package/channels/wechat_channel/handler.py +8 -8
  35. package/channels/wechat_channel/manifest.yaml +5 -5
  36. package/channels/wechat_channel/media.py +178 -178
  37. package/core/activity.py +753 -709
  38. package/core/agent_loop.py +7673 -7522
  39. package/core/allowlist.py +2 -3
  40. package/core/approval.py +34 -24
  41. package/core/approval_timeout.py +256 -228
  42. package/core/artifacts.py +3 -3
  43. package/core/attachment_gc.py +21 -0
  44. package/core/auto_review.py +2 -2
  45. package/core/browser/cdp.py +5 -2
  46. package/core/browser/discover.py +55 -19
  47. package/core/browser/session.py +4 -4
  48. package/core/cache_break_detector.py +97 -0
  49. package/core/cache_breakpoints.py +103 -0
  50. package/core/cache_policies.py +255 -0
  51. package/core/cancellation.py +3 -3
  52. package/core/channel_configs.py +3 -3
  53. package/core/channel_turns.py +13 -13
  54. package/core/child_approval.py +2 -3
  55. package/core/code_intel.py +11 -11
  56. package/core/command_policy.py +13 -7
  57. package/core/computer/annotate.py +231 -11
  58. package/core/computer/capture.py +140 -1
  59. package/core/computer/guard.py +7 -4
  60. package/core/computer/input.py +452 -26
  61. package/core/computer/session.py +563 -381
  62. package/core/computer/tools.py +2170 -928
  63. package/core/computer/uia.py +100 -1
  64. package/core/computer/watch.py +1 -1
  65. package/core/computer/win32.py +302 -7
  66. package/core/config_requirements.py +205 -205
  67. package/core/cron/runner.py +4 -4
  68. package/core/daily_log.py +2 -2
  69. package/core/dedup.py +2 -2
  70. package/core/egress_channels.py +326 -0
  71. package/core/egress_gate.py +96 -8
  72. package/core/egress_preapproved.py +59 -3
  73. package/core/endpoint.py +141 -141
  74. package/core/events.py +17 -8
  75. package/core/extension.py +2 -2
  76. package/core/file_history.py +10 -10
  77. package/core/file_tools.py +3 -3
  78. package/core/github_config.py +1 -1
  79. package/core/group_digest.py +3 -4
  80. package/core/group_minutes.py +5 -5
  81. package/core/group_reply.py +24 -0
  82. package/core/groups.py +5 -9
  83. package/core/hooks.py +15 -15
  84. package/core/i18n.py +2 -2
  85. package/core/ice/canary.py +3 -3
  86. package/core/ice/net_heuristics.py +2 -2
  87. package/core/im_routing.py +2 -2
  88. package/core/image_input.py +183 -43
  89. package/core/inbound.py +3 -3
  90. package/core/jobs.py +6 -6
  91. package/core/last_good.py +150 -150
  92. package/core/leaf_md.py +3 -3
  93. package/core/llm_errors.py +36 -27
  94. package/core/mail_config.py +2 -2
  95. package/core/memory/compressor.py +8 -8
  96. package/core/memory/manager.py +30 -45
  97. package/core/memory/session_memory.py +1 -2
  98. package/core/memory/short_term.py +4 -4
  99. package/core/memory_extract.py +1 -1
  100. package/core/memory_organize.py +8 -8
  101. package/core/memory_store.py +7 -9
  102. package/core/memory_transfer.py +2 -2
  103. package/core/model_capabilities.py +2 -2
  104. package/core/model_configs.py +219 -68
  105. package/core/model_profiles.py +333 -0
  106. package/core/modes.py +12 -11
  107. package/core/net_proxy.py +3 -3
  108. package/core/pipeline/scheduler.py +48 -43
  109. package/core/pipeline/stage.py +3 -0
  110. package/core/pipeline/stages/agent_loop.py +36 -15
  111. package/core/pipeline/stages/group_reply.py +22 -20
  112. package/core/pipeline/stages/post_process.py +7 -7
  113. package/core/pipeline/stages/pre_process.py +360 -68
  114. package/core/prompt_assembler.py +13 -4
  115. package/core/recycle.py +227 -16
  116. package/core/response_language.py +1 -1
  117. package/core/retention.py +2 -2
  118. package/core/rg.py +4 -3
  119. package/core/security.py +26 -8
  120. package/core/services.py +8 -8
  121. package/core/session_model.py +3 -5
  122. package/core/session_pool.py +35 -5
  123. package/core/session_recap.py +40 -3
  124. package/core/session_workspace.py +2 -3
  125. package/core/settings_baseline.py +2 -2
  126. package/core/settings_transfer.py +25 -1
  127. package/core/shell.py +52 -20
  128. package/core/side_call.py +3 -3
  129. package/core/skill_config.py +164 -0
  130. package/core/skill_factory.py +2 -2
  131. package/core/skill_guidance.py +2 -4
  132. package/core/skill_index.py +3 -4
  133. package/core/skill_settings.py +1 -1
  134. package/core/skill_sources.py +7 -7
  135. package/core/ssh_config.py +129 -0
  136. package/core/state_registry.py +67 -5
  137. package/core/subagent.py +28 -5
  138. package/core/subagent_defs.py +3 -3
  139. package/core/summarizer.py +4 -5
  140. package/core/tasks_notify.py +6 -6
  141. package/core/tiers.py +2 -2
  142. package/core/todos.py +1 -1
  143. package/core/token_calibrator.py +1 -4
  144. package/core/tool_outcome.py +108 -108
  145. package/core/touched_files.py +1 -1
  146. package/core/trace.py +12 -3
  147. package/core/unlock.py +4 -4
  148. package/core/update_tui.py +184 -158
  149. package/core/updater.py +5 -3
  150. package/core/version.py +14 -14
  151. package/core/vision_budget.py +235 -0
  152. package/core/web_cache.py +152 -152
  153. package/core/web_request.py +474 -0
  154. package/core/window_estimate.py +1 -1
  155. package/core/workspace.py +56 -26
  156. package/crannia_tray.py +278 -278
  157. package/licenses/GPL-3.0.txt +619 -619
  158. package/licenses/LGPL-2.1.txt +502 -502
  159. package/licenses/LGPL-3.0.txt +165 -165
  160. package/licenses/MIT-chat-on-wechat.txt +18 -18
  161. package/licenses/MIT-deepseek-harness.txt +21 -21
  162. package/licenses/Molio-LICENSE.txt +44 -44
  163. package/locales/en.json +1876 -1755
  164. package/main.py +154 -154
  165. package/mcpx/client.py +12 -1
  166. package/mcpx/manager.py +530 -522
  167. package/mcpx/servers/web_search.py +5 -13
  168. package/package.json +15 -23
  169. package/providers/anthropic/client.py +35 -33
  170. package/providers/base.py +13 -13
  171. package/providers/cache_policies.json +294 -0
  172. package/providers/cost_table.json +3779 -3779
  173. package/providers/lmstudio/client.py +2 -2
  174. package/providers/model_capabilities.json +6665 -6665
  175. package/providers/model_profiles.json +629 -0
  176. package/providers/ollama/client.py +2 -2
  177. package/providers/openai_compat.py +37 -16
  178. package/providers/openrouter/client.py +2 -2
  179. package/providers/qwen/__init__.py +1 -1
  180. package/providers/qwen/client.py +2 -2
  181. package/providers/qwen/manifest.yaml +16 -16
  182. package/providers/rate_limiter.py +2 -2
  183. package/providers/siliconflow/client.py +2 -2
  184. package/providers/validation.py +171 -171
  185. package/providers/vision_profiles.json +89 -0
  186. package/providers/window_table.json +8909 -8909
  187. package/requirements.txt +59 -51
  188. package/sbom-linux-x64.json +4580 -0
  189. package/sbom.json +4600 -4413
  190. package/skills/diagram/SKILL.md +47 -0
  191. package/skills/diagram/__init__.py +1 -0
  192. package/skills/diagram/handler.py +294 -0
  193. package/skills/diagram/layout.py +174 -0
  194. package/skills/diagram/manifest.yaml +106 -0
  195. package/skills/diagram/mermaid.py +170 -0
  196. package/skills/diagram/svg.py +223 -0
  197. package/skills/entertainment/SKILL.md +35 -35
  198. package/skills/entertainment/__init__.py +1 -1
  199. package/skills/entertainment/handler.py +91 -91
  200. package/skills/entertainment/manifest.yaml +26 -26
  201. package/skills/file_parser/GUIDANCE.md +10 -10
  202. package/skills/file_parser/handler.py +33 -11
  203. package/skills/github/SKILL.md +32 -32
  204. package/skills/github/__init__.py +1 -1
  205. package/skills/mail_parser/SKILL.md +68 -68
  206. package/skills/mail_parser/__init__.py +1 -1
  207. package/skills/mail_parser/handler.py +1 -1
  208. package/skills/media_gen/GUIDANCE.md +19 -19
  209. package/skills/media_gen/SKILL.md +43 -43
  210. package/skills/media_gen/__init__.py +1 -1
  211. package/skills/media_gen/handler.py +1 -1
  212. package/skills/media_gen/manifest.yaml +93 -93
  213. package/skills/netops/SKILL.md +45 -0
  214. package/skills/netops/__init__.py +1 -0
  215. package/skills/netops/handler.py +418 -0
  216. package/skills/netops/manifest.yaml +118 -0
  217. package/skills/office_parser/_excel_io.py +3 -3
  218. package/skills/office_parser/handler.py +2 -2
  219. package/skills/office_parser/ppt_tools.py +1 -1
  220. package/skills/office_parser/pptx_export/console_encoding.py +27 -27
  221. package/skills/office_parser/pptx_export/resource_paths.py +88 -88
  222. package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
  223. package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
  224. package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
  225. package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
  226. package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
  227. package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
  228. package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
  229. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
  230. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
  231. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
  232. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
  233. package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
  234. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
  235. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
  236. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
  237. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
  238. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
  239. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
  240. package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
  241. package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
  242. package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
  243. package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
  244. package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
  245. package/skills/office_parser/references/layout_library.md +816 -816
  246. package/skills/office_parser/references/ppt-master/LICENSE +21 -21
  247. package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
  248. package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
  249. package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
  250. package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
  251. package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
  252. package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
  253. package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
  254. package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
  255. package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
  256. package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
  257. package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
  258. package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
  259. package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
  260. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
  261. package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
  262. package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
  263. package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
  264. package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
  265. package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
  266. package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
  267. package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
  268. package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
  269. package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
  270. package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
  271. package/skills/office_parser/references/spec_lock.md +235 -235
  272. package/skills/office_parser/soffice.py +68 -68
  273. package/skills/office_parser/word_tools.py +3 -3
  274. package/skills/ssh/SKILL.md +81 -0
  275. package/skills/ssh/__init__.py +1 -0
  276. package/skills/ssh/handler.py +609 -0
  277. package/skills/ssh/manifest.yaml +182 -0
  278. package/tui/crannia.cmd +134 -134
  279. package/tui/crannia.sh +82 -0
  280. package/tui/crannia_tui/__init__.py +1 -1
  281. package/tui/crannia_tui/app.py +240 -17
  282. package/tui/crannia_tui/app.tcss +21 -0
  283. package/tui/crannia_tui/clipboard.py +78 -10
  284. package/tui/crannia_tui/commands.py +37 -0
  285. package/tui/crannia_tui/events.py +6 -0
  286. package/tui/crannia_tui/i18n.py +164 -164
  287. package/tui/crannia_tui/locales/en.json +31 -6
  288. package/tui/crannia_tui/paths.py +4 -1
  289. package/tui/crannia_tui/profile.py +178 -169
  290. package/tui/crannia_tui/settings.py +134 -134
  291. package/tui/crannia_tui/setup.py +44 -5
  292. package/tui/crannia_tui/ui.py +156 -16
  293. package/tui/crannia_tui/update.py +393 -389
  294. package/vendor/ripgrep/COPYING.txt +3 -3
  295. package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
  296. package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
  297. package/vendor/ripgrep/README.md +30 -14
  298. package/vendor/ripgrep/UNLICENSE.txt +24 -24
  299. package/vendor/ripgrep/linux-x64/rg +0 -0
  300. package/vendor/ripgrep/package-source.json +15 -16
  301. package/web/__main__.py +12 -15
  302. package/web/server.py +8481 -8594
  303. package/web/static/img/channel-telegram.svg +1 -1
  304. package/web/static/img/channel-wechat.svg +1 -1
  305. package/web/templates/logs.html +49 -49
  306. package/web/templates/models.html +46 -46
@@ -252,11 +252,11 @@ class FeishuChannel(Channel):
252
252
  resp = client.im.v1.message.reply(req)
253
253
  if _response_ok(resp):
254
254
  return True
255
- print("[feishu] 回复被拒(msg_type=%s code=%s %s),改发普通消息"
255
+ print("[feishu] reply rejected (msg_type=%s code=%s %s), sending as normal message"
256
256
  % (msg_type, getattr(resp, "code", "?"),
257
257
  getattr(resp, "msg", "")))
258
258
  except Exception as e: # noqa: BLE001
259
- print(f"[feishu] 回复失败({type(e).__name__}: {e}),改发普通消息")
259
+ print(f"[feishu] reply failed ({type(e).__name__}: {e}), sending as normal message")
260
260
 
261
261
  #: 形状即真相(飞书的 id 带前缀:`oc_` 群/会话、`ou_` 用户)
262
262
  receive_id_type = ("chat_id" if str(session.session_id).startswith("oc_")
@@ -272,10 +272,10 @@ class FeishuChannel(Channel):
272
272
  .build()
273
273
  resp = client.im.v1.message.create(req)
274
274
  except Exception as e: # noqa: BLE001
275
- print(f"[feishu] send error({type(e).__name__}: {e})")
275
+ print(f"[feishu] send error ({type(e).__name__}: {e})")
276
276
  return False
277
277
  if not _response_ok(resp):
278
- print("[feishu] send rejected(msg_type=%s code=%s %s)"
278
+ print("[feishu] send rejected (msg_type=%s code=%s %s)"
279
279
  % (msg_type, getattr(resp, "code", "?"),
280
280
  getattr(resp, "msg", "")))
281
281
  return False
@@ -288,21 +288,21 @@ class FeishuChannel(Channel):
288
288
  """上传 + 发一条(图片走 `image`,其余走 `file`)。"""
289
289
  p = Path(str(file_path or ""))
290
290
  if not p.is_file():
291
- print("[feishu] 要发的文件不存在:%s" % (file_path or "(空)"))
291
+ print("[feishu] file to send does not exist: %s" % (file_path or "(empty)"))
292
292
  return False
293
293
  data = p.read_bytes()
294
294
  mime, _ = mimetypes.guess_type(p.name)
295
295
  is_image = (mime or "").lower().startswith("image/")
296
296
  limit = MAX_IMAGE_BYTES if is_image else MAX_FILE_BYTES
297
297
  if len(data) > limit:
298
- print("[feishu] 文件太大(%d 字节 > %d),没有上传:%s"
298
+ print("[feishu] file too large (%d bytes > %d), not uploaded: %s"
299
299
  % (len(data), limit, p.name))
300
300
  return False
301
301
  name = filename or p.name
302
302
  try:
303
303
  client = self._get_client()
304
304
  except ImportError:
305
- print("[feishu] 没装 lark-oapi,发不了附件")
305
+ print("[feishu] lark-oapi not installed, cannot send attachment")
306
306
  return False
307
307
  try:
308
308
  if is_image:
@@ -315,7 +315,7 @@ class FeishuChannel(Channel):
315
315
  resp = client.im.v1.image.create(req)
316
316
  key = getattr(getattr(resp, "data", None), "image_key", "") or ""
317
317
  if not _response_ok(resp) or not key:
318
- print("[feishu] 图片上传失败(code=%s %s)"
318
+ print("[feishu] image upload failed (code=%s %s)"
319
319
  % (getattr(resp, "code", "?"), getattr(resp, "msg", "")))
320
320
  return False
321
321
  return self._post_message(
@@ -331,7 +331,7 @@ class FeishuChannel(Channel):
331
331
  resp = client.im.v1.file.create(req)
332
332
  key = getattr(getattr(resp, "data", None), "file_key", "") or ""
333
333
  if not _response_ok(resp) or not key:
334
- print("[feishu] 文件上传失败(code=%s %s)"
334
+ print("[feishu] file upload failed (code=%s %s)"
335
335
  % (getattr(resp, "code", "?"), getattr(resp, "msg", "")))
336
336
  return False
337
337
  return self._post_message(
@@ -339,7 +339,7 @@ class FeishuChannel(Channel):
339
339
  json.dumps({"file_key": key, "file_name": name},
340
340
  ensure_ascii=False))
341
341
  except Exception as e: # noqa: BLE001
342
- print(f"[feishu] 附件发送失败({type(e).__name__}: {e})")
342
+ print(f"[feishu] attachment send failed ({type(e).__name__}: {e})")
343
343
  return False
344
344
 
345
345
  def _drain_sync(self, session: MessageSession, reply_to: str = "") -> None:
@@ -351,7 +351,7 @@ class FeishuChannel(Channel):
351
351
  channel="feishu_channel",
352
352
  user_id=session.session_id)
353
353
  except Exception as exc: # noqa: BLE001
354
- print(f"[feishu] 取待发文件失败({type(exc).__name__}: {exc})")
354
+ print(f"[feishu] failed to fetch pending files ({type(exc).__name__}: {exc})")
355
355
  return
356
356
  for rec in recs:
357
357
  ok = self._send_media_sync(session, rec.get("path", ""),
@@ -407,22 +407,22 @@ class FeishuChannel(Channel):
407
407
  if not kind:
408
408
  continue
409
409
  if not message_id:
410
- print("[feishu] 消息里没有 message_id,取不到附件:%s" % key)
410
+ print("[feishu] message has no message_id, cannot fetch attachment: %s" % key)
411
411
  continue
412
412
  try:
413
413
  data, real_name = await asyncio.to_thread(
414
414
  self._download_resource, message_id, key, kind)
415
415
  except Exception as exc: # noqa: BLE001
416
- print(f"[feishu] 取附件失败({type(exc).__name__}: {exc})")
416
+ print(f"[feishu] failed to fetch attachment ({type(exc).__name__}: {exc})")
417
417
  continue
418
418
  if not data:
419
419
  # 空字节不是"一个空文件":它多半是"响应 200 但没有正文"。
420
420
  # 以前会落一个 0 字节的文件,下游只能说"附件是空的"。
421
- print("[feishu] 取回来的附件是空的(kind=%s key=%s…)"
421
+ print("[feishu] fetched attachment is empty (kind=%s key=%s...)"
422
422
  % (kind, str(key)[:8]))
423
423
  continue
424
424
  if len(data) > feishu_media.MAX_DOWNLOAD_BYTES:
425
- print("[feishu] 附件太大(%d 字节),没有下载:%s"
425
+ print("[feishu] attachment too large (%d bytes), not downloaded: %s"
426
426
  % (len(data), key))
427
427
  continue
428
428
  name = getattr(comp, "name", "") or real_name
@@ -430,12 +430,12 @@ class FeishuChannel(Channel):
430
430
  path = await asyncio.to_thread(
431
431
  self._save_media, data, kind, key, name)
432
432
  except Exception as exc: # noqa: BLE001
433
- print(f"[feishu] 附件落盘失败({type(exc).__name__}: {exc})")
433
+ print(f"[feishu] failed to save attachment ({type(exc).__name__}: {exc})")
434
434
  continue
435
435
  comp.local_path = str(path)
436
436
  if hasattr(comp, "size_bytes"):
437
437
  comp.size_bytes = len(data)
438
- print("[feishu] 附件已落盘:%s(%d 字节)" % (path.name, len(data)))
438
+ print("[feishu] attachment saved: %s (%d bytes)" % (path.name, len(data)))
439
439
 
440
440
  # ------------------------------------------------------------------
441
441
  # Event handling (called from worker thread via _FeishuEventHandler)
@@ -454,7 +454,7 @@ class FeishuChannel(Channel):
454
454
  if not self._main_loop or not self._running:
455
455
  # 这一条不许静默:通道还没就绪时消息会凭空消失,
456
456
  # 看来就像"对方那条消息没发出来"。
457
- print("[feishu] 通道还没就绪(main_loop/running),这条消息丢了:type=%s"
457
+ print("[feishu] channel not ready (main_loop/running), message dropped: type=%s"
458
458
  % (msg_data.get("message_type") or "?"))
459
459
  return
460
460
  try:
@@ -465,7 +465,7 @@ class FeishuChannel(Channel):
465
465
  # 没有回复、也没有步骤流(症状与"这条消息没收到"一模一样)。
466
466
  fut.add_done_callback(_report_future_error)
467
467
  except Exception as exc: # noqa: BLE001
468
- print(f"[feishu] 投递事件失败({type(exc).__name__}: {exc})")
468
+ print(f"[feishu] failed to dispatch event ({type(exc).__name__}: {exc})")
469
469
 
470
470
  async def _handle(self, msg_data: dict, event_data: dict) -> None:
471
471
  """主循环上的处理:转换 → 取附件 → 提交事件 → 管线。"""
@@ -480,20 +480,20 @@ class FeishuChannel(Channel):
480
480
  #: "消息像没收到"这一类只能靠它区分是"没进来"还是"进来后被丢了"。
481
481
  #: 带消息号前 8 位 —— "它怎么自己又回了一遍"只能靠它区分
482
482
  #: "同一条被重投"(号相同,会被去重闸拦)与"真的又发了一条"(号不同)。
483
- print("[feishu] 收到消息 type=%s chat=%s id=%s keys=%s"
483
+ print("[feishu] message received type=%s chat=%s id=%s keys=%s"
484
484
  % (msg_type or "?",
485
- (str(chat_id)[:10] + "…") if chat_id else "(空)",
486
- (str(msg_id)[:8] + "…") if msg_id else "(空)",
487
- ",".join(sorted(feishu_media.content_of(msg_data).keys())) or "(空)"))
485
+ (str(chat_id)[:10] + "…") if chat_id else "(empty)",
486
+ (str(msg_id)[:8] + "…") if msg_id else "(empty)",
487
+ ",".join(sorted(feishu_media.content_of(msg_data).keys())) or "(empty)"))
488
488
 
489
489
  chain = FeishuMessageConverter().to_internal(msg_data)
490
490
  if chain.is_empty:
491
491
  # `system`(入群/退群等)本来就没有给模型的内容 —— 不打日志。
492
492
  if msg_type != "system":
493
- print("[feishu] 收到一条没有可用内容的消息(type=%s,content 键=%s)"
493
+ print("[feishu] message has no usable content (type=%s, content keys=%s)"
494
494
  % (msg_type or "?",
495
495
  ",".join(sorted(feishu_media.content_of(msg_data).keys()))
496
- or "(空)"))
496
+ or "(empty)"))
497
497
  return
498
498
 
499
499
  await self._resolve_media(chain, msg_id)
@@ -561,11 +561,11 @@ class FeishuChannel(Channel):
561
561
  in_thread=in_thread)
562
562
  #: 每一次发出都留一行:两行 = 两遍(用户能看到"又回了一遍"这
563
563
  #: 件事的现场),零行 = 它压根没发出去。
564
- print("[feishu] 回复已发出(%d 字符,%s,msg=%s)"
565
- % (len(response), "成功" if ok else "失败",
566
- (str(message_id)[:8] + "…") if message_id else "(空)"))
564
+ print("[feishu] reply sent (%d chars, %s, msg=%s)"
565
+ % (len(response), "ok" if ok else "failed",
566
+ (str(message_id)[:8] + "…") if message_id else "(empty)"))
567
567
  else:
568
- print("[feishu] 这一轮没有回复文本(不发送)")
568
+ print("[feishu] no reply text this turn (not sending)")
569
569
  self._drain_sync(event.session, message_id)
570
570
 
571
571
 
@@ -581,7 +581,7 @@ def _report_future_error(fut: Any) -> None:
581
581
  except Exception: # noqa: BLE001
582
582
  return
583
583
  if exc is not None:
584
- print("[feishu] 处理这条消息时抛了异常(这一条没能进入管线):%s: %s"
584
+ print("[feishu] exception while handling message (not entering pipeline): %s: %s"
585
585
  % (type(exc).__name__, exc))
586
586
 
587
587
 
@@ -765,7 +765,7 @@ class FeishuMessageConverter:
765
765
  # `container_id_type` 取值在本机 SDK 里没有依据,不猜,
766
766
  # 如实说明 + 打日志(别让它变成"机器人不理我")。
767
767
  comps.append(Plain(text="[合并转发的聊天记录](暂不支持展开)"))
768
- print("[feishu] 合并转发消息:暂不支持展开")
768
+ print("[feishu] merged-forward message: expansion not supported")
769
769
 
770
770
  elif msg_type == "system":
771
771
  # 入群 / 退群 / 改名 —— 不是给模型的输入。
@@ -925,12 +925,12 @@ class FeishuMessageConverter:
925
925
  name=_f["file_name"],
926
926
  url=feishu_media.SCHEME + "file/" + _f["file_key"],
927
927
  mime_type=_mime_of(_f["file_name"])))
928
- print("[feishu] 富文本顶层 files 里的附件:%s" % _f["file_name"])
928
+ print("[feishu] attachment in rich-text top-level files: %s" % _f["file_name"])
929
929
 
930
930
  if unknown:
931
931
  #: 出声:这条消息照常处理,但那种元素我们没接住 ——
932
932
  #: 下一次"模型看不见"的现场,日志里要有这句话当线索。
933
- print("[feishu] post 里有没见过的元素标签:%s(其余部分照常处理)"
933
+ print("[feishu] unknown element tag in post: %s (rest handled normally)"
934
934
  % ",".join(sorted(set(unknown))))
935
935
 
936
936
  text = feishu_media.replace_mentions("\n".join(texts), mentions)
@@ -1,12 +1,12 @@
1
- kind: channel
2
- name: feishu_channel
3
- version: "0.1.0"
4
- description: "Feishu (Lark) IM channel via lark-oapi WebSocket long connection. No public IP required."
5
-
6
- config:
7
- platform_type: feishu
8
- support_multimodal: true
9
- support_streaming: true
10
-
11
- required_packages:
12
- - lark-oapi
1
+ kind: channel
2
+ name: feishu_channel
3
+ version: "0.1.0"
4
+ description: "Feishu (Lark) IM channel via lark-oapi WebSocket long connection. No public IP required."
5
+
6
+ config:
7
+ platform_type: feishu
8
+ support_multimodal: true
9
+ support_streaming: true
10
+
11
+ required_packages:
12
+ - lark-oapi
@@ -1 +1 @@
1
- """QQ 机器人通道(官方 Bot API v2)。"""
1
+ """QQ 机器人通道(官方 Bot API v2)。"""
@@ -86,7 +86,7 @@ def _load_credentials() -> dict:
86
86
  data = json.load(f)
87
87
  return data if isinstance(data, dict) else {}
88
88
  except (OSError, json.JSONDecodeError) as exc:
89
- print("[qq_bot] 读凭据文件失败(%s: %s)" % (type(exc).__name__, exc))
89
+ print("[qq_bot] failed to read credentials file (%s: %s)" % (type(exc).__name__, exc))
90
90
  return {}
91
91
 
92
92
 
@@ -348,7 +348,7 @@ class QQBotChannel(Channel):
348
348
  try:
349
349
  creds = _load_credentials()
350
350
  except Exception as exc: # noqa: BLE001
351
- print("[qq_bot] 读凭据失败(%s: %s)" % (type(exc).__name__, exc))
351
+ print("[qq_bot] failed to read credentials (%s: %s)" % (type(exc).__name__, exc))
352
352
  creds = {}
353
353
  self._app_id = str(cfg.get("app_id") or creds.get("app_id")
354
354
  or os.environ.get("QQ_BOT_APP_ID") or "")
@@ -393,7 +393,7 @@ class QQBotChannel(Channel):
393
393
  self._proxy = self._resolve_proxy()
394
394
  if self._proxy:
395
395
  from core.net_proxy import redact as _redact
396
- print("[qq_bot] 使用代理:%s" % _redact(self._proxy))
396
+ print("[qq_bot] using proxy: %s" % _redact(self._proxy))
397
397
  backoff = 2.0
398
398
  try:
399
399
  proxy = self._proxy or None
@@ -412,7 +412,7 @@ class QQBotChannel(Channel):
412
412
  if not self._running:
413
413
  break
414
414
  self._fail_start("%s: %s" % (type(exc).__name__, exc))
415
- print("[qq_bot] 网关断开,%d 秒后重连" % int(backoff))
415
+ print("[qq_bot] gateway disconnected, reconnecting in %d s" % int(backoff))
416
416
  await asyncio.sleep(backoff)
417
417
  backoff = min(backoff * 2, 60.0)
418
418
  finally:
@@ -433,7 +433,7 @@ class QQBotChannel(Channel):
433
433
  component_vars={"msg": message},
434
434
  error_tpl="{msg}", error_vars={"msg": message})
435
435
  except Exception as exc:
436
- print("[qq_bot] 记事故失败(%s: %s)" % (type(exc).__name__, exc))
436
+ print("[qq_bot] failed to record incident (%s: %s)" % (type(exc).__name__, exc))
437
437
 
438
438
  async def _gateway_once(self, proxy: str | None) -> None:
439
439
  """连一次网关,直到它自己断开或要求重连。"""
@@ -474,7 +474,7 @@ class QQBotChannel(Channel):
474
474
  if op == 11:
475
475
  continue
476
476
  if op == 7:
477
- print("[qq_bot] 平台要求重连")
477
+ print("[qq_bot] platform requested reconnect")
478
478
  return
479
479
  if op == 9:
480
480
  self._seq = None
@@ -548,13 +548,13 @@ class QQBotChannel(Channel):
548
548
  except asyncio.CancelledError:
549
549
  raise
550
550
  except Exception as exc:
551
- print("[qq_bot] 心跳停了(%s: %s)" % (type(exc).__name__, exc))
551
+ print("[qq_bot] heartbeat stopped (%s: %s)" % (type(exc).__name__, exc))
552
552
 
553
553
  async def _dispatch(self, event_type: str, data: dict) -> None:
554
554
  if event_type == "READY":
555
555
  user = data.get("user") or {}
556
556
  self._bot_openid = str(user.get("id") or "")
557
- print("[qq_bot] 已连接(bot id=%s)" % (self._bot_openid or "?"))
557
+ print("[qq_bot] connected (bot id=%s)" % (self._bot_openid or "?"))
558
558
  try:
559
559
  from core import incidents as _inc
560
560
  _inc.resolve("qq_bot_channel", "channel")
@@ -566,7 +566,7 @@ class QQBotChannel(Channel):
566
566
  try:
567
567
  await self._handle_message(event_type, data)
568
568
  except Exception as exc:
569
- print("[qq_bot] 处理消息出错(%s: %s)" % (type(exc).__name__, exc))
569
+ print("[qq_bot] error handling message (%s: %s)" % (type(exc).__name__, exc))
570
570
 
571
571
  # 入站
572
572
 
@@ -594,7 +594,7 @@ class QQBotChannel(Channel):
594
594
  if not target_id:
595
595
  #: 只打键名,不打值 —— 那些值里是用户的 openid。
596
596
  #: 打出来是为了下一次现场能把它补进 `_c2c_openid` 那张表。
597
- print("[qq_bot] 这条事件没有回话对象,跳过(t=%s,顶层键=%s)"
597
+ print("[qq_bot] event has no reply target, skipped (t=%s, top-level keys=%s)"
598
598
  % (event_type, ",".join(sorted(str(k) for k in data))))
599
599
  return
600
600
 
@@ -614,8 +614,8 @@ class QQBotChannel(Channel):
614
614
  )
615
615
  self._budget.remember(str(session), scope, msg_id)
616
616
 
617
- text = chain.content[:80] if chain.content else "[媒体]"
618
- print("[qq_bot] %s 收到消息:%s" % (scope, text))
617
+ text = chain.content[:80] if chain.content else "[media]"
618
+ print("[qq_bot] %s message received: %s" % (scope, text))
619
619
 
620
620
  message = Message(
621
621
  sender_id=sender_id,
@@ -651,7 +651,7 @@ class QQBotChannel(Channel):
651
651
  try:
652
652
  path = await self._download_one(item, url)
653
653
  except Exception as exc:
654
- print("[qq_bot] 下载附件失败(%s: %s)"
654
+ print("[qq_bot] failed to download attachment (%s: %s)"
655
655
  % (type(exc).__name__, exc))
656
656
  path = ""
657
657
  if path:
@@ -663,7 +663,7 @@ class QQBotChannel(Channel):
663
663
  async def _download_one(self, item: dict, url: str) -> str:
664
664
  size = int((item or {}).get("size") or 0)
665
665
  if size > _MAX_DOWNLOAD_BYTES:
666
- print("[qq_bot] 附件太大(%d 字节),不下载" % size)
666
+ print("[qq_bot] attachment too large (%d bytes), not downloading" % size)
667
667
  return ""
668
668
  name = str((item or {}).get("filename") or "")
669
669
  suffix = Path(name).suffix or ".bin"
@@ -697,7 +697,7 @@ class QQBotChannel(Channel):
697
697
  try:
698
698
  await self._drain_delivered(session)
699
699
  except Exception as exc:
700
- print("[qq_bot] 发待交付文件时出错(%s: %s)"
700
+ print("[qq_bot] error sending pending delivery files (%s: %s)"
701
701
  % (type(exc).__name__, exc))
702
702
 
703
703
  async def _send_text(self, scope: str, target_id: str, text: str,
@@ -730,10 +730,10 @@ class QQBotChannel(Channel):
730
730
  if resp.status in (200, 201, 202):
731
731
  return True
732
732
  status, body = resp.status, await resp.text()
733
- print("[qq_bot] 发送被拒(%d):%s" % (status, body[:200]))
733
+ print("[qq_bot] send rejected (%d): %s" % (status, body[:200]))
734
734
  return False
735
735
  except Exception as exc:
736
- print("[qq_bot] 发送失败(%s: %s)" % (type(exc).__name__, exc))
736
+ print("[qq_bot] send failed (%s: %s)" % (type(exc).__name__, exc))
737
737
  return False
738
738
 
739
739
  async def send(self, session: MessageSession, content: str | MessageChain) -> bool:
@@ -763,7 +763,7 @@ class QQBotChannel(Channel):
763
763
  """
764
764
  path = Path(file_path or "")
765
765
  if not path.is_file():
766
- print("[qq_bot] 要发的文件不存在:%s" % file_path)
766
+ print("[qq_bot] file to send does not exist: %s" % file_path)
767
767
  return False
768
768
  scope = "group" if session.message_type is MessageType.GROUP else "c2c"
769
769
  target_id = str(session.session_id)
@@ -780,16 +780,16 @@ class QQBotChannel(Channel):
780
780
  proxy=self._proxy or None) as resp:
781
781
  if resp.status not in (200, 201, 202):
782
782
  status, body = resp.status, await resp.text()
783
- print("[qq_bot] 上传文件被拒(%d):%s" % (status, body[:200]))
783
+ print("[qq_bot] file upload rejected (%d): %s" % (status, body[:200]))
784
784
  return False
785
785
  info = await resp.json(content_type=None)
786
786
  except Exception as exc:
787
- print("[qq_bot] 上传文件失败(%s: %s)" % (type(exc).__name__, exc))
787
+ print("[qq_bot] file upload failed (%s: %s)" % (type(exc).__name__, exc))
788
788
  return False
789
789
 
790
790
  file_info = str((info or {}).get("file_info") or "")
791
791
  if not file_info:
792
- print("[qq_bot] 上传成功但没拿到 file_info,没法发消息")
792
+ print("[qq_bot] upload succeeded but no file_info, cannot send message")
793
793
  return False
794
794
 
795
795
  msg_id, _ = self._budget.last_for(str(session))
@@ -806,10 +806,10 @@ class QQBotChannel(Channel):
806
806
  if resp.status in (200, 201, 202):
807
807
  return True
808
808
  status, body = resp.status, await resp.text()
809
- print("[qq_bot] 发送文件消息被拒(%d):%s" % (status, body[:200]))
809
+ print("[qq_bot] file message rejected (%d): %s" % (status, body[:200]))
810
810
  return False
811
811
  except Exception as exc:
812
- print("[qq_bot] 发送文件消息失败(%s: %s)" % (type(exc).__name__, exc))
812
+ print("[qq_bot] file message failed (%s: %s)" % (type(exc).__name__, exc))
813
813
  return False
814
814
 
815
815
  async def _drain_delivered(self, session: MessageSession) -> int:
@@ -827,7 +827,7 @@ class QQBotChannel(Channel):
827
827
  channel="qq_bot_channel",
828
828
  user_id=str(getattr(session, "session_id", "") or ""))
829
829
  except Exception as exc:
830
- print("[qq_bot] 取待发文件失败(%s: %s)" % (type(exc).__name__, exc))
830
+ print("[qq_bot] failed to fetch pending files (%s: %s)" % (type(exc).__name__, exc))
831
831
  return 0
832
832
  sent = 0
833
833
  for rec in recs:
@@ -1,4 +1,4 @@
1
- kind: channel
2
- name: qq_bot_channel
3
- description: QQ Bot adapter — official Bot API v2 (WebSocket gateway + REST)
4
- version: 0.1.0
1
+ kind: channel
2
+ name: qq_bot_channel
3
+ description: QQ Bot adapter — official Bot API v2 (WebSocket gateway + REST)
4
+ version: 0.1.0
@@ -1 +1 @@
1
- """Telegram channel adapter."""
1
+ """Telegram channel adapter."""
@@ -333,7 +333,7 @@ class TelegramChannel(Channel):
333
333
  #: 再处理一遍(去重缓存重启后是空的,拦不住)。
334
334
  offset = _load_offset()
335
335
  if offset:
336
- print("[telegram] 从上次的游标接着收(update_id >= %d)" % offset)
336
+ print("[telegram] resuming from last cursor (update_id >= %d)" % offset)
337
337
 
338
338
  while self._running:
339
339
  retries = 0
@@ -386,14 +386,14 @@ class TelegramChannel(Channel):
386
386
  except Exception: # noqa: BLE001
387
387
  chat_id = None
388
388
  if chat_id is None or self._bot is None:
389
- print("[telegram] 这条消息没处理成,且没有可用的会话回话 —— 只能记日志")
389
+ print("[telegram] could not handle message and no chat to reply to -- logging only")
390
390
  return
391
391
  try:
392
392
  await self._bot.send_message(
393
393
  chat_id=chat_id,
394
394
  text="⚠️ 消息遗失,未接收,需要时请重新发送。")
395
395
  except Exception as e: # noqa: BLE001
396
- print(f"[telegram] 「消息遗失」提醒没发出去:"
396
+ print(f"[telegram] failed to send lost-message notice: "
397
397
  f"{type(e).__name__}: {e}")
398
398
 
399
399
  async def terminate(self) -> None:
@@ -441,7 +441,7 @@ class TelegramChannel(Channel):
441
441
  and not tg_media.addressed_to_bot(
442
442
  getattr(update, "message", None),
443
443
  self._bot_username, self._bot_id)):
444
- print("[telegram] 群里这条不是在跟我说话,跳过(chat=%s)"
444
+ print("[telegram] group message not addressed to me, skipped (chat=%s)"
445
445
  % session.session_id)
446
446
  return None
447
447
 
@@ -493,7 +493,7 @@ class TelegramChannel(Channel):
493
493
  try:
494
494
  await self._drain_delivered(self._make_session(update))
495
495
  except Exception as e: # noqa: BLE001
496
- print(f"[telegram] 发待交付文件时出错({type(e).__name__}: {e})")
496
+ print(f"[telegram] error sending pending delivery files ({type(e).__name__}: {e})")
497
497
 
498
498
  async def send(self, session: MessageSession, content: str | MessageChain) -> bool:
499
499
  """没有 Bot 就是没送达 —— 以前这一支什么都不做、也不出声。
@@ -505,11 +505,11 @@ class TelegramChannel(Channel):
505
505
  这条路上,那是文件唯一的出口(同微信 / 飞书 / 钉钉)。
506
506
  """
507
507
  if not self._bot:
508
- print(f"[telegram] 没有 Bot 实例,这条没有送达:{session.session_id}")
508
+ print(f"[telegram] no Bot instance, not delivered: {session.session_id}")
509
509
  return False
510
510
  chat_id = _chat_id_of(session)
511
511
  if chat_id is None:
512
- print(f"[telegram] 会话 id 不是数字,发不出去:{session.session_id!r}")
512
+ print(f"[telegram] chat id is not numeric, cannot send: {session.session_id!r}")
513
513
  return False
514
514
  text = content if isinstance(content, str) else content.content
515
515
  delivered = False
@@ -528,7 +528,7 @@ class TelegramChannel(Channel):
528
528
  (用户先看到文件、再看到回答)。判据见 `channels/base.py::send_note`。
529
529
  """
530
530
  if not self._bot:
531
- print(f"[telegram] 没有 Bot 实例,这句旁白没送达:{session.session_id}")
531
+ print(f"[telegram] no Bot instance, note not delivered: {session.session_id}")
532
532
  return False
533
533
  chat_id = _chat_id_of(session)
534
534
  if chat_id is None or not str(text or "").strip():
@@ -571,15 +571,15 @@ class TelegramChannel(Channel):
571
571
  签名,`deliver_file` 那侧按属性存在认通道。
572
572
  """
573
573
  if not self._bot:
574
- print("[telegram] 没有 Bot 实例,附件发不出去")
574
+ print("[telegram] no Bot instance, cannot send attachment")
575
575
  return False
576
576
  p = Path(str(file_path or ""))
577
577
  if not p.is_file():
578
- print("[telegram] 要发的文件不存在:%s" % (file_path or "(空)"))
578
+ print("[telegram] file to send does not exist: %s" % (file_path or "(empty)"))
579
579
  return False
580
580
  chat_id = _chat_id_of(session)
581
581
  if chat_id is None:
582
- print(f"[telegram] 会话 id 不是数字,附件发不出去:{session.session_id!r}")
582
+ print(f"[telegram] chat id is not numeric, cannot send attachment: {session.session_id!r}")
583
583
  return False
584
584
  name = filename or p.name
585
585
  kind = tg_media.outbound_kind(name)
@@ -595,9 +595,9 @@ class TelegramChannel(Channel):
595
595
  self._bot.send_document, chat_id=chat_id,
596
596
  document=upload)
597
597
  except Exception as exc: # noqa: BLE001
598
- print(f"[telegram] 附件发送失败({type(exc).__name__}: {exc})")
598
+ print(f"[telegram] attachment send failed ({type(exc).__name__}: {exc})")
599
599
  return False
600
- print("[telegram] 附件已发送:%s(%s)" % (name, kind))
600
+ print("[telegram] attachment sent: %s (%s)" % (name, kind))
601
601
  return True
602
602
 
603
603
  async def _drain_delivered(self, session: MessageSession) -> int:
@@ -616,7 +616,7 @@ class TelegramChannel(Channel):
616
616
  channel="telegram_channel",
617
617
  user_id=str(getattr(session, "session_id", "") or ""))
618
618
  except Exception as exc: # noqa: BLE001
619
- print(f"[telegram] 取待发文件失败({type(exc).__name__}: {exc})")
619
+ print(f"[telegram] failed to fetch pending files ({type(exc).__name__}: {exc})")
620
620
  return 0
621
621
  sent = 0
622
622
  for rec in recs:
@@ -653,11 +653,11 @@ class TelegramChannel(Channel):
653
653
  for item in tg_media.items_of(tg_msg):
654
654
  file_id = str(item.get("file_id") or "")
655
655
  if not file_id:
656
- print("[telegram] 媒体没有 file_id,跳过(kind=%s)" % item.get("kind"))
656
+ print("[telegram] media has no file_id, skipped (kind=%s)" % item.get("kind"))
657
657
  continue
658
658
  size = int(item.get("size") or 0)
659
659
  if size > tg_media.MAX_DOWNLOAD_BYTES:
660
- print("[telegram] 附件太大(%d 字节 > %d),没有下载:%s"
660
+ print("[telegram] attachment too large (%d bytes > %d), not downloaded: %s"
661
661
  % (size, tg_media.MAX_DOWNLOAD_BYTES, item.get("name")))
662
662
  continue
663
663
  try:
@@ -667,10 +667,10 @@ class TelegramChannel(Channel):
667
667
  tg_media.ext_of(item)))
668
668
  await tg_file.download_to_drive(path)
669
669
  out.append((item, str(path)))
670
- print("[telegram] 附件已落盘:%s(%s,%d 字节)"
670
+ print("[telegram] attachment saved: %s (%s, %d bytes)"
671
671
  % (path.name, item.get("kind"), size))
672
672
  except Exception as exc: # noqa: BLE001
673
- print(f"[telegram] 取附件失败({type(exc).__name__}: {exc})")
673
+ print(f"[telegram] failed to fetch attachment ({type(exc).__name__}: {exc})")
674
674
  return out
675
675
 
676
676
  # ------------------------------------------------------------------
@@ -697,7 +697,7 @@ class TelegramChannel(Channel):
697
697
  wait = _retry_after_of(exc)
698
698
  if wait is None:
699
699
  raise
700
- print("[telegram] 被限流,%.0f 秒后重试一次" % wait)
700
+ print("[telegram] rate limited, retrying once in %.0f s" % wait)
701
701
  await asyncio.sleep(wait)
702
702
  return await fn(*args, **kwargs)
703
703
 
@@ -730,7 +730,7 @@ def _load_offset(path: Path | None = None) -> int:
730
730
  except FileNotFoundError:
731
731
  return 0
732
732
  except Exception as exc: # noqa: BLE001
733
- print("[telegram] 游标读不出来,从 0 开始(可能重放积压):%s: %s"
733
+ print("[telegram] cannot read cursor, starting from 0 (backlog may replay): %s: %s"
734
734
  % (type(exc).__name__, exc))
735
735
  return 0
736
736
  try:
@@ -749,7 +749,7 @@ def _save_offset(value: int, path: Path | None = None) -> None:
749
749
  tmp.replace(p)
750
750
  except Exception as exc: # noqa: BLE001
751
751
  # 写不进去也要出声:否则下次重启静默重放
752
- print("[telegram] 游标写不进去(重启会重放积压):%s: %s"
752
+ print("[telegram] cannot write cursor (backlog replays on restart): %s: %s"
753
753
  % (type(exc).__name__, exc))
754
754
 
755
755
 
@@ -1,4 +1,4 @@
1
- kind: channel
2
- name: telegram_channel
3
- description: Telegram Bot adapter — multi-user messaging via Telegram Bot API
4
- version: 0.1.0
1
+ kind: channel
2
+ name: telegram_channel
3
+ description: Telegram Bot adapter — multi-user messaging via Telegram Bot API
4
+ version: 0.1.0