Make commands customizable

main
Stef Dunlap 2023-03-11 00:18:45 -05:00
parent 6ab972368a
commit c11118667e
2 changed files with 8 additions and 4 deletions

View File

@ -5,5 +5,7 @@
"channels": ["#chatgpt"],
"openaiApiKey": "[redacted]",
"initialSystemMessage": "You are a helpful assistant.",
"newChatCmd": "!chat",
"contChatCmd": "!cont",
"alwaysRemember": false
}
}

View File

@ -66,8 +66,10 @@ const client = new irc.Client(config.server, config.nick, {
// listen for messages that start with !chat and call the chatgpt api with a callback that prints the response line by line
client.addListener('message', async (from, to, message) => {
let is_chat_cmd = message.startsWith('!chat');
let is_cont_cmd = message.startsWith('!cont');
const chatCmd = config.newChatCmd;
const contCmd = config.contChatCmd;
let is_chat_cmd = message.startsWith(chatCmd);
let is_cont_cmd = contCmd.length > 0 && message.startsWith(contCmd);
if (is_chat_cmd || is_cont_cmd) {
if (context.is_response_in_progress()) {
@ -78,7 +80,7 @@ client.addListener('message', async (from, to, message) => {
context.clear();
}
context.add_user_prompt(message);
const query = message.slice(6);
const query = message.slice(chatCmd.length + 1);
try {
await chatgpt(query, context.messages, handleChatGPTResponseLine);
context.finish_current_response();