Refactor messageHandler to check OpenAI API key

- Import checkOpenaiApiKey function from contributes/commands.
- Update sendMessage condition to include checkOpenaiApiKey.
This commit is contained in:
bobo.yang 2023-05-28 13:12:05 +08:00
parent 50b8ae8185
commit 15230c80a3

View File

@ -7,6 +7,7 @@ import '../context/loadContexts';
import { logger } from '../util/logger';
import { on } from 'events';
import { isWaitForApiKey, onApiKey } from './historyMessages';
import { checkOpenaiApiKey } from '../contributes/commands';
export class MessageHandler {
@ -33,7 +34,7 @@ export class MessageHandler {
}
}
if (message.command === 'sendMessage') {
if (await isWaitForApiKey()) {
if (await isWaitForApiKey() && !await checkOpenaiApiKey()) {
onApiKey(message.text, panel);
return;
}