Skip to content

Commit

Permalink
feat: detect capacity limit
Browse files Browse the repository at this point in the history
  • Loading branch information
MrlolDev committed Dec 12, 2022
1 parent 658be86 commit 1dc12af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/openai-auth-2captcha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ export async function getOpenAIAuth2Captcha({
// NOTE: this is where you may encounter a CAPTCHA
await page.solveRecaptchas()

var capacityLimit = await page.$('[role="alert"]')
if (capacityLimit) {
throw `ChatGPT is at capacity right now`
}

await page.waitForSelector('#__next .btn-primary', { timeout: timeoutMs })

// once we get to this point, the Cloudflare cookies are available
Expand All @@ -91,10 +96,6 @@ export async function getOpenAIAuth2Captcha({
waitUntil: 'networkidle0'
})
])
/*var capacityLimit = await page.$('')
if (capacityLimit) {
throw `ChatGPT is at capacity right now`
}*/
}

const pageCookies = await page.cookies()
Expand Down
4 changes: 4 additions & 0 deletions src/openai-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export async function getOpenAIAuth({
await page.goto('https://chat.openai.com/auth/login')

// NOTE: this is where you may encounter a CAPTCHA
var capacityLimit = await page.$('[role="alert"]')
if (capacityLimit) {
throw `ChatGPT is at capacity right now`
}

await page.waitForSelector('#__next .btn-primary', { timeout: timeoutMs })

Expand Down

0 comments on commit 1dc12af

Please sign in to comment.