From 342148001014aa9cd815b0a4dc47ce97da66ef20 Mon Sep 17 00:00:00 2001 From: crazywhalecc Date: Sat, 11 Feb 2023 21:25:41 +0800 Subject: [PATCH] update docs --- docs/components/bot/bot-context.md | 8 ++++++-- docs/components/common/global-defines.md | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/components/bot/bot-context.md b/docs/components/bot/bot-context.md index 352c75f4..259cfc56 100644 --- a/docs/components/bot/bot-context.md +++ b/docs/components/bot/bot-context.md @@ -170,7 +170,7 @@ if ($response instanceof \ActionResponse) { - `ZM_PROMPT_TIMEOUT_QUOTE_SELF`:在询问参数超时时,如果 `$timeout_prompt` 和 `$prompt` 均不为空,则在发送超时提示语时引用自己发送的 `$prompt` 提示语。 - `ZM_PROMPT_TIMEOUT_QUOTE_USER`:在询问参数超时时,如果超时的消息不为空则引用用户最开始触发该注解的消息。 - `ZM_PROMPT_RETURN_STRING`:在获取到询问回复时,该函数返回消息的字符串格式。 -- `ZM_PROMPT_RETURN_SEGMENT`:在获取到询问回复时,该函数返回消息的消息段格式。 +- `ZM_PROMPT_RETURN_ARRAY`:在获取到询问回复时,该函数返回消息的消息段格式(默认)。 - `ZM_PROMPT_RETURN_EVENT`:在获取到询问回复时,该函数返回消息对应的 OneBotEvent 对象格式。 示例: @@ -190,7 +190,7 @@ public function testSegment(\BotContext $ctx) public function testString(\BotContext $ctx) { // 等待用户回复一条消息 - $reply = $ctx->prompt('请回复一条消息', 600, '你超时了', ZM_PROMPT_RETURN_STRING); + $reply = $ctx->promptString('请回复一条消息', 600, '你超时了'); // 如果用户回复了消息,那么 reply 将是一个字符串 // 如果用户没有回复消息,超时了,那下方的代码不会被执行,此处的事件流程将强制中断 $ctx->reply('你回复了:' . $reply); @@ -216,6 +216,10 @@ public function testString(\BotContext $ctx) {type:4,quote:'请再回复一条消息',content:'你又超时了'}, ]" /> +## promptString() - 等待一条消息回复并以字符串格式返回 + +该方法参数完全等同 `prompt()`,只是在返回的值方面,此方法会返回 string 类型,等同于 `$option` 参数设置了 `ZM_PROMPT_RETURN_STRING` 参数。 + ## hasReplied() - 检查是否已回复 `hasReplied()` 方法用处是检查当前事件是否已经回复过消息,如果已经回复过消息(即调用过 `reply()`),那么这里将返回 `true`,否则返回 `false`。 diff --git a/docs/components/common/global-defines.md b/docs/components/common/global-defines.md index de36e17e..64e6a78f 100644 --- a/docs/components/common/global-defines.md +++ b/docs/components/common/global-defines.md @@ -376,3 +376,9 @@ public function testRoute(HttpRequestEvent $event) 获取一个 KV 库实例。 有关 KV 库的使用,见 [组件 - KV 缓存](/components/store/cache)。 + +### zm_http_response() + +快速生成一个符合 PSR-7 的 HTTP Response 对象。 + +有关参数,等同于 HttpFactory 对象,详见 HttpFactory 文档(TODO)。