mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +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) {
|
async recordChat (e) {
|
||||||
// let gl = await this.e.group.getMemberMap()
|
// 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 = {
|
const chat = {
|
||||||
sender: e.sender.card,
|
sender: e.sender.card,
|
||||||
senderId: e.sender.user_id,
|
senderId: e.sender.user_id,
|
||||||
senderSex: e.sender.sex,
|
senderSex: e.sender.sex,
|
||||||
msg: e.msg,
|
msg: e.raw_message,
|
||||||
role: e.sender.role,
|
role: e.sender.role,
|
||||||
area: e.sender.area,
|
area: e.sender.area,
|
||||||
age: e.sender.age,
|
age: e.sender.age,
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import crypto from 'crypto'
|
||||||
|
|
||||||
import HttpsProxyAgent from 'https-proxy-agent'
|
import HttpsProxyAgent from 'https-proxy-agent'
|
||||||
import { Config, pureSydneyInstruction } from './config.js'
|
import { Config, pureSydneyInstruction } from './config.js'
|
||||||
import { getMasterQQ, isCN } from './common.js'
|
import {formatDate, getMasterQQ, isCN} from './common.js'
|
||||||
import delay from 'delay'
|
import delay from 'delay'
|
||||||
|
|
||||||
if (!globalThis.fetch) {
|
if (!globalThis.fetch) {
|
||||||
|
|
@ -696,6 +696,22 @@ export default class SydneyAIClient {
|
||||||
conversation.messages.push(userMessage)
|
conversation.messages.push(userMessage)
|
||||||
conversation.messages.push(replyMessage)
|
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)
|
await this.conversationsCache.set(conversationKey, conversation)
|
||||||
return {
|
return {
|
||||||
conversationSignature,
|
conversationSignature,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue