refactor(onebot): declare every action param the handler reads

Action handlers now only see fields from the param table. Extra client
keys are still ignored. Garbage values on declared numbers fail instead
of becoming zero.
This commit is contained in:
DrSmoothl committed 2026-08-30 00:56:01 +08:00
1 parent 117335166f
commit f6adadcd12
14 files changed
+952 -235

No files matched your search

+355 -34
View File
@@ -726,6 +726,24 @@
"type": "integer",
"minimum": 1
}
},
{
"name": "button_id",
"type": "string",
"required": true,
"schema": {
"type": "string",
"minLength": 1
}
},
{
"name": "callback_data",
"type": "string",
"required": false,
"schema": {
"type": "string"
},
"default": ""
}
],
"invariants": [],
@@ -745,12 +763,21 @@
"msg_seq": {
"type": "integer",
"minimum": 1
},
"button_id": {
"type": "string",
"minLength": 1
},
"callback_data": {
"type": "string",
"default": ""
}
},
"required": [
"group_id",
"bot_appid",
"msg_seq"
"msg_seq",
"button_id"
],
"additionalProperties": true
},
@@ -1577,6 +1604,12 @@
"type": "string"
},
"default": ""
},
{
"name": "headers",
"type": "raw",
"required": false,
"schema": {}
}
],
"invariants": [],
@@ -1594,7 +1627,8 @@
"name": {
"type": "string",
"default": ""
}
},
"headers": {}
},
"additionalProperties": true
},
@@ -2268,13 +2302,15 @@
"params": [
{
"name": "message_id",
"type": "string",
"required": false,
"type": "messageId",
"required": true,
"role": "message_id",
"schema": {
"type": "string"
},
"default": "",
"role": "message_id"
"type": "integer",
"not": {
"const": 0
}
}
}
],
"invariants": [],
@@ -2282,11 +2318,16 @@
"type": "object",
"properties": {
"message_id": {
"type": "string",
"default": "",
"type": "integer",
"not": {
"const": 0
},
"x-role": "message_id"
}
},
"required": [
"message_id"
],
"additionalProperties": true
},
"category": "扩展"
@@ -3661,6 +3702,14 @@
"schema": {
"type": "string"
}
},
{
"name": "message_id",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
}
],
"invariants": [],
@@ -3669,6 +3718,9 @@
"properties": {
"id": {
"type": "string"
},
"message_id": {
"type": "string"
}
},
"additionalProperties": true
@@ -4766,9 +4818,11 @@
},
{
"name": "type",
"type": "raw",
"type": "string",
"required": false,
"schema": {}
"schema": {
"type": "string"
}
}
],
"invariants": [],
@@ -4781,7 +4835,9 @@
"description": "群号",
"x-role": "group_id"
},
"type": {}
"type": {
"type": "string"
}
},
"required": [
"group_id"
@@ -6138,11 +6194,90 @@
"aliases": [],
"summary": "获取小程序卡片 ark",
"readOnly": true,
"params": [],
"params": [
{
"name": "type",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "title",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "desc",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "picUrl",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "pic_url",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "jumpUrl",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "jump_url",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
}
],
"invariants": [],
"inputSchema": {
"type": "object",
"properties": {},
"properties": {
"type": {
"type": "string"
},
"title": {
"type": "string"
},
"desc": {
"type": "string"
},
"picUrl": {
"type": "string"
},
"pic_url": {
"type": "string"
},
"jumpUrl": {
"type": "string"
},
"jump_url": {
"type": "string"
}
},
"additionalProperties": true
},
"category": "扩展"
@@ -8748,6 +8883,62 @@
"schema": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
{
"name": "message_type",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "group_id",
"type": "int",
"required": false,
"schema": {
"type": "integer",
"minimum": 0
}
},
{
"name": "user_id",
"type": "int",
"required": false,
"schema": {
"type": "integer",
"minimum": 0
}
},
{
"name": "source",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "summary",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "prompt",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "news",
"type": "raw",
"required": false,
"schema": {}
}
],
"invariants": [],
@@ -8759,7 +8950,28 @@
},
"message": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
"message_type": {
"type": "string"
},
"group_id": {
"type": "integer",
"minimum": 0
},
"user_id": {
"type": "integer",
"minimum": 0
},
"source": {
"type": "string"
},
"summary": {
"type": "string"
},
"prompt": {
"type": "string"
},
"news": {}
},
"additionalProperties": true
},
@@ -8917,6 +9129,36 @@
"schema": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
{
"name": "source",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "summary",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "prompt",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "news",
"type": "raw",
"required": false,
"schema": {}
}
],
"invariants": [],
@@ -8934,7 +9176,17 @@
},
"message": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
"source": {
"type": "string"
},
"summary": {
"type": "string"
},
"prompt": {
"type": "string"
},
"news": {}
},
"required": [
"group_id"
@@ -9280,6 +9532,36 @@
"schema": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
{
"name": "source",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "summary",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "prompt",
"type": "string",
"required": false,
"schema": {
"type": "string"
}
},
{
"name": "news",
"type": "raw",
"required": false,
"schema": {}
}
],
"invariants": [],
@@ -9296,7 +9578,17 @@
},
"message": {
"description": "OneBot message: string | segment[] | object. In segment arrays, text segments whose text field is exactly \"\" are compatibility placeholders and do not count as sendable segments; missing, null, and whitespace-only text remain subject to normal validation."
}
},
"source": {
"type": "string"
},
"summary": {
"type": "string"
},
"prompt": {
"type": "string"
},
"news": {}
},
"required": [
"user_id"
@@ -9983,15 +10275,19 @@
},
{
"name": "sub_type",
"type": "raw",
"type": "string",
"required": false,
"schema": {}
"schema": {
"type": "string"
}
},
{
"name": "type",
"type": "raw",
"type": "string",
"required": false,
"schema": {}
"schema": {
"type": "string"
}
},
{
"name": "approve",
@@ -10020,8 +10316,12 @@
"type": "string",
"minLength": 1
},
"sub_type": {},
"type": {},
"sub_type": {
"type": "string"
},
"type": {
"type": "string"
},
"approve": {
"type": "boolean",
"default": true
@@ -11692,23 +11992,31 @@
"params": [
{
"name": "longNick",
"type": "raw",
"type": "string",
"required": false,
"schema": {}
"schema": {
"type": "string"
}
},
{
"name": "long_nick",
"type": "raw",
"type": "string",
"required": false,
"schema": {}
"schema": {
"type": "string"
}
}
],
"invariants": [],
"inputSchema": {
"type": "object",
"properties": {
"longNick": {},
"long_nick": {}
"longNick": {
"type": "string"
},
"long_nick": {
"type": "string"
}
},
"additionalProperties": true
},
@@ -11933,17 +12241,30 @@
"params": [
{
"name": "words",
"type": "raw",
"required": false,
"schema": {}
"type": "string[]",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
"invariants": [],
"inputSchema": {
"type": "object",
"properties": {
"words": {}
"words": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"words"
],
"additionalProperties": true
},
"category": "扩展"