Commit Graph
18 Commits
Author SHA1 Message Date
H3CoF6 0401ac4afb feat: implement some group album actions 2026-05-16 12:17:23 +08:00
H3CoF6 b176e929b9 feat: implement upload group avatar 2026-05-14 04:09:55 +08:00
DrSmoothl ea5a1d505a feat: add forward message preview metadata support 2026-05-13 20:53:26 +08:00
DrSmoothl b32a8110af refactor(core): make ApiActionContext required, drop 80 dead defensive guards
ApiActionContext had 81 optional method fields (\`name?: ...\`) plus 4
required ones — but every single optional field was wired in
buildApiContext (verified by diffing the two lists). The optionality
was dead: nothing else implemented this interface, no test ever
swapped fields out, and the action handlers all paid for the
fiction with defensive guards like:

    if (!ctx.sendGroupMessage) {
      return failedResponse(RETCODE.ACTION_FAILED, 'send_group_msg is not implemented');
    }

— 80 such guards total across the action files (78 in the 3-line
form, 1 single-line, 1 \`if (!(ctx.a && ctx.b))\` compound). None of
them could ever fire.

This commit deletes the dead optionality. Two mechanical changes:

1. api-handler.ts: 81 \`name?: ...\` -> \`name: ...\` in ApiActionContext.
   The MessageSendResult optionals (meta?, echoEvent?) are unrelated
   and stay as-is. After: 85 required fields, 0 optionals.

2. actions/*.ts: drop the 80 guard blocks. Net -129 lines across
   extended, group-admin, group-file, group-info, friend, message,
   request. info.ts had none to begin with.

What this buys:

- The type system now enforces the wiring contract. If
  buildApiContext forgets to wire a field, tsc fails at the call
  site — the bug we were ostensibly catching at runtime in 80 places
  is now caught at compile time in 0 places, for free.
- Action handler bodies shrink visibly (avg ~3 lines per handler).
  extended.ts goes 1021 -> 935.
- AI / human readers no longer skim past dead code.

Caught one TS2774 ("This condition will always return true since
this function is always defined") on a compound guard in
extended.ts:186 that the regex missed; removed it manually. That
diagnostic is the type system actually doing its job — exactly the
point of the change.

244 tests pass (was 244). Same pre-existing macOS-arm64 websocket
addon failure, unrelated.
2026-05-12 17:09:56 +08:00
DrSmoothl e91a506bf5 feat(onebot): implement forward_{group,friend}_single_msg via md5 fast-upload
Captures protocol-level media fingerprints (md5/sha1/dims/format) on the
receive side and persists them alongside existing MediaStore entries, so a
forward can re-send the original message via QQ's md5 fast-upload path
without re-downloading the source CDN bytes. Avoids the stale-rkey trap
where the cached imageUrl 404s a few hours after receipt.

- MessageElement: add md5Hex / sha1Hex / pic|video|voiceFormat /
  noByteFallback optional fields.
- MediaStore: extend CachedImage / CachedRecord with fingerprints, add
  CachedVideo + rememberVideo / findVideo / updateVideoUrl. Per-row growth
  ~80-90 bytes; LRU cap stays at 4096 per type.
- msg-push-handler: extract fingerprints from NTV2 image/record/video and
  legacy NotOnlineImage/CustomFace/Ptt paths.
- event-converter: invoke mediaSegmentSink for video too.
- highway image/ptt/video upload: add fast-only branch that skips
  loadBinarySource/encodeSilk/stageVideoSource when noByteFallback is set,
  and fails fast if the server still returns uKey. Video forward uses the
  100-byte FALLBACK_THUMB as its subFile (original thumb not preserved in
  onebot semantics).
- message-actions: add forwardSingleMessage which looks up the cached
  event, enriches each media element with cached fingerprints, and
  dispatches via the existing sendGroup/sendPrivateMessage path. Files
  reject explicitly (separate upload protocol, out of scope).
- extended actions: wire forward_friend_single_msg / forward_group_single_msg
  to the new context method, replacing the not-implemented stubs.
2026-05-12 16:22:16 +08:00
H3CoF6 df5e3a26ac implement some onebot actions (#26)
* feat: implement more group admin action (kick members and set search and set add type)

* feat: implement some user extend func (set group mark \\ get custom emoji)

* feat: implement get send emoji his
2026-05-11 16:00:25 +08:00
H3CoF6 6f6ce1144b 补全一些onebot action实现 2 (#24)
* feat: implement get profile like

* feat: implement get at all remain

* feat: implement get undirectional friends

* feat: implement set self long nick

* feat: implement set input status

* feat: implement EN 2 ZH

* feat: implement get mini app ark

* feat: implement click inline button

* feat: implement set and send group sign

* feat: implement set qq avatar

* feat: group notice with pic and delete notice implement

* fix(group-notice): POST api and fix new bkn logic
2026-05-10 10:14:41 +08:00
手瓜一十雪 1565749105 Add MediaCache and media segment sink
Introduce an in-memory MediaCache to index recently seen image and record segments and wire a MediaSegmentSink into EventConverter to populate it. OneBotInstance now constructs MediaCache and registers a sink to remember image/record metadata; instance-context exposes get_image/get_record lookup handlers that consult the cache (and re-resolve record URLs via bridge OIDB when needed). ApiHandler actions get_image/get_record now accept file_id fallback and use the new context lookups. Removed the old findMediaInStore stub and added comprehensive tests for the cache and sink behavior.
2026-05-09 15:33:13 +08:00
H3CoF6 c8dd520d65 feat: implement get cookies and CSRF and credentials 2026-05-09 05:17:18 +08:00
H3CoF6 8b313fe088 feat: implement set qq profile 2026-05-09 05:08:03 +08:00
H3CoF6 049ef2960c feat: implement set online status 2026-05-09 04:57:00 +08:00
H3CoF6 a0d584375a feat: implement get group notice 2026-05-09 04:24:03 +08:00
H3CoF6 c862a157db feat: implement send group notice 2026-05-09 03:44:08 +08:00
H3CoF6 3791addb43 feat: implement get all essence msg 2026-05-08 20:41:47 +08:00
H3CoF6 7e2ba60073 feat: implement default mark msg as read and add get clientkey onebot api 2026-05-08 16:42:19 +08:00
H3CoF6 4a51e3d686 feat: 引入web方法,实现group honor 2026-05-08 01:56:23 +08:00
H3CoF6 0d84e3b99e feat: implemented mark msg as read 2026-05-07 05:49:13 +08:00
手瓜一十雪 39f1672b29 Migrate project to pnpm monorepo
Restructure the repository into a pnpm workspace under packages/ (core, webui, runtime). Move source files for core and webui into packages/*, add package manifests for @snowluma/core and @snowluma/runtime, and remove the old launcher package.json. Update root package.json to be a monorepo controller (scripts delegate to pnpm filters, set packageManager and Node engine). Configure build outputs to emit into the repo-root dist/ (vite config changes) so the existing release pipeline continues to work. Add .npmrc with mirrors, expand .gitignore for monorepo layout, add tsconfig base and package-level tsconfigs, and add vitest config for the core package. Adjust injector native search paths and update tests import paths to the new package layout. Small CI/workflow comment added to clarify build behavior and README updated with monorepo structure and common commands.
2026-05-03 14:02:29 +08:00