File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -10,31 +10,37 @@ export function initChatGPT() {
1010 } ) ;
1111}
1212
13- async function getChatGPTReply ( content ) {
13+ async function getChatGPTReply ( content , contactId ) {
1414 const { conversationId, text, id } = await chatGPT . sendMessage (
1515 content ,
16- chatOption
16+ chatOption [ contactId ]
1717 ) ;
1818 chatOption = {
19- conversationId,
20- parentMessageId : id ,
19+ [ contactId ] : {
20+ conversationId,
21+ parentMessageId : id ,
22+ } ,
2123 } ;
2224 console . log ( 'response: ' , conversationId , text ) ;
2325 // response is a markdown-formatted string
2426 return text ;
2527}
2628
2729export async function replyMessage ( contact , content ) {
30+ const { id : contactId } = contact ;
2831 try {
2932 if (
3033 content . trim ( ) . toLocaleLowerCase ( ) === config . resetKey . toLocaleLowerCase ( )
3134 ) {
32- chatOption = { } ;
35+ chatOption = {
36+ ...chatOption ,
37+ [ contactId ] : { } ,
38+ } ;
3339 await contact . say ( 'Previous conversation has been reset.' ) ;
3440 return ;
3541 }
3642 const message = await retryRequest (
37- ( ) => getChatGPTReply ( content ) ,
43+ ( ) => getChatGPTReply ( content , contactId ) ,
3844 config . retryTimes ,
3945 500
4046 ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import config from './config.js';
44import { replyMessage , initChatGPT } from './chatgpt.js' ;
55
66let bot : any = { } ;
7- initProjest ( ) ;
7+ initProject ( ) ;
88async function onMessage ( msg ) {
99 const contact = msg . talker ( ) ;
1010 const receiver = msg . to ( ) ;
@@ -82,7 +82,7 @@ async function onFriendShip(friendship) {
8282 }
8383}
8484
85- async function initProjest ( ) {
85+ async function initProject ( ) {
8686 try {
8787 await initChatGPT ( ) ;
8888 bot = WechatyBuilder . build ( {
You can’t perform that action at this time.
0 commit comments