feat(imbot/feishu): complete platform support, clean up dead surface#1109
Open
0x0079 wants to merge 1 commit into
Open
feat(imbot/feishu): complete platform support, clean up dead surface#11090x0079 wants to merge 1 commit into
0x0079 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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; theinternal/remote_controlwiring that consumes these capabilities is a follow-up PR stacked on this one.Capabilities
OnP2CardActionTriggerand emit them ascore.Messagecallbacks (is_callback/callback_data/message_id) so the existing Telegram-style router handles Feishu unchanged.OnP2MessageReaction{Created,Deleted}V1so subscribed reaction events don't lognot found handler.sendTexthonorsopts.Metadata["card_json"](sendRawCard); inline keyboards onreplyMarkupstill render viabuildInteractiveCard.EditMessagenow patches the message to a markdown card viaIm.Message.Patch(also drops any inline keyboard in one call).DeleteMessagenow recalls viaIm.Message.Delete.sendMediauploads images (Im.Image.Create,image_type=message) and files (Im.File.Create,file_typederived from extension), then sends as the matching message type. Sources accept local paths (file://) andhttp(s)URLs.convertLarkMessageToCoreextracts image/file/audio/media payloads into acore.MediaContentwhose attachment carries afeishu://<fileKey>marker plus message id / file key / resource type inRaw.FeishuBotgrowsDownloadMessageResource(Im.MessageResource.Get).Correctness
getReceiveIdTypeto follow Feishu prefix conventions:ou_ → open_id,on_ → union_id,oc_ → chat_id,"@" → email, elseuser_id. The previous implementation sliced 4 chars (so 3-char prefixes never matched) and mappedoc_toopen_id, which produced theopen_id cross app(99992361) failure on every chat reply.convertLarkMessageToCoreuseschat_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.messageEditing+callbackQueriestoPlatformFeishu/PlatformLarkcapabilities so callers can feature-test for in-place edits.Cleanup
bot_sdk.go→feishu.goto match other platforms' naming.HandleWebhook/GetWebhookURL/VerifyWebhook), placeholderSetCardHandler/HandleCardAction, and the manual-onlySetQuickActions/GetQuickActions/convertToQuickActionsFormat; drop them from theFeishuBotinterface and frominternal/{remote_control,command}call sites.adapter.go, the webhook event types intypes.go, the emptyfeishu_test.gostub, and thelark.Botwebhook overrides.Tests
card_action_test.gocovershandleCardActionTriggeremission,getReceiveIdTypemapping,mimeFromFileName,feishuFileType,openMediaReader(local file), andbuildLarkContentmedia extraction.go build ./...andgo test ./imbot/... ./internal/remote_control/... ./remote/...both pass.Docs
imbot/doc/feishu_channel.mddescribing the channel handlers, callback shape,receive_id_typerules, and howtingly-boxwires this. Reference: https://github.com/larksuite/oapi-sdk-go/blob/v3_main/doc/channel.mdFollow-up
A stacked PR on
claude/fervent-cori-YOHZE-remotewires these capabilities throughinternal/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