kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
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
rodzic
2e0990e9be
commit
16d144adab
|
@ -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')
|
||||||
|
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 inputBox.press('Enter')
|
||||||
|
await this._page.keyboard.up('Shift')
|
||||||
|
} else {
|
||||||
|
await inputBox.press('Enter')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
await delay(1000)
|
await delay(1000)
|
||||||
|
|
Ładowanie…
Reference in New Issue