Skip to content

Commit

Permalink
update to 2.6.4 (build 432)
Browse files Browse the repository at this point in the history
  • Loading branch information
crazywhalecc committed Dec 25, 2021
1 parent 3ed1cb6 commit 74050c4
Show file tree
Hide file tree
Showing 10 changed files with 215 additions and 53 deletions.
15 changes: 15 additions & 0 deletions docs/component/bot/robot-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,21 @@ vardump($result["retcode"]); //如果成功撤回,输出 int(0)

响应数据:无

### getExtendedAPI()

用来调用 OneBot 标准之外扩展出来的自定义 API。与下方 `callExtendedAPI` 不同的是,为了方便用户使用,炸毛框架内置了热门使用并且相对稳定的机器人客户端的专有 API。

目前内置了 `go-cqhttp` 频道相关的扩充 API。

使用示例:`getExtendedAPI('go-cqhttp')->getGuildList()`
使用示例2:`getExtendedAPI()->sendGuildChannelMsg($guild_id, $channel_id, '频道的消息')`

唯一一个参数做保留,用于选择不同客户端,目前仅支持 `go-cqhttp`,所以缺省也默认为 `go-cqhttp`

!!! warning "注意"

由于不同版本的扩展 API 变化可能会很大,改动较多,炸毛框架不会将对应扩展方法写入文档,具体调用情况可根据 IDE 自动补全中的文档或对应类的注释查看。

### callExtendedAPI() (扩充 API)

用来调用 OneBot 标准之外扩展出来的自定义 API。
Expand Down
1 change: 1 addition & 0 deletions docs/guide/errcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@
| E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 |
| E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()`|
| E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 |
| E00071 | 框架找不到对应类型的 API 调用类 | 检查 `getExtendedAPI($name)` 传入的 `$name` 是否正确 |
| E99999 | 未知错误 | |

6 changes: 6 additions & 0 deletions docs/update/build-update.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

同时此处将只使用 build 版本号进行区分。

## build 432 (2021-12-25)

- 新增 GoCqhttpAPI 包,用于支持额外的 OneBot Action(API)
- 修复 MySQL 查询器中 `fetchOne()` 方法无法正确返回值的 Bug
- 修复 Swoole Hook 因配置不当无法正确使用的 Bug

## build 431 (2021-12-22)

- 修复 Issue #50
Expand Down
12 changes: 11 additions & 1 deletion docs/update/v2.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# 更新日志(v2 版本)

# v2.6.3 (build 430)
## v2.6.4(build 432)

> 更新时间:2021.12.25
- 新增 GoCqhttpAPI 包,用于支持额外的 OneBot Action(API)
- 修复 MySQL 查询器中 `fetchOne()` 方法无法正确返回值的 Bug
- 修复 Swoole Hook 因配置不当无法正确使用的 Bug
- 修复 Issue #50
- 新增 PhpStorm IDE 直接运行框架的脚本

## v2.6.3 (build 430)

> 更新时间:2021.12.8
Expand Down
6 changes: 6 additions & 0 deletions src/ZM/API/CQAPI.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ private function processHttpAPI($connection, $reply, $function = null): bool {
return false;
}

public function getActionName($suffix, string $method) {
$postfix = ($suffix == OneBotV11::API_ASYNC ? '_async' : ($suffix == OneBotV11::API_RATE_LIMITED ? '_rate_limited' : ''));
$func_name = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $method));
return $func_name . $postfix;
}

public function __call($name, $arguments) {
return false;
}
Expand Down
111 changes: 111 additions & 0 deletions src/ZM/API/GoCqhttpAPIV11.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

namespace ZM\API;

class GoCqhttpAPIV11
{
const SUPPORT_VERSION = '1.0.0-beta8';

use CQAPI;

private $connection;
private $callback;
private $prefix;

public function __construct($connection, $callback, $prefix)
{
$this->connection = $connection;
$this->callback = $callback;
$this->prefix = $prefix;
}

/**
* 获取频道系统内BOT的资料
* 响应字段:nickname, tiny_id, avatar_url
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E7%B3%BB%E7%BB%9F%E5%86%85bot%E7%9A%84%E8%B5%84%E6%96%99
* @return array|bool
*/
public function getGuildServiceProfile()
{
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__)
], $this->callback);
}

/**
* 获取频道列表
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8
* @return array|bool
*/
public function getGuildList() {
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__)
], $this->callback);
}

/**
* 通过访客获取频道元数据
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E9%80%9A%E8%BF%87%E8%AE%BF%E5%AE%A2%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E5%85%83%E6%95%B0%E6%8D%AE
* @param $guild_id
* @return array|bool
*/
public function getGuildMetaByGuest($guild_id) {
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__),
'params' => [
'guild_id' => $guild_id
]
], $this->callback);
}

/**
* 获取子频道列表
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E5%AD%90%E9%A2%91%E9%81%93%E5%88%97%E8%A1%A8
* @param $guild_id
* @param false $no_cache
* @return array|bool
*/
public function getGuildChannelList($guild_id, bool $no_cache = false) {
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__),
'params' => [
'guild_id' => $guild_id,
'no_cache' => $no_cache
]
], $this->callback);
}

/**
* 获取频道成员列表
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E8%8E%B7%E5%8F%96%E9%A2%91%E9%81%93%E6%88%90%E5%91%98%E5%88%97%E8%A1%A8
* @param $guild_id
* @return array|bool
*/
public function getGuildMembers($guild_id) {
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__),
'params' => [
'guild_id' => $guild_id
]
], $this->callback);
}

/**
* 发送信息到子频道
* @link https://github.com/Mrs4s/go-cqhttp/blob/master/docs/guild.md#%E5%8F%91%E9%80%81%E4%BF%A1%E6%81%AF%E5%88%B0%E5%AD%90%E9%A2%91%E9%81%93
* @param $guild_id
* @param $channel_id
* @param $message
* @return array|bool
*/
public function sendGuildChannelMsg($guild_id, $channel_id, $message) {
return $this->processAPI($this->connection, [
'action' => $this->getActionName($this->prefix, __FUNCTION__),
'params' => [
'guild_id' => $guild_id,
'channel_id' => $channel_id,
'message' => $message
]
], $this->callback);
}
}
Loading

0 comments on commit 74050c4

Please sign in to comment.