From 07203e4d74c94906dcdec63f8c2710308e5caff9 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Thu, 8 Dec 2022 19:42:21 +0800 Subject: [PATCH] fix: list format --- index.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/index.js b/index.js index 35e27d3..e8ec778 100644 --- a/index.js +++ b/index.js @@ -29,7 +29,8 @@ export class chatgpt extends plugin { }, { reg: 'chatgpt对话列表', - fnc: 'getConversations' + fnc: 'getConversations', + permission: 'master' }, { reg: '^#结束对话([\s\S]*)', @@ -55,19 +56,19 @@ export class chatgpt extends plugin { */ async getConversations (e) { let keys = await redis.keys('CHATGPT:CONVERSATIONS:*') - if (!keys || keys.length === 0) { - await this.reply('当前没有人正在与机器人对话', true) - } else { - let response = '当前对话列表:(格式为【开始时间 qq昵称 对话长度 最后活跃时间】)\n' - await Promise.all(keys.map(async (key) => { - let conversation = await redis.get(key) - if (conversation) { - conversation = JSON.parse(conversation) - response += `${conversation.ctime} ${conversation.sender.nickname} ${conversation.num} ${conversation.utime} \n` + if (!keys || keys.length === 0) { + await this.reply('当前没有人正在与机器人对话', true) + } else { + let response = '当前对话列表:(格式为【开始时间 | qq昵称 | 对话长度 | 最后活跃时间】)\n' + await Promise.all(keys.map(async (key) => { + let conversation = await redis.get(key) + if (conversation) { + conversation = JSON.parse(conversation) + response += `${conversation.ctime} | ${conversation.sender.nickname} | ${conversation.num} | ${conversation.utime} \n` + } + })) + await this.reply(`${response}`, true) } - })) - await this.reply(`${response}`, true) - } } /**