OneBot-api icon

OneBot-api

Consume OneBot API

Overview

This node interacts with the OneBot API to manage member relationships within groups, friends, bots, messages, and miscellaneous operations. Specifically for the "成员关系" (Member) resource and the "退出群聊" (Leave Group Chat) operation, it allows a user to leave a group chat or dismiss the group if they are the owner. This is useful in scenarios where a bot or user needs to programmatically exit a group or dissolve it entirely.

Practical examples:

  • A bot automatically leaves a group after completing a task.
  • The group owner dismisses the group when it is no longer needed.
  • Automating group management workflows by leaving or dismissing groups based on certain triggers.

Properties

Name Meaning
Group Name or ID Select the target group from a list of groups or specify its ID using an expression.
是否解散群 (is_dismiss) Boolean flag indicating whether to dismiss the group if the user is the owner (true/false).

Output

The node outputs JSON data representing the result of the leave or dismiss operation. The output typically includes success status and any error messages if the operation fails.

If the operation succeeds, the output JSON confirms the action was completed. If it fails, the output contains an error message describing the issue.

No binary data output is involved in this operation.

Dependencies

  • Requires connection to a OneBot API endpoint.
  • Requires an API key credential configured in n8n for authentication with the OneBot API.
  • The node uses helper methods to fetch group lists and verify permissions before performing the leave or dismiss action.

Troubleshooting

  • Common issues:

    • Failure to retrieve group list due to authentication errors or network issues.
    • Attempting to dismiss a group without being the owner will fail.
    • Specifying an invalid or non-existent group ID.
  • Error messages and resolutions:

    • "获取登录信息失败,无法获取管理的群聊" ("Failed to get login info, cannot get managed groups"): Check API credentials and connectivity.
    • "获取群列表失败" ("Failed to get group list"): Verify that the bot has permission to access group information.
    • Errors related to insufficient permissions when trying to dismiss a group: Ensure the user/bot is the group owner.
    • General API request failures: Confirm the OneBot API endpoint is reachable and the credentials are valid.

Links and References

Discussion