Make commands customizable
parent
6ab972368a
commit
c11118667e
|
@ -5,5 +5,7 @@
|
|||
"channels": ["#chatgpt"],
|
||||
"openaiApiKey": "[redacted]",
|
||||
"initialSystemMessage": "You are a helpful assistant.",
|
||||
"newChatCmd": "!chat",
|
||||
"contChatCmd": "!cont",
|
||||
"alwaysRemember": false
|
||||
}
|
8
index.js
8
index.js
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue