获取Bot列表
getBotList
获取当前插件绑定节点下的所有 Bot 账号信息。
签名
getBotList()
参数
无参数。
响应数据
| 字段名 | 数据类型 | 说明 |
|---|---|---|
| code | number | 0 成功,-1 失败 |
| msg | string | 描述信息 |
| data | Array | Bot 列表 |
data 数组每项:
| 字段名 | 数据类型 | 说明 |
|---|---|---|
| string | QQ 号 | |
| nickname | string | 昵称 |
| level | string | QQ 等级 |
| protocol | string | 协议名称 |
| status | boolean | 在线状态 |
| received | number | 接收消息数 |
| sent | number | 发送消息数 |
| onlineTime | number | 上线时间戳(秒) |
| info | string | 附加信息 |
| node | object|null | 所属节点 { id, name } |
示例
遍历所有 Bot:
const res = getBotList();
if (res.code === 0) {
res.data.forEach(bot => {
const status = bot.status ? "在线" : "离线";
writeLog(`${bot.nickname}(${bot.qq}) ${status} Lv.${bot.level}`);
});
}
统计收发消息:
const res = getBotList();
if (res.code === 0) {
const totalReceived = res.data.reduce((s, b) => s + b.received, 0);
const totalSent = res.data.reduce((s, b) => s + b.sent, 0);
writeLog(`收: ${totalReceived} 发: ${totalSent}`);
}