|
@@ -11,7 +11,7 @@ import {
|
|
} from 'instagram-id-to-url-segment';
|
|
} from 'instagram-id-to-url-segment';
|
|
import {
|
|
import {
|
|
IgApiClient,
|
|
IgApiClient,
|
|
- IgClientError, IgExactUserNotFoundError, IgLoginRequiredError, IgLoginTwoFactorRequiredError, IgResponseError,
|
|
|
|
|
|
+ IgClientError, IgCookieNotFoundError, IgExactUserNotFoundError, IgLoginRequiredError, IgLoginTwoFactorRequiredError, IgResponseError,
|
|
MediaInfoResponseItemsItem, UserFeedResponseItemsItem
|
|
MediaInfoResponseItemsItem, UserFeedResponseItemsItem
|
|
} from 'instagram-private-api';
|
|
} from 'instagram-private-api';
|
|
import { SocksProxyAgent } from 'socks-proxy-agent';
|
|
import { SocksProxyAgent } from 'socks-proxy-agent';
|
|
@@ -386,7 +386,14 @@ export default class {
|
|
}
|
|
}
|
|
lazyMedia.item = () => Promise.resolve(mediaItem);
|
|
lazyMedia.item = () => Promise.resolve(mediaItem);
|
|
this.workOnMedia([lazyMedia], this.sendMedia(`instagram media ${segmentId}`, receiver));
|
|
this.workOnMedia([lazyMedia], this.sendMedia(`instagram media ${segmentId}`, receiver));
|
|
- }).catch((err: IgClientError) => { this.bot.sendTo(receiver, parseMediaError(err)); });
|
|
|
|
|
|
+ }).catch((err: IgClientError) => {
|
|
|
|
+ this.bot.sendTo(receiver, parseMediaError(err));
|
|
|
|
+ if (err instanceof IgLoginRequiredError || err instanceof IgCookieNotFoundError) {
|
|
|
|
+ logger.warn('login required, awaiting login...');
|
|
|
|
+ this.bot.sendTo(receiver, '等待登陆中,稍后会处理请求,请稍候……');
|
|
|
|
+ return this.session.login().then(() => sendPost(segmentId, receiver));
|
|
|
|
+ };
|
|
|
|
+ });
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -486,7 +493,7 @@ export default class {
|
|
|
|
|
|
public queryUser = (username: string) => this.client.user.searchExact(username)
|
|
public queryUser = (username: string) => this.client.user.searchExact(username)
|
|
.catch((error: IgClientError) => {
|
|
.catch((error: IgClientError) => {
|
|
- if (error instanceof IgLoginRequiredError) {
|
|
|
|
|
|
+ if (error instanceof IgLoginRequiredError || error instanceof IgCookieNotFoundError) {
|
|
logger.warn('login required, logging in again...');
|
|
logger.warn('login required, logging in again...');
|
|
return this.session.login().then(() => this.client.user.searchExact(username));
|
|
return this.session.login().then(() => this.client.user.searchExact(username));
|
|
} else throw error;
|
|
} else throw error;
|