Commit 16d144ad authored by Joel's avatar Joel Committed by GitHub

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.
parent 2e0990e9
...@@ -199,8 +199,17 @@ export class ChatGPTAPIBrowser { ...@@ -199,8 +199,17 @@ export class ChatGPTAPIBrowser {
const lastMessage = await this.getLastMessage() const lastMessage = await this.getLastMessage()
await inputBox.click() await inputBox.click()
await inputBox.type(message, { delay: 0 }) const paragraphs = message.split('\n')
await inputBox.press('Enter') 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 { do {
await delay(1000) await delay(1000)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment