|
@@ -280,6 +280,10 @@ export default class {
|
|
|
this.bot.sendTo(receiver, `找不到用户 ${rawUserName.replace(/^@?(.*)$/, '@$1')}。`);
|
|
|
}
|
|
|
if (error instanceof IgNetworkError) {
|
|
|
+ if ((error.cause as Error).message === "Unexpected '<'") {
|
|
|
+ logger.warn('login required, logging in again...');
|
|
|
+ return this.session.login().then(() => sendAllStories(rawUserName, receiver, startIndex, count));
|
|
|
+ }
|
|
|
logger.warn(`error while fetching stories for ${rawUserName}: ${JSON.stringify(error.cause)}`);
|
|
|
this.bot.sendTo(receiver, `获取 Stories 时出现错误:原因: ${error.cause}`);
|
|
|
} else if (error instanceof IgLoginRequiredError) {
|
|
@@ -314,6 +318,12 @@ export default class {
|
|
|
return Promise.resolve(`${username}:${this.cache[username].user.pk}`);
|
|
|
}
|
|
|
return this.client.user.searchExact(username)
|
|
|
+ .catch((error: IgClientError) => {
|
|
|
+ if (error instanceof IgLoginRequiredError) {
|
|
|
+ logger.warn('login required, logging in again...');
|
|
|
+ return this.session.login().then(() => this.client.user.searchExact(username));
|
|
|
+ } else throw error;
|
|
|
+ })
|
|
|
.then(user => {
|
|
|
logger.info(`initialized cache item for user ${user.full_name} (@${username})`);
|
|
|
this.cache[user.username] = {user, stories: {}, pullOrder: 0};
|
|
@@ -412,6 +422,10 @@ export default class {
|
|
|
})
|
|
|
.catch((error: IgClientError & Partial<RequestError>) => {
|
|
|
if (error instanceof IgNetworkError) {
|
|
|
+ if ((error.cause as Error).message === "Unexpected '<'") {
|
|
|
+ logger.warn('login required, logging in again...');
|
|
|
+ return this.session.login().then(this.workForAll);
|
|
|
+ }
|
|
|
logger.warn(`error while fetching stories for all: ${JSON.stringify(error.cause)}`);
|
|
|
} else if (error instanceof IgLoginRequiredError) {
|
|
|
logger.warn('login required, logging in again...');
|