mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-26 01:55:34 +08:00
update to 2.6.4 (build 432)
This commit is contained in:
@@ -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)
|
### callExtendedAPI() (扩充 API)
|
||||||
|
|
||||||
用来调用 OneBot 标准之外扩展出来的自定义 API。
|
用来调用 OneBot 标准之外扩展出来的自定义 API。
|
||||||
|
|||||||
@@ -70,5 +70,6 @@
|
|||||||
| E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 |
|
| E00068 | 模块解包时无法正常拷贝文件 | 检查文件夹是否正常可以创建和写入。 |
|
||||||
| E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()`。 |
|
| E00069 | 框架不能启动两个 ConsoleApplication 实例 | 不要重复使用 `new ConsoleApplication()`。 |
|
||||||
| E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 |
|
| E00070 | 框架找不到 `zm_data` 目录 | 检查配置中指定的 `zm_data` 目录是否存在。 |
|
||||||
|
| E00071 | 框架找不到对应类型的 API 调用类 | 检查 `getExtendedAPI($name)` 传入的 `$name` 是否正确 |
|
||||||
| E99999 | 未知错误 | |
|
| E99999 | 未知错误 | |
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,12 @@
|
|||||||
|
|
||||||
同时此处将只使用 build 版本号进行区分。
|
同时此处将只使用 build 版本号进行区分。
|
||||||
|
|
||||||
|
## build 432 (2021-12-25)
|
||||||
|
|
||||||
|
- 新增 GoCqhttpAPI 包,用于支持额外的 OneBot Action(API)
|
||||||
|
- 修复 MySQL 查询器中 `fetchOne()` 方法无法正确返回值的 Bug
|
||||||
|
- 修复 Swoole Hook 因配置不当无法正确使用的 Bug
|
||||||
|
|
||||||
## build 431 (2021-12-22)
|
## build 431 (2021-12-22)
|
||||||
|
|
||||||
- 修复 Issue #50
|
- 修复 Issue #50
|
||||||
|
|||||||
@@ -1,6 +1,16 @@
|
|||||||
# 更新日志(v2 版本)
|
# 更新日志(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
|
> 更新时间:2021.12.8
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,12 @@ trait CQAPI
|
|||||||
return false;
|
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) {
|
public function __call($name, $arguments) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
111
src/ZM/API/GoCqhttpAPIV11.php
Normal file
111
src/ZM/API/GoCqhttpAPIV11.php
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php /** @noinspection PhpUnused */
|
||||||
|
|
||||||
|
|
||||||
namespace ZM\API;
|
namespace ZM\API;
|
||||||
@@ -6,6 +6,7 @@ namespace ZM\API;
|
|||||||
use ZM\ConnectionManager\ConnectionObject;
|
use ZM\ConnectionManager\ConnectionObject;
|
||||||
use ZM\ConnectionManager\ManagerGM;
|
use ZM\ConnectionManager\ManagerGM;
|
||||||
use ZM\Exception\RobotNotFoundException;
|
use ZM\Exception\RobotNotFoundException;
|
||||||
|
use ZM\Exception\ZMKnownException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OneBot V11 的 API 实现类
|
* OneBot V11 的 API 实现类
|
||||||
@@ -22,10 +23,10 @@ class OneBotV11
|
|||||||
const API_RATE_LIMITED = 2;
|
const API_RATE_LIMITED = 2;
|
||||||
|
|
||||||
/** @var ConnectionObject|null */
|
/** @var ConnectionObject|null */
|
||||||
private $connection;
|
protected $connection;
|
||||||
|
|
||||||
private $callback = true;
|
protected $callback = true;
|
||||||
private $prefix = 0;
|
protected $prefix = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $robot_id
|
* @param $robot_id
|
||||||
@@ -92,7 +93,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function sendPrivateMsg($user_id, $message, $auto_escape = false) {
|
public function sendPrivateMsg($user_id, $message, $auto_escape = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
@@ -111,7 +112,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function sendGroupMsg($group_id, $message, $auto_escape = false) {
|
public function sendGroupMsg($group_id, $message, $auto_escape = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
@@ -131,7 +132,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function sendMsg($message_type, $target_id, $message, $auto_escape = false) {
|
public function sendMsg($message_type, $target_id, $message, $auto_escape = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'message_type' => $message_type,
|
'message_type' => $message_type,
|
||||||
($message_type == 'private' ? 'user' : $message_type) . '_id' => $target_id,
|
($message_type == 'private' ? 'user' : $message_type) . '_id' => $target_id,
|
||||||
@@ -149,7 +150,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function deleteMsg($message_id) {
|
public function deleteMsg($message_id) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'message_id' => $message_id
|
'message_id' => $message_id
|
||||||
]
|
]
|
||||||
@@ -164,7 +165,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getMsg($message_id) {
|
public function getMsg($message_id) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'message_id' => $message_id
|
'message_id' => $message_id
|
||||||
]
|
]
|
||||||
@@ -179,7 +180,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getForwardMsg($id) {
|
public function getForwardMsg($id) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'id' => $id
|
'id' => $id
|
||||||
]
|
]
|
||||||
@@ -195,7 +196,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function sendLike($user_id, $times = 1) {
|
public function sendLike($user_id, $times = 1) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'times' => $times
|
'times' => $times
|
||||||
@@ -213,7 +214,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupKick($group_id, $user_id, $reject_add_request = false) {
|
public function setGroupKick($group_id, $user_id, $reject_add_request = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -232,7 +233,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupBan($group_id, $user_id, $duration = 1800) {
|
public function setGroupBan($group_id, $user_id, $duration = 1800) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -251,7 +252,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupAnonymousBan($group_id, $anonymous_or_flag, $duration = 1800) {
|
public function setGroupAnonymousBan($group_id, $anonymous_or_flag, $duration = 1800) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
(is_string($anonymous_or_flag) ? 'flag' : 'anonymous') => $anonymous_or_flag,
|
(is_string($anonymous_or_flag) ? 'flag' : 'anonymous') => $anonymous_or_flag,
|
||||||
@@ -269,7 +270,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupWholeBan($group_id, $enable = true) {
|
public function setGroupWholeBan($group_id, $enable = true) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'enable' => $enable
|
'enable' => $enable
|
||||||
@@ -287,7 +288,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupAdmin($group_id, $user_id, $enable = true) {
|
public function setGroupAdmin($group_id, $user_id, $enable = true) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -305,7 +306,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupAnonymous($group_id, $enable = true) {
|
public function setGroupAnonymous($group_id, $enable = true) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'enable' => $enable
|
'enable' => $enable
|
||||||
@@ -323,7 +324,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupCard($group_id, $user_id, $card = "") {
|
public function setGroupCard($group_id, $user_id, $card = "") {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -341,7 +342,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupName($group_id, $group_name) {
|
public function setGroupName($group_id, $group_name) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'group_name' => $group_name
|
'group_name' => $group_name
|
||||||
@@ -358,7 +359,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupLeave($group_id, $is_dismiss = false) {
|
public function setGroupLeave($group_id, $is_dismiss = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'is_dismiss' => $is_dismiss
|
'is_dismiss' => $is_dismiss
|
||||||
@@ -377,7 +378,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupSpecialTitle($group_id, $user_id, $special_title = "", $duration = -1) {
|
public function setGroupSpecialTitle($group_id, $user_id, $special_title = "", $duration = -1) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -397,7 +398,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setFriendAddRequest($flag, $approve = true, $remark = "") {
|
public function setFriendAddRequest($flag, $approve = true, $remark = "") {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'flag' => $flag,
|
'flag' => $flag,
|
||||||
'approve' => $approve,
|
'approve' => $approve,
|
||||||
@@ -417,7 +418,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setGroupAddRequest($flag, $sub_type, $approve = true, $reason = "") {
|
public function setGroupAddRequest($flag, $sub_type, $approve = true, $reason = "") {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'flag' => $flag,
|
'flag' => $flag,
|
||||||
'sub_type' => $sub_type,
|
'sub_type' => $sub_type,
|
||||||
@@ -433,7 +434,7 @@ class OneBotV11
|
|||||||
* @return array|bool|null
|
* @return array|bool|null
|
||||||
*/
|
*/
|
||||||
public function getLoginInfo() {
|
public function getLoginInfo() {
|
||||||
return $this->processAPI($this->connection, ['action' => $this->getActionName(__FUNCTION__)], $this->callback);
|
return $this->processAPI($this->connection, ['action' => $this->getActionName($this->prefix, __FUNCTION__)], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -443,9 +444,9 @@ class OneBotV11
|
|||||||
* @param bool $no_cache
|
* @param bool $no_cache
|
||||||
* @return array|bool|null
|
* @return array|bool|null
|
||||||
*/
|
*/
|
||||||
public function getStrangerInfo($user_id, $no_cache = false) {
|
public function getStrangerInfo($user_id, bool $no_cache) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'no_cache' => $no_cache
|
'no_cache' => $no_cache
|
||||||
@@ -460,7 +461,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getFriendList() {
|
public function getFriendList() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -473,7 +474,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getGroupInfo($group_id, $no_cache = false) {
|
public function getGroupInfo($group_id, $no_cache = false) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'no_cache' => $no_cache
|
'no_cache' => $no_cache
|
||||||
@@ -488,7 +489,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getGroupList() {
|
public function getGroupList() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,9 +501,9 @@ class OneBotV11
|
|||||||
* @param bool $no_cache
|
* @param bool $no_cache
|
||||||
* @return array|bool|null
|
* @return array|bool|null
|
||||||
*/
|
*/
|
||||||
public function getGroupMemberInfo($group_id, $user_id, $no_cache = false) {
|
public function getGroupMemberInfo($group_id, $user_id, bool $no_cache) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
@@ -519,7 +520,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getGroupMemberList($group_id) {
|
public function getGroupMemberList($group_id) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id
|
'group_id' => $group_id
|
||||||
]
|
]
|
||||||
@@ -535,7 +536,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getGroupHonorInfo($group_id, $type) {
|
public function getGroupHonorInfo($group_id, $type) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'group_id' => $group_id,
|
'group_id' => $group_id,
|
||||||
'type' => $type
|
'type' => $type
|
||||||
@@ -550,7 +551,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getCsrfToken() {
|
public function getCsrfToken() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,7 +563,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getCredentials($domain = "") {
|
public function getCredentials($domain = "") {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'domain' => $domain
|
'domain' => $domain
|
||||||
]
|
]
|
||||||
@@ -578,7 +579,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getRecord($file, $out_format) {
|
public function getRecord($file, $out_format) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'file' => $file,
|
'file' => $file,
|
||||||
'out_format' => $out_format
|
'out_format' => $out_format
|
||||||
@@ -594,7 +595,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getImage($file) {
|
public function getImage($file) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'file' => $file
|
'file' => $file
|
||||||
]
|
]
|
||||||
@@ -608,7 +609,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function canSendImage() {
|
public function canSendImage() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,7 +620,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function canSendRecord() {
|
public function canSendRecord() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,7 +631,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getStatus() {
|
public function getStatus() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +642,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function getVersionInfo() {
|
public function getVersionInfo() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,7 +654,7 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function setRestart($delay = 0) {
|
public function setRestart($delay = 0) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__),
|
'action' => $this->getActionName($this->prefix, __FUNCTION__),
|
||||||
'params' => [
|
'params' => [
|
||||||
'delay' => $delay
|
'delay' => $delay
|
||||||
]
|
]
|
||||||
@@ -667,20 +668,32 @@ class OneBotV11
|
|||||||
*/
|
*/
|
||||||
public function cleanCache() {
|
public function cleanCache() {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $this->getActionName(__FUNCTION__)
|
'action' => $this->getActionName($this->prefix, __FUNCTION__)
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取内置支持的扩展API对象
|
||||||
|
* 现支持 go-cqhttp 的扩展API
|
||||||
|
* @param string $package_name
|
||||||
|
* @return mixed
|
||||||
|
* @throws ZMKnownException
|
||||||
|
*/
|
||||||
|
public function getExtendedAPI(string $package_name = 'go-cqhttp') {
|
||||||
|
$table = [
|
||||||
|
'go-cqhttp' => GoCqhttpAPIV11::class,
|
||||||
|
];
|
||||||
|
if (isset($table[$package_name])) {
|
||||||
|
return new $table[$package_name]($this->connection, $this->callback, $this->prefix);
|
||||||
|
} else {
|
||||||
|
throw new ZMKnownException(zm_internal_errcode('E00071'), '无法找到对应的调用扩展类');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function callExtendedAPI($action, $params = []) {
|
public function callExtendedAPI($action, $params = []) {
|
||||||
return $this->processAPI($this->connection, [
|
return $this->processAPI($this->connection, [
|
||||||
'action' => $action,
|
'action' => $action,
|
||||||
'params' => $params
|
'params' => $params
|
||||||
], $this->callback);
|
], $this->callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getActionName(string $method) {
|
|
||||||
$prefix = ($this->prefix == self::API_ASYNC ? '_async' : ($this->prefix == self::API_RATE_LIMITED ? '_rate_limited' : ''));
|
|
||||||
$func_name = strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $method));
|
|
||||||
return $func_name . $prefix;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -30,7 +30,7 @@ class ConsoleApplication extends Application
|
|||||||
{
|
{
|
||||||
private static $obj = null;
|
private static $obj = null;
|
||||||
|
|
||||||
const VERSION_ID = 431;
|
const VERSION_ID = 432;
|
||||||
const VERSION = "2.6.4";
|
const VERSION = "2.6.4";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -487,7 +487,7 @@ class Framework
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$global_hook = ZMConfig::get("global", 'runtime')['swoole_coroutine_hook_flags'] ?? (SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL));
|
$global_hook = ZMConfig::get("global", 'runtime')['swoole_coroutine_hook_flags'] ?? (SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL));
|
||||||
if ($coroutine_mode && $global_hook === false) Runtime::enableCoroutine(true, $global_hook);
|
if ($coroutine_mode) Runtime::enableCoroutine(true, $global_hook);
|
||||||
else Runtime::enableCoroutine(false, SWOOLE_HOOK_ALL);
|
else Runtime::enableCoroutine(false, SWOOLE_HOOK_ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class MySQLWrapper
|
|||||||
* @return false|mixed
|
* @return false|mixed
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
*/
|
*/
|
||||||
public function fetchOne(string $query, array $params = [], array $types = []): bool {
|
public function fetchOne(string $query, array $params = [], array $types = []) {
|
||||||
try {
|
try {
|
||||||
return $this->connection->fetchOne($query, $params, $types);
|
return $this->connection->fetchOne($query, $params, $types);
|
||||||
} catch (Throwable $e) {
|
} catch (Throwable $e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user