|
@@ -7,7 +7,7 @@ import { promisify } from 'util';
|
|
|
|
|
|
import {
|
|
|
IgApiClient,
|
|
|
- IgClientError, IgExactUserNotFoundError, IgLoginTwoFactorRequiredError, IgLoginRequiredError, IgNetworkError,
|
|
|
+ IgClientError, IgCookieNotFoundError, IgExactUserNotFoundError, IgLoginTwoFactorRequiredError, IgLoginRequiredError, IgNetworkError,
|
|
|
ReelsMediaFeedResponseItem, UserFeedResponseUser
|
|
|
} from 'instagram-private-api';
|
|
|
import { RequestError } from 'request-promise/errors';
|
|
@@ -286,8 +286,9 @@ export default class {
|
|
|
}
|
|
|
logger.warn(`error while fetching stories for ${rawUserName}: ${JSON.stringify(error.cause)}`);
|
|
|
this.bot.sendTo(receiver, `获取 Stories 时出现错误:原因: ${error.cause}`);
|
|
|
- } else if (error instanceof IgLoginRequiredError) {
|
|
|
+ } else if (error instanceof IgLoginRequiredError || error instanceof IgCookieNotFoundError) {
|
|
|
logger.warn('login required, logging in again...');
|
|
|
+ this.bot.sendTo(receiver, '等待登陆中,稍后会处理请求,请稍候……');
|
|
|
this.session.login().then(() => sendAllStories(rawUserName, receiver, startIndex, count));
|
|
|
} else {
|
|
|
logger.error(`unhandled error while fetching stories for ${rawUserName}: ${error}`);
|
|
@@ -319,7 +320,7 @@ export default class {
|
|
|
}
|
|
|
return this.client.user.searchExact(username)
|
|
|
.catch((error: IgClientError) => {
|
|
|
- if (error instanceof IgLoginRequiredError) {
|
|
|
+ if (error instanceof IgLoginRequiredError || error instanceof IgCookieNotFoundError) {
|
|
|
logger.warn('login required, logging in again...');
|
|
|
return this.session.login().then(() => this.client.user.searchExact(username));
|
|
|
} else throw error;
|
|
@@ -427,7 +428,7 @@ export default class {
|
|
|
return this.session.login().then(this.workForAll);
|
|
|
}
|
|
|
logger.warn(`error while fetching stories for all: ${JSON.stringify(error.cause)}`);
|
|
|
- } else if (error instanceof IgLoginRequiredError) {
|
|
|
+ } else if (error instanceof IgLoginRequiredError || error instanceof IgCookieNotFoundError) {
|
|
|
logger.warn('login required, logging in again...');
|
|
|
this.session.login().then(this.workForAll);
|
|
|
} else {
|