mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-21 07:35:34 +08:00
文档更新:部分内容调整补充、WebSocket 客户端接入 (#337)
* update docs * update docs * update docs
This commit is contained in:
@@ -11,47 +11,47 @@ GitHub 链接:https://github.com/zhamao-robot/zhamao-framework/blob/main/src/Z
|
||||
|
||||
在任何事件(或任何支持依赖注入的地方)中,你都可以使用以下依赖项:
|
||||
|
||||
- `Psr\Log\LoggerInterface`:日志记录器
|
||||
- `Psr\Container\ContainerInterface`:容器
|
||||
- `Psr\Log\LoggerInterface`:日志记录器(可使用类的别名 `LoggerInterface`)
|
||||
- `Psr\Container\ContainerInterface`:容器(可使用别名 `ContainerInterface`)
|
||||
- `DI\Container`:容器,区别在于可以使用 `set` 方法来动态设置依赖项,与 `container` 函数返回的实例相同
|
||||
- `ZM\Config\ZMConfig`:配置,与 `config` 函数返回的实例相同
|
||||
- `ZM\Config\ZMConfig`:配置,与 `config` 函数返回的实例相同(可使用别名 `ZMConfig`)
|
||||
- ...
|
||||
|
||||
## OneBot 事件
|
||||
|
||||
在 OneBot 事件(`@BotEvent`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\V12\Object\OneBotEvent`:当前事件的实例
|
||||
- `ZM\Context\BotContext`:当前事件的上下文,部分事件可能不可用(要求传入的事件存在 `platform` 字段)
|
||||
- `OneBot\V12\Object\OneBotEvent`:当前事件的实例(可使用别名 `OneBotEvent`)
|
||||
- `ZM\Context\BotContext`:当前事件的上下文,可使用别名 `BotContext`,部分事件可能不可用(要求传入的事件存在 `platform` 字段)
|
||||
|
||||
## OneBot 动作响应
|
||||
|
||||
在 OneBot 动作响应(`@BotActionResponse`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\V12\Object\ActionResponse`:当前动作响应的实例
|
||||
- `OneBot\V12\Object\ActionResponse`:当前动作响应的实例(可使用别名 `ActionResponse`)
|
||||
|
||||
## HTTP 请求事件(路由事件)
|
||||
|
||||
在 HTTP 请求事件(`@Route`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\Driver\Event\Http\HttpRequestEvent`:当前事件的实例
|
||||
- `Psr\Http\Message\ServerRequestInterface`:当前请求的实例
|
||||
- `OneBot\Driver\Event\Http\HttpRequestEvent`:当前事件的实例(可使用别名 `HttpRequestEvent`)
|
||||
- `Psr\Http\Message\ServerRequestInterface`:当前请求的实例(可使用别名 `ServerRequestInterface`)
|
||||
|
||||
## WebSocket 连接事件
|
||||
|
||||
在 WebSocket 连接事件(`@BindEvent(WebSocketOpenEvent::class)`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketOpenEvent`:当前事件的实例
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketOpenEvent`:当前事件的实例(可使用别名 `WebSocketOpenEvent`)
|
||||
|
||||
## WebSocket 消息事件
|
||||
|
||||
在 WebSocket 消息事件(`@BindEvent(WebSocketMessageEvent::class)`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketMessageEvent`:当前事件的实例
|
||||
- `Choir\WebSocket\FrameInterface`:当前消息(帧)的实例
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketMessageEvent`:当前事件的实例(可使用别名 `WebSocketMessageEvent`)
|
||||
- `Choir\WebSocket\FrameInterface`:当前消息(帧)的实例(可使用别名 `FrameInterface`)
|
||||
|
||||
## WebSocket 关闭事件
|
||||
|
||||
在 WebSocket 关闭事件(`@BindEvent(WebSocketCloseEvent::class)`)中,你可以使用以下依赖项:
|
||||
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketCloseEvent`:当前事件的实例
|
||||
- `OneBot\Driver\Event\WebSocket\WebSocketCloseEvent`:当前事件的实例(可使用别名 `WebSocketCloseEvent`)
|
||||
|
||||
Reference in New Issue
Block a user