萌卡NT开发文档
首页
指南
API 文档
事件
CQ 码
首页
指南
API 文档
事件
CQ 码
  • 获取Bot列表

获取Bot列表

getBotList

获取当前插件绑定节点下的所有 Bot 账号信息。

签名

getBotList()

参数

无参数。

响应数据

字段名数据类型说明
codenumber0 成功,-1 失败
msgstring描述信息
dataArrayBot 列表

data 数组每项:

字段名数据类型说明
qqstringQQ 号
nicknamestring昵称
levelstringQQ 等级
protocolstring协议名称
statusboolean在线状态
receivednumber接收消息数
sentnumber发送消息数
onlineTimenumber上线时间戳(秒)
infostring附加信息
nodeobject|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}`);
}
最近更新: 2026/5/28 01:00
Contributors: shiin0118