refactor(gateway): migrate Weixin adapter to bundled plugin - #41101
Closed
kshitijk4poor wants to merge 2 commits into
Closed
refactor(gateway): migrate Weixin adapter to bundled plugin#41101kshitijk4poor wants to merge 2 commits into
kshitijk4poor wants to merge 2 commits into
Conversation
Move the Weixin (微信 / WeChat) adapter from gateway/platforms/weixin.py into
a self-contained bundled plugin under plugins/platforms/weixin/, following the
Discord/Mattermost/Home Assistant/Yuanbao/Signal/QQBot migration shape.
register() supplies the hooks that previously lived as per-platform wiring
in core:
- adapter_factory -> the elif in gateway/run.py::_create_adapter()
- check_fn -> check_weixin_requirements guard there
- is_connected -> the Platform.WEIXIN branch in _is_platform_connected
+ the _PLATFORM_CONNECTED_CHECKERS lambda
- setup_fn -> _setup_weixin (iLink QR login + DM/group policy)
+ its _PLATFORMS entry + _builtin_setup_fn mapping
- standalone_sender_fn -> _send_weixin in tools/send_message_tool.py
- cron_deliver_env_var -> WEIXIN_HOME_CHANNEL
The one-shot send_weixin_direct helper stays in the adapter; _standalone_send
wraps it for cron/send_message delivery. Weixin is HTTP (iLink API), so this
works out-of-process.
Connection-check reorder: weixin requires BOTH account_id and token, and it
sets config.token during env-enablement, so the generic token-only branch in
_is_platform_connected would wrongly pass it without account_id. Rather than
keep a per-platform special-case, the registry is_connected hook is now
consulted BEFORE the generic token branch — a platform's own check is the
authoritative signal. Verified no cross-platform regression (full gateway
connection-check suite green).
Deliberately left generic in core: the Platform.WEIXIN enum literal, the
_apply_env_overrides WEIXIN_* env block, the WEIXIN_TOKEN entry in the
_token_env_names map, and the _is_user_authorized allowlist maps. Weixin has
no load_gateway_config YAML block, so no apply_yaml_config_fn.
Updated the connection-checker guard test to exclude bundled-plugin platforms;
repointed the bare-submodule test import to the plugin adapter module.
28 tasks
weixin is now a bundled plugin; its PlatformEntry already permits /update via allow_update_command (defaults True), honored by the registry fallback in _handle_update_command. The hardcoded Platform.WEIXIN entry in _UPDATE_ALLOWED_PLATFORMS is therefore redundant. Same cleanup as NousResearch#32525 did for Discord/Mattermost.
Collaborator
Author
|
Follow-up to #32525: now that the migrated-platform |
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.
What this does
Moves the Weixin (微信 / WeChat) adapter from
gateway/platforms/weixin.pyinto a self-contained bundled plugin under
plugins/platforms/weixin/,following the Discord / Mattermost / Home Assistant / Yuanbao / Signal / QQBot
migration shape.
How
register()supplies the hooks that were per-platform wiring in core:adapter_factory, check_fn, is_connected, setup_fn (iLink QR login + DM/group
policy), standalone_sender_fn, cron_deliver_env_var. The one-shot
send_weixin_directhelper stays in the adapter;_standalone_sendwraps itfor out-of-process cron / send_message delivery.
Connection-check reorder (the one non-mechanical bit)
Weixin requires BOTH
account_idand a token, and it setsconfig.tokenduring env-enablement — so the generic token-only branch in
_is_platform_connectedwould wrongly pass it without an account_id. Insteadof a per-platform special-case, the registry
is_connectedhook is nowconsulted BEFORE the generic token branch (a platform's own check is the
authoritative signal). Verified no cross-platform regression — full gateway
connection-check suite green, all platforms detect correctly.
Out of scope (stays generic, same as every other platform)
Platform.WEIXINenum literal, the_apply_env_overridesWEIXIN_* env block,the
WEIXIN_TOKENentry in_token_env_names, the_is_user_authorizedallowlist maps. No
load_gateway_configYAML block, so no apply_yaml_config_fn.Tests
Rename R089 (adapter). 254 focused tests pass. Updated the connection-checker
guard test to exclude bundled-plugin platforms; repointed the bare-submodule
test import. No new failures vs main (pre-existing matrix/telegram xdist flakes
excluded).