ZM\API\OneBotV11
get
public function get(int|string $robot_id): ZMRobot
描述
获取机器人Action/API实例
参数
| 名称 |
类型 |
描述 |
| robot_id |
int |
string |
返回
getRandom
public function getRandom(): ZMRobot
描述
随机获取一个连接到框架的机器人实例
返回
getAllRobot
public function getAllRobot(): ZMRobot[]
描述
获取所有机器人实例
返回
setCallback
public function setCallback(bool|Closure $callback): OneBotV11
描述
设置回调或启用协程等待API回包
参数
| 名称 |
类型 |
描述 |
| callback |
bool |
Closure |
返回
setPrefix
public function setPrefix(int $prefix): OneBotV11
描述
设置API调用类型后缀
参数
| 名称 |
类型 |
描述 |
| prefix |
int |
设置后缀类型,API_NORMAL为不加后缀,API_ASYNC为异步调用,API_RATE_LIMITED为加后缀并且限制调用频率 |
返回
sendPrivateMsg
public function sendPrivateMsg(int|string $user_id, string $message, bool $auto_escape): array|bool
描述
发送私聊消息
参数
| 名称 |
类型 |
描述 |
| user_id |
int |
string |
| message |
string |
消息内容 |
| auto_escape |
bool |
是否自动转义(默认为false) |
返回
sendGroupMsg
public function sendGroupMsg(int|string $group_id, string $message, bool $auto_escape): array|bool
描述
发送群消息
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| message |
string |
消息内容 |
| auto_escape |
bool |
是否自动转义(默认为false) |
返回
sendMsg
public function sendMsg(string $message_type, int|string $target_id, string $message, bool $auto_escape): array|bool
描述
发送消息
参数
| 名称 |
类型 |
描述 |
| message_type |
string |
消息类型 |
| target_id |
int |
string |
| message |
string |
消息内容 |
| auto_escape |
bool |
是否自动转义(默认为false) |
返回
deleteMsg
public function deleteMsg(int|string $message_id): array|bool
描述
撤回消息
参数
| 名称 |
类型 |
描述 |
| message_id |
int |
string |
返回
getMsg
public function getMsg(int|string $message_id): array|bool
描述
获取消息
参数
| 名称 |
类型 |
描述 |
| message_id |
int |
string |
返回
getForwardMsg
public function getForwardMsg(int|string $id): array|bool
描述
获取合并转发消息
参数
返回
sendLike
public function sendLike(int|string $user_id, int $times): array|bool
描述
发送好友赞
参数
| 名称 |
类型 |
描述 |
| user_id |
int |
string |
| times |
int |
时间 |
返回
setGroupKick
public function setGroupKick(int|string $group_id, int|string $user_id, bool $reject_add_request): array|bool
描述
群组踢人
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| reject_add_request |
bool |
|
返回
setGroupBan
public function setGroupBan(int|string $group_id, int|string $user_id, int $duration): array|bool
描述
群组单人禁言
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| duration |
int |
禁言时长 |
返回
setGroupAnonymousBan
public function setGroupAnonymousBan(int|string $group_id, array|int|string $anonymous_or_flag, int $duration): array|bool
描述
群组匿名用户禁言
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| anonymous_or_flag |
array |
int |
| duration |
int |
|
返回
setGroupWholeBan
public function setGroupWholeBan(int|string $group_id, bool $enable): array|bool
描述
群组全员禁言
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| enable |
bool |
|
返回
setGroupAdmin
public function setGroupAdmin(int|string $group_id, int|string $user_id, bool $enable): array|bool
描述
群组设置管理员
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| enable |
bool |
|
返回
setGroupAnonymous
public function setGroupAnonymous(int|string $group_id, bool $enable): array|bool
描述
群组匿名
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| enable |
bool |
是否启用(默认为true) |
返回
setGroupCard
public function setGroupCard(int|string $group_id, int|string $user_id, string $card): array|bool
描述
设置群名片(群备注)
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| card |
string |
名片内容(默认为空) |
返回
setGroupName
public function setGroupName(int|string $group_id, string $group_name): array|bool
描述
设置群名
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| group_name |
string |
群名 |
返回
setGroupLeave
public function setGroupLeave(int|string $group_id, bool $is_dismiss): array|bool
描述
退出群组
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| is_dismiss |
bool |
是否解散(默认为false) |
返回
setGroupSpecialTitle
public function setGroupSpecialTitle(int|string $group_id, int|string $user_id, string $special_title, int $duration): array|bool
描述
设置群组专属头衔
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| special_title |
string |
专属头衔内容 |
| duration |
int |
持续时间(默认为-1,永久) |
返回
setFriendAddRequest
public function setFriendAddRequest(array|int|string $flag, bool $approve, string $remark): array|bool
描述
处理加好友请求
参数
| 名称 |
类型 |
描述 |
| flag |
array |
int |
| approve |
bool |
是否同意(默认为true) |
| remark |
string |
设置昵称(默认不设置) |
返回
setGroupAddRequest
public function setGroupAddRequest(array|int|string $flag, string $sub_type, bool $approve, string $reason): array|bool
描述
处理加群请求/邀请
参数
| 名称 |
类型 |
描述 |
| flag |
array |
int |
| sub_type |
string |
处理请求类型(包含add和invite) |
| approve |
bool |
是否同意(默认为true) |
| reason |
string |
拒绝理由(仅在拒绝时有效,默认为空) |
返回
getLoginInfo
public function getLoginInfo(): array|bool
描述
获取登录号信息
返回
getStrangerInfo
public function getStrangerInfo(int|string $user_id, bool $no_cache): array|bool
描述
获取陌生人信息
参数
| 名称 |
类型 |
描述 |
| user_id |
int |
string |
| no_cache |
bool |
是否不使用缓存(默认为false) |
返回
getFriendList
public function getFriendList(): array|bool
描述
获取好友列表
返回
getGroupInfo
public function getGroupInfo(int|string $group_id, bool $no_cache): array|bool
描述
获取群信息
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| no_cache |
bool |
|
返回
getGroupList
public function getGroupList(): array|bool
描述
获取群列表
返回
getGroupMemberInfo
public function getGroupMemberInfo(int|string $group_id, int|string $user_id, bool $no_cache): array|bool
描述
获取群成员信息
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| user_id |
int |
string |
| no_cache |
bool |
|
返回
getGroupMemberList
public function getGroupMemberList(int|string $group_id): array|bool
描述
获取群成员列表
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
返回
getGroupHonorInfo
public function getGroupHonorInfo(int|string $group_id, string $type): array|bool
描述
获取群荣誉信息
参数
| 名称 |
类型 |
描述 |
| group_id |
int |
string |
| type |
string |
荣誉类型 |
返回
getCsrfToken
public function getCsrfToken(): array|bool
描述
获取 CSRF Token
返回
getCredentials
public function getCredentials(string $domain): array|bool
描述
获取 QQ 相关接口凭证
参数
返回
getRecord
public function getRecord(string $file, string $out_format): array|bool
描述
获取语音
参数
| 名称 |
类型 |
描述 |
| file |
string |
文件 |
| out_format |
string |
输出格式 |
返回
getImage
public function getImage(string $file): array|bool
描述
获取图片
参数
返回
canSendImage
public function canSendImage(): array|bool
描述
检查是否可以发送图片
返回
canSendRecord
public function canSendRecord(): array|bool
描述
检查是否可以发送语音
返回
getStatus
public function getStatus(): array|bool
描述
获取运行状态
返回
getVersionInfo
public function getVersionInfo(): array|bool
描述
获取版本信息
返回
setRestart
public function setRestart(int $delay): array|bool
描述
重启 OneBot 实现
参数
| 名称 |
类型 |
描述 |
| delay |
int |
延迟时间(毫秒,默认为0) |
返回
cleanCache
public function cleanCache(): array|bool
描述
清理缓存
返回
getExtendedAPI
public function getExtendedAPI(string $package_name): mixed
描述
获取内置支持的扩展API对象
现支持 go-cqhttp 的扩展API
参数
| 名称 |
类型 |
描述 |
| package_name |
string |
|
返回
callExtendedAPI
public function callExtendedAPI(string $action, array $params): array|bool
描述
作者很懒,什么也没有说
参数
| 名称 |
类型 |
描述 |
| action |
string |
动作(API)名称 |
| params |
array |
参数 |
返回