# Zhamao Framework: OneBot12Adapter类 参考

OneBot12Adapter类 参考
类 OneBot12Adapter 继承关系图:
[图例]
OneBot12Adapter 的协作图:
[图例]

## Public 成员函数

| __construct (string $submodule='', ?AnnotationParser $parser=null)
| parseBotCommand (BotCommand $command, ?array $same_method_annotations=null)
| parseCommandArgument ()
| handleBotCommand (BotEvent $event, BotContext $ctx)
| handleUnknownWSReverseInput (WebSocketOpenEvent $event)
| handleWSReverseOpen (WebSocketOpenEvent $event)
| handleWSReverseMessage (WebSocketMessageEvent $event)
Public 成员函数 继承自 ZMPlugin
| __construct (string $dir)
| getDir ()
| addBotEvent (BotEvent $event)
| addBotCommand (BotCommand $command)
| addEvent (string $event_name, callable $callback, int $level=20)
| addHttpRoute (Route $route)
| getBotEvents ()
| getBotCommands ()
| getEvents ()
| getRoutes ()

## 额外继承的成员函数

Protected 属性 继承自 ZMPlugin
string | $dir
array | $bot_events = []
array | $bot_commands = []
array | $events = []
array | $routes = []

## 构造及析构函数说明

## __construct()

__construct | ( | string | $submodule = `''`,
|  | ?AnnotationParser | $parser = `null`
| ) |  |

函数调用图:

## 成员函数说明

## handleBotCommand()

handleBotCommand | ( | BotEvent | $event,
|  | BotContext | $ctx
| ) |  |

调用 BotCommand 注解的方法

参数

  BotEvent | $event | BotEvent 事件
  BotContext | $ctx | 机器人环境上下文

函数调用图:

## handleUnknownWSReverseInput()

handleUnknownWSReverseInput | ( | WebSocketOpenEvent | $event | ) |

异常

  StopException |

函数调用图:

## handleWSReverseMessage()

handleWSReverseMessage | ( | WebSocketMessageEvent | $event | ) |

处理 WebSocket 消息

参数

  WebSocketMessageEvent | $event | 事件对象

异常

  OneBotException |

函数调用图:

## handleWSReverseOpen()

handleWSReverseOpen | ( | WebSocketOpenEvent | $event | ) |

接入和认证反向 WS 的连接

异常

  StopException |

函数调用图:

## parseBotCommand()

parseBotCommand | ( | BotCommand | $command,
|  | ?array | $same_method_annotations = `null`
| ) |  |

将 BotCommand 假设含有 CommandArgument 的话，就注册到参数列表中

参数

  BotCommand | $command | 命令对象
  null | array | $same_method_annotations | 同一个方法的所有注解

函数调用图:

## parseCommandArgument()

parseCommandArgument | ( |  | ) |

忽略解析记录 CommandArgument 注解

该类的文档由以下文件生成:

- src/ZM/Plugin/OneBot12Adapter.php