|
@@ -18,7 +18,7 @@ import { SocksProxyAgent } from 'socks-proxy-agent';
|
|
|
|
|
|
import { getLogger } from './loggers';
|
|
import { getLogger } from './loggers';
|
|
import QQBot from './koishi';
|
|
import QQBot from './koishi';
|
|
-import { Arr, BigNumOps, chainPromises } from './utils';
|
|
|
|
|
|
+import { Arr, BigNumOps, chainPromises, neverResolves } from './utils';
|
|
import Webshot, { Cookies, Page } from './webshot';
|
|
import Webshot, { Cookies, Page } from './webshot';
|
|
|
|
|
|
const parseLink = (link: string): { userName?: string, postUrlSegment?: string } => {
|
|
const parseLink = (link: string): { userName?: string, postUrlSegment?: string } => {
|
|
@@ -289,6 +289,10 @@ export default class {
|
|
|
|
|
|
browserLogin = page =>
|
|
browserLogin = page =>
|
|
page.fill('input[name="username"]', opt.credentials[0], {timeout: 0})
|
|
page.fill('input[name="username"]', opt.credentials[0], {timeout: 0})
|
|
|
|
+ .then(() => {
|
|
|
|
+ if (isWaitingForLogin !== true) return;
|
|
|
|
+ logger.warn('still waiting for login, pausing execution...'); return neverResolves();
|
|
|
|
+ })
|
|
.then(() => { isWaitingForLogin = true; logger.warn('blocked by login dialog, trying to log in manually...'); })
|
|
.then(() => { isWaitingForLogin = true; logger.warn('blocked by login dialog, trying to log in manually...'); })
|
|
.then(() => page.fill('input[name="password"]', opt.credentials[1], {timeout: 0}))
|
|
.then(() => page.fill('input[name="password"]', opt.credentials[1], {timeout: 0}))
|
|
.then(() => page.click('button[type="submit"]', {timeout: 0}))
|
|
.then(() => page.click('button[type="submit"]', {timeout: 0}))
|
|
@@ -537,7 +541,7 @@ export default class {
|
|
fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
|
|
fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
|
|
});
|
|
});
|
|
|
|
|
|
- return Promise.race([promise, promisify(setTimeout)(promiseDelay * 3)]);
|
|
|
|
|
|
+ return Promise.race([promise, isWaitingForLogin ? neverResolves() : promisify(setTimeout)(promiseDelay * 3)]);
|
|
}))
|
|
}))
|
|
))
|
|
))
|
|
.then(() => {
|
|
.then(() => {
|