fix: properly handle messages with newlines

Pressing Enter would normally send the current message, so now the code splits it up by newlines and uses Shift+Enter unless it's the last split.
pull/143/head
Joel 2022-12-14 22:24:03 -08:00 zatwierdzone przez GitHub
rodzic 2e0990e9be
commit 16d144adab
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 11 dodań i 2 usunięć

Wyświetl plik

@ -199,8 +199,17 @@ export class ChatGPTAPIBrowser {
const lastMessage = await this.getLastMessage()
await inputBox.click()
await inputBox.type(message, { delay: 0 })
await inputBox.press('Enter')
const paragraphs = message.split('\n')
for (let i = 0; i < paragraphs.length; i++) {
await inputBox.type(paragraphs[i], { delay: 0 })
if (i < paragraphs.length - 1) {
await this._page.keyboard.down('Shift')
await inputBox.press('Enter')
await this._page.keyboard.up('Shift')
} else {
await inputBox.press('Enter')
}
}
do {
await delay(1000)