fix: list format

This commit is contained in:
ikechan8370 2022-12-08 19:42:21 +08:00
parent 763e3f5b7d
commit 07203e4d74

View file

@ -29,7 +29,8 @@ export class chatgpt extends plugin {
}, },
{ {
reg: 'chatgpt对话列表', reg: 'chatgpt对话列表',
fnc: 'getConversations' fnc: 'getConversations',
permission: 'master'
}, },
{ {
reg: '^#结束对话([\s\S]*)', reg: '^#结束对话([\s\S]*)',
@ -58,12 +59,12 @@ export class chatgpt extends plugin {
if (!keys || keys.length === 0) { if (!keys || keys.length === 0) {
await this.reply('当前没有人正在与机器人对话', true) await this.reply('当前没有人正在与机器人对话', true)
} else { } else {
let response = '当前对话列表:(格式为【开始时间 qq昵称 对话长度 最后活跃时间】)\n' let response = '当前对话列表:(格式为【开始时间 qq昵称 对话长度 最后活跃时间】)\n'
await Promise.all(keys.map(async (key) => { await Promise.all(keys.map(async (key) => {
let conversation = await redis.get(key) let conversation = await redis.get(key)
if (conversation) { if (conversation) {
conversation = JSON.parse(conversation) conversation = JSON.parse(conversation)
response += `${conversation.ctime} ${conversation.sender.nickname} ${conversation.num} ${conversation.utime} \n` response += `${conversation.ctime} ${conversation.sender.nickname} ${conversation.num} ${conversation.utime} \n`
} }
})) }))
await this.reply(`${response}`, true) await this.reply(`${response}`, true)