Skip to content

feat: add subaccount admin command for superusers - #1288

Open
This-is-XiaoDeng wants to merge 4 commits into
mainfrom
feat/subaccount-admin-command
Open

feat: add subaccount admin command for superusers#1288
This-is-XiaoDeng wants to merge 4 commits into
mainfrom
feat/subaccount-admin-command

Conversation

@This-is-XiaoDeng

Copy link
Copy Markdown
Member

Summary

Adds an admin-only command subaccount (alias 子账号) to the larkuser plugin, restricted to superusers, for managing sub-account bindings.

Features

  • view (subaccount view <用户ID> / subaccount 状态 <用户ID>): Check the binding status of a specified user ID — shows whether it's a sub-account, a main account with sub-accounts, or has no bindings.
  • bind (subaccount bind <子账号ID> <主账号ID>): Bind one account as a sub-account of another. Requires confirmation via the prompt tool, showing both involved accounts' IDs and nicknames.
  • unbind (subaccount unbind <子账号ID>): Unbind a sub-account from its main account. Requires confirmation showing the sub-account and its main account details.
  • unbind --all (subaccount unbind <主账号ID> --all): Unbind all sub-accounts of a specified main account. Requires confirmation listing all sub-accounts.

Changes

src/plugins/nonebot_plugin_larkutils/subaccount.py

  • Added get_sub_accounts(main_account) -> list[str]: Query all sub-account IDs of a main account.
  • Added remove_main_account(user_id) -> None: Remove a sub-account's binding.
  • Added remove_all_sub_accounts(main_account) -> list[str]: Remove all sub-accounts of a main account, returning the removed IDs.

src/plugins/nonebot_plugin_larkutils/__init__.py

  • Exported the new helper functions.

src/plugins/nonebot_plugin_larkuser/matchers/subaccount_admin.py (new)

  • Superuser-only command handler with three subcommands.
  • Uses larkuser's existing prompt tool for confirmation flows.

src/plugins/nonebot_plugin_larkuser/__init__.py

  • Imports the new matcher.

Language files (src/lang/*/larkuser.yaml)

  • Added all subaccount_admin.* translation keys for zh_hans, en_us, and zh_tw.

Add an admin-only command 'subaccount' (alias '子账号') to the larkuser
plugin, restricted to superusers, for managing sub-account bindings:

- view: Check the binding status of a specified user ID
- bind: Bind one account as a sub-account of another (with confirmation)
- unbind: Unbind a sub-account from its parent (with confirmation)
- unbind --all: Unbind all sub-accounts of a specified main account (with confirmation)

Bind/unbind operations use larkuser's prompt tool to require explicit
confirmation, listing the IDs and nicknames of involved accounts.

Also adds helper functions to larkutils/subaccount.py:
- get_sub_accounts(main_account) -> list[str]
- remove_main_account(user_id) -> None
- remove_all_sub_accounts(main_account) -> list[str]

Closes # (pending PR)
@github-actions
github-actions Bot requested review from montmorill and xxtg666 July 24, 2026 14:14
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 39 complexity

Metric Results
Complexity 39

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This-is-XiaoDeng and others added 2 commits July 24, 2026 22:24
Add help metadata for the new subaccount admin command to larkhelp
system, categorized as 'superuser' with usage instructions in all
three languages (zh_hans, en_us, zh_tw).
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