OneBot-api icon

OneBot-api

Consume OneBot API

Overview

This node interacts with the OneBot API to manage member relationships, specifically supporting an operation to randomly delete friends from a user's friend list. It allows users to specify a maximum number of friends to delete randomly and optionally exclude certain friends using a whitelist.

Common scenarios:

  • Cleaning up a large friend list by removing a random subset of friends.
  • Automating friend management while protecting important contacts via a whitelist.
  • Periodically pruning inactive or unwanted friends without manual selection.

Practical example:
A user wants to reduce their friend list size by randomly deleting up to 5 friends at once but wants to ensure that close friends are never deleted. They enable the whitelist feature and select those close friends to exclude from deletion.


Properties

Name Meaning
最大删除数量 (max_friends_to_delete) Sets the maximum number of friends to delete randomly. The actual number deleted is a random value between 1 and this number.
使用白名单 (use_whitelist_random) Whether to use a whitelist to exclude certain friends from being randomly deleted.
好友 Names or IDs (whitelist_friends_random) List of friends (by name or ID) to exclude from random deletion when whitelist is enabled. Can be selected from the friend list or specified via expression.

Output

The node outputs JSON data representing the result of the random deletion operation. This typically includes success status and details about which friends were deleted.

If any error occurs during execution, the output JSON will contain an error field with the error message and a success field set to false.

No binary data output is involved in this operation.


Dependencies

  • Requires connection to the OneBot API via an API key credential configured in n8n.
  • Uses OneBot API endpoints to fetch friend lists and perform friend deletion actions.
  • The node depends on helper methods to load friend lists dynamically for whitelist selection.

Troubleshooting

  • Common issues:

    • Failure to fetch friend list due to invalid or missing API credentials.
    • Attempting to delete more friends than exist in the friend list.
    • Errors if the whitelist contains invalid or non-existent friend IDs.
  • Error messages:

    • "Failed to get login info": Indicates inability to authenticate with the OneBot API. Check API credentials.
    • "Failed to get friend list": Could mean the API endpoint is unreachable or the account has no friends.
    • "Unknown resource type": Occurs if an unsupported resource is selected; ensure "成员关系" (member) resource is chosen.
    • General execution errors include descriptive messages; review logs for details.
  • Resolutions:

    • Verify API credentials and connectivity.
    • Ensure whitelist entries are valid friend identifiers.
    • Limit the maximum deletion count to a reasonable number within the current friend list size.

Links and References

Discussion