mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
feat: add robot msg
This commit is contained in:
parent
6653188a8f
commit
7d571df12a
2 changed files with 25 additions and 4 deletions
|
|
@ -1270,12 +1270,17 @@ export class chatgpt extends plugin {
|
|||
|
||||
async recordChat (e) {
|
||||
// let gl = await this.e.group.getMemberMap()
|
||||
if (e.isGroup && e.msg) {
|
||||
if (!e.raw_message) {
|
||||
if (e.img && e.img.length > 0) {
|
||||
e.msg = '[图片]'
|
||||
}
|
||||
}
|
||||
if (e.isGroup && e.raw_message) {
|
||||
const chat = {
|
||||
sender: e.sender.card,
|
||||
senderId: e.sender.user_id,
|
||||
senderSex: e.sender.sex,
|
||||
msg: e.msg,
|
||||
msg: e.raw_message,
|
||||
role: e.sender.role,
|
||||
area: e.sender.area,
|
||||
age: e.sender.age,
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import crypto from 'crypto'
|
|||
|
||||
import HttpsProxyAgent from 'https-proxy-agent'
|
||||
import { Config, pureSydneyInstruction } from './config.js'
|
||||
import { getMasterQQ, isCN } from './common.js'
|
||||
import {formatDate, getMasterQQ, isCN} from './common.js'
|
||||
import delay from 'delay'
|
||||
|
||||
if (!globalThis.fetch) {
|
||||
|
|
@ -452,7 +452,7 @@ export default class SydneyAIClient {
|
|||
.map((item) => item.toString())
|
||||
.map(chat => {
|
||||
chat = JSON.parse(chat)
|
||||
return `发言者:${chat.sender}(${chat.senderId})[${chat.role}][${chat.area}](${chat.age}) 性别:${chat.senderSex} 发言内容:${chat.msg} 发言时间:${chat.time}\n`
|
||||
return `发言者:${chat.sender} (${chat.senderId}) [${chat.role}] [${chat.area}] (${chat.age}) 性别:${chat.senderSex} 发言内容:${chat.msg} 发言时间:${chat.time}\n`
|
||||
})
|
||||
.join('\n')
|
||||
}
|
||||
|
|
@ -696,6 +696,22 @@ export default class SydneyAIClient {
|
|||
conversation.messages.push(userMessage)
|
||||
conversation.messages.push(replyMessage)
|
||||
}
|
||||
if (groupId) {
|
||||
const chat = {
|
||||
sender: Config.sydneyBrainWashName || 'Sydney',
|
||||
senderId: Bot.uin,
|
||||
msg: reply.text,
|
||||
role: 'robot',
|
||||
area: 'Microsoft',
|
||||
age: 1,
|
||||
time: formatDate(new Date())
|
||||
}
|
||||
// console.log(chat)
|
||||
await redis.rPush('CHATGPT:LATEST_CHAT_RECORD:' + groupId, JSON.stringify(chat))
|
||||
if (await redis.lLen('CHATGPT:LATEST_CHAT_RECORD:' + groupId) > Config.groupContextLength) {
|
||||
await redis.lPop('CHATGPT:LATEST_CHAT_RECORD:' + groupId)
|
||||
}
|
||||
}
|
||||
await this.conversationsCache.set(conversationKey, conversation)
|
||||
return {
|
||||
conversationSignature,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue