简体中文 English 繁體中文 日本語 Русский
本文为静态镜像,内容以交互版为准 在交互式文档中心打开 →

ErisPulse Adapter Standardized Return Specification

1. Description

Why does this specification exist?

To ensure the uniformity of API response formats across different platforms and maintain compatibility with OneBot12, the ErisPulse adapter adopts the message sending return structure standard defined by OneBot12.

However, the ErisPulse protocol has some special definitions:

2. Basic Return Structure

All action responses must include the following basic fields:

Field Name Data Type Required Description
status string Yes Execution status, must be "ok" or "failed"
retcode int64 Yes Return code, follows OneBot12 return code rules
data any Yes Response data, contains the request result on success, null on failure
message_id string Yes Message ID, used to identify the message, empty string if not available
message string Yes Error message, empty string on success
{platform_name}_raw any No Raw response data

Optional fields:

Field Name Data Type Required Description
echo string No Returned verbatim when the request contains an echo field

3. Full Field Specification

3.1 Common Fields

Successful Response Example

{
    "status": "ok",
    "retcode": 0,
    "data": {
        "message_id": "1234",
        "time": 1632847927.599013
    },
    "message_id": "1234",
    "message": "",
    "echo": "1234",
    "telegram_raw": {...}
}

Failed Response Example

{
    "status": "failed",
    "retcode": 10003,
    "data": null,
    "message_id": "",
    "message": "Missing required parameter: user_id",
    "echo": "1234",
    "telegram_raw": {...}
}

3.2 Return Code Specification

0 Success (OK)

1xxxx Request Error

Error Code Error Name Description
10001 Bad Request Invalid action request
10002 Unsupported Action Unsupported action request
10003 Bad Param Invalid action request parameter
10004 Unsupported Param Unsupported action request parameter
10005 Unsupported Segment Unsupported message segment type
10006 Bad Segment Data Invalid message segment parameter
10007 Unsupported Segment Data Unsupported message segment parameter
10101 Who Am I Robot account not specified
10102 Unknown Self Unknown robot account

2xxxx Handler Error

Error Code Error Name Description
20001 Bad Handler Action handler implementation error
20002 Internal Handler Error Exception thrown during action handler execution

3xxxx Execution Error

Error Code Range Error Type Description
31xxx Database Error Database error
32xxx Filesystem Error Filesystem error
33xxx Network Error Network error
34xxx Platform Error Robot platform error
35xxx Logic Error Action logic error
36xxx I Am Tired Implementation decided to strike

Reserved Error Ranges

4. Implementation Requirements

  1. All responses must contain the fields: status, retcode, data, and message.
  2. When the request contains a non-empty echo field, the response must include an echo field with the same value.
  3. Return codes must strictly follow the OneBot12 specification.
  4. Error messages (message) should be human-readable descriptions.

5. Extension Specifications

ErisPulse extends the OneBot12 standard return structure as follows:

5.1 message_id Required Field

In the OneBot12 standard, message_id is located within the data object and is not mandatory. ErisPulse elevates it to a required top-level field:

5.2 {platform}_raw Raw Response Field

The return value should include the {platform}_raw field, which stores a complete copy of the raw response data from the platform:

{
    "status": "ok",
    "retcode": 0,
    "data": {"message_id": "1234", "time": 1632847927},
    "message_id": "1234",
    "message": "",
    "telegram_raw": {
        "ok": true,
        "result": {"message_id": 1234, "date": 1632847927, ...}
    }
}

Requirements:

5.3 Framework Extension Return Codes (Custom Low Three Digits in the 34xxx Platform Error Segment)

The OneBot12 specification allows implementations to define custom low three digits of 3xxxx. The 34xxx segment semantics are Platform Error (robot platform error, such as failures caused by platform restrictions). The 34xxx segment is used hierarchically according to responsibilities:

Low Three Digits Segment Ownership Purpose
340xx Adapter Implementation Request operation group (Request Not Found / Already Handled / Not Supported / Permission Denied, see request-action-spec §7)
341xx~345xx Adapter Implementation Platform-side permission / risk control / account restriction errors (implement custom low three digits, original error placed in {platform}_raw)
346xx ErisPulse Framework (reserved) Framework-level interception and general failures; adapters/modules should not occupy these codes
347xx~349xx Adapter Implementation Other platform execution errors

ErisPulse framework currently uses the 346xx codes:

Error Code Error Name Description
34600 SDK Failure General failure in the framework (make_error() default return code)
34601 Action Denied Outbound action denied by scope (scope.actions), call not initiated, directly return this response

Responsibility distinction: 34601 is framework-level interception before the call (the module has no right to initiate the action); 34004 / 34xxx platform codes are actions already sent but rejected by the platform (e.g., Bot lacks permission, is restricted). When modules check for permission issues, they should check both types: first check 34601 (the module's own scope is disabled), then check 34xxx (platform-side restrictions).

The return structure is the standard failure response as defined in §2:

{
    "status": "failed",
    "retcode": 34601,
    "data": null,
    "message_id": "",
    "message": "action 'send' denied by scope.actions"
}

5.4 Adapter Implementation Checklist

6. Notes