Compare commits
2 Commits
1abaa24a2b
...
6ab972368a
Author | SHA1 | Date |
---|---|---|
Stef Dunlap | 6ab972368a | |
Stef Dunlap | 22d0b8a412 |
9
index.js
9
index.js
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/env node
|
||||
//IRC bot that responds to !chat, queries the chatgpt api, and prints the response line by line
|
||||
const fs = require('fs');
|
||||
const irc = require('irc');
|
||||
const axios = require('axios');
|
||||
const config = require('./config.json');
|
||||
|
@ -51,9 +52,9 @@ class Context {
|
|||
}
|
||||
}
|
||||
|
||||
let context = new Context(savedMessages);
|
||||
let context = null;
|
||||
if (fs.existsSync('./messages.json')) {
|
||||
savedMessages = require('./messages.json');
|
||||
const savedMessages = require('./messages.json');
|
||||
context = new Context(savedMessages);
|
||||
} else {
|
||||
context = new Context(seed_messages);
|
||||
|
@ -76,7 +77,7 @@ client.addListener('message', async (from, to, message) => {
|
|||
if(is_chat_cmd && !config.alwaysRemember) {
|
||||
context.clear();
|
||||
}
|
||||
context.add_user_prompt(query);
|
||||
context.add_user_prompt(message);
|
||||
const query = message.slice(6);
|
||||
try {
|
||||
await chatgpt(query, context.messages, handleChatGPTResponseLine);
|
||||
|
@ -175,4 +176,4 @@ function chatgpt(query, messages, callback) {
|
|||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue