fix: 修复和优化群聊文件读取逻辑

This commit is contained in:
ikechan8370 2023-12-11 00:46:38 +08:00
parent d254163fa7
commit e61d4ff3fa
3 changed files with 17 additions and 6 deletions

View file

@ -1,4 +1,3 @@
import common from '../../../lib/common/common.js'
export async function getChatHistoryGroup (e, num) {
// if (e.adapter === 'shamrock') {
@ -46,9 +45,15 @@ export async function getChatHistoryGroup (e, num) {
return []
}
function pickMemberAsync (e, userId) {
async function pickMemberAsync (e, userId) {
let key = `CHATGPT:GroupMemberInfo:${e.group_id}:${userId}`
let cache = await redis.get(key)
if (cache) {
return JSON.parse(cache)
}
return new Promise((resolve, reject) => {
e.group.pickMember(userId, true, (sender) => {
redis.set(key, JSON.stringify(sender), { EX: 86400 })
resolve(sender)
})
})