Skip to content

feat(imbot/feishu): complete platform support, clean up dead surface#1109

Open
0x0079 wants to merge 1 commit into
mainfrom
claude/fervent-cori-YOHZE
Open

feat(imbot/feishu): complete platform support, clean up dead surface#1109
0x0079 wants to merge 1 commit into
mainfrom
claude/fervent-cori-YOHZE

Conversation

@0x0079

@0x0079 0x0079 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Brings the Feishu/Lark platform to parity with Telegram for the channel features the bot uses, and trims a large amount of dead stub code. Scope is intentionally limited to imbot/ plus two tiny call-site updates that follow from the cleanup; the internal/remote_control wiring that consumes these capabilities is a follow-up PR stacked on this one.

Capabilities

  • Receive card button clicks via OnP2CardActionTrigger and emit them as core.Message callbacks (is_callback / callback_data / message_id) so the existing Telegram-style router handles Feishu unchanged.
  • No-op reaction handlers for OnP2MessageReaction{Created,Deleted}V1 so subscribed reaction events don't log not found handler.
  • Send pre-rendered cards: sendText honors opts.Metadata["card_json"] (sendRawCard); inline keyboards on replyMarkup still render via buildInteractiveCard.
  • EditMessage now patches the message to a markdown card via Im.Message.Patch (also drops any inline keyboard in one call).
  • DeleteMessage now recalls via Im.Message.Delete.
  • Outbound media: sendMedia uploads images (Im.Image.Create, image_type=message) and files (Im.File.Create, file_type derived from extension), then sends as the matching message type. Sources accept local paths (file://) and http(s) URLs.
  • Inbound media: convertLarkMessageToCore extracts image/file/audio/media payloads into a core.MediaContent whose attachment carries a feishu://<fileKey> marker plus message id / file key / resource type in Raw. FeishuBot grows DownloadMessageResource (Im.MessageResource.Get).

Correctness

  • Rewrite getReceiveIdType to follow Feishu prefix conventions: ou_ → open_id, on_ → union_id, oc_ → chat_id, "@" → email, else user_id. The previous implementation sliced 4 chars (so 3-char prefixes never matched) and mapped oc_ to open_id, which produced the open_id cross app (99992361) failure on every chat reply.
  • convertLarkMessageToCore uses chat_id (oc_…) uniformly for the reply target on both direct and group messages, matching the card-callback reply target and keeping the per-chat conversation key stable.
  • Add messageEditing + callbackQueries to PlatformFeishu / PlatformLark capabilities so callers can feature-test for in-place edits.

Cleanup

  • Rename bot_sdk.gofeishu.go to match other platforms' naming.
  • Delete webhook stubs (HandleWebhook / GetWebhookURL / VerifyWebhook), placeholder SetCardHandler / HandleCardAction, and the manual-only SetQuickActions / GetQuickActions / convertToQuickActionsFormat; drop them from the FeishuBot interface and from internal/{remote_control,command} call sites.
  • Delete the unused adapter.go, the webhook event types in types.go, the empty feishu_test.go stub, and the lark.Bot webhook overrides.

Tests

  • card_action_test.go covers handleCardActionTrigger emission, getReceiveIdType mapping, mimeFromFileName, feishuFileType, openMediaReader (local file), and buildLarkContent media extraction.
  • go build ./... and go test ./imbot/... ./internal/remote_control/... ./remote/... both pass.

Docs

Follow-up

A stacked PR on claude/fervent-cori-YOHZE-remote wires these capabilities through internal/remote_control (platform-aware keyboard sends and action menu, capability-aware in-place edits, inbound-media plumbing, multi-platform /join).

https://claude.ai/code/session_014ThTKs7Ft4zptY2pQJDpjZ


Generated by Claude Code

Brings the Feishu/Lark platform to parity with Telegram for the channel
features the bot uses, and trims a large amount of dead stub code.

Capabilities
- Receive interactive-card button clicks via OnP2CardActionTrigger and
  emit them as core.Message callbacks (is_callback/callback_data/
  message_id) so the existing Telegram-style router handles Feishu
  unchanged.
- No-op reaction handlers for OnP2MessageReaction{Created,Deleted}V1 so
  subscribed reaction events don't log "not found handler".
- sendText honors a pre-rendered card_json on opts.Metadata (sendRawCard);
  inline keyboards on opts.Metadata["replyMarkup"] still render via
  buildInteractiveCard.
- EditMessage now patches the message to a markdown card via
  Im.Message.Patch (also drops any inline keyboard in one call).
- DeleteMessage now recalls via Im.Message.Delete.
- Outbound media: sendMedia uploads images (Im.Image.Create, image_type
  message) and files (Im.File.Create, file_type derived from extension),
  then sends as the matching message type. Sources accept local paths
  (file://) and http(s) URLs.
- Inbound media: convertLarkMessageToCore extracts image/file/audio/media
  payloads into a core.MediaContent whose attachment carries a
  feishu://<fileKey> marker plus message id / file key / resource type in
  Raw. FeishuBot grows DownloadMessageResource (Im.MessageResource.Get).

Correctness
- Rewrite getReceiveIdType to follow Feishu prefix conventions: ou_ →
  open_id, on_ → union_id, oc_ → chat_id, "@" → email, else user_id. The
  previous implementation used a 4-char slice that never matched 3-char
  prefixes and mapped oc_ to open_id, which produced the "open_id cross
  app" (99992361) failure on every chat reply.
- convertLarkMessageToCore now uses chat_id (oc_…) uniformly for the
  reply target on both direct and group messages, matching the callback
  reply target and the per-chat conversation key.
- Add messageEditing + callbackQueries to PlatformFeishu/PlatformLark
  capabilities so callers can feature-test for in-place edits.

Cleanup
- Rename bot_sdk.go → feishu.go to match other platforms.
- Delete webhook stubs (HandleWebhook/GetWebhookURL/VerifyWebhook), the
  placeholder SetCardHandler/HandleCardAction, and the manual-only
  SetQuickActions/GetQuickActions/convertToQuickActionsFormat; drop them
  from the FeishuBot interface and from internal/{remote_control,command}
  call sites. Delete the unused adapter.go + webhook event types in
  types.go and the empty feishu_test.go stub. Also drop the lark.Bot
  webhook overrides.

Tests
- Add card_action_test.go covering handleCardActionTrigger emission,
  getReceiveIdType mapping, mimeFromFileName, feishuFileType,
  openMediaReader (local file), and buildLarkContent media extraction.

Docs
- New imbot/doc/feishu_channel.md describing the channel handlers,
  callback shape, receive_id_type rules, and how tingly-box wires this.

https://claude.ai/code/session_014ThTKs7Ft4zptY2pQJDpjZ
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