Make commands customizable
parent
6ab972368a
commit
c11118667e
|
@ -5,5 +5,7 @@
|
||||||
"channels": ["#chatgpt"],
|
"channels": ["#chatgpt"],
|
||||||
"openaiApiKey": "[redacted]",
|
"openaiApiKey": "[redacted]",
|
||||||
"initialSystemMessage": "You are a helpful assistant.",
|
"initialSystemMessage": "You are a helpful assistant.",
|
||||||
|
"newChatCmd": "!chat",
|
||||||
|
"contChatCmd": "!cont",
|
||||||
"alwaysRemember": false
|
"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
|
// 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) => {
|
client.addListener('message', async (from, to, message) => {
|
||||||
let is_chat_cmd = message.startsWith('!chat');
|
const chatCmd = config.newChatCmd;
|
||||||
let is_cont_cmd = message.startsWith('!cont');
|
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 (is_chat_cmd || is_cont_cmd) {
|
||||||
if (context.is_response_in_progress()) {
|
if (context.is_response_in_progress()) {
|
||||||
|
@ -78,7 +80,7 @@ client.addListener('message', async (from, to, message) => {
|
||||||
context.clear();
|
context.clear();
|
||||||
}
|
}
|
||||||
context.add_user_prompt(message);
|
context.add_user_prompt(message);
|
||||||
const query = message.slice(6);
|
const query = message.slice(chatCmd.length + 1);
|
||||||
try {
|
try {
|
||||||
await chatgpt(query, context.messages, handleChatGPTResponseLine);
|
await chatgpt(query, context.messages, handleChatGPTResponseLine);
|
||||||
context.finish_current_response();
|
context.finish_current_response();
|
||||||
|
|
Loading…
Reference in New Issue