|
@@ -66,7 +66,7 @@ class SessionManager {
|
|
logger.warn('attempting to retry after 1 minute...');
|
|
logger.warn('attempting to retry after 1 minute...');
|
|
if (fs.existsSync(filePath))
|
|
if (fs.existsSync(filePath))
|
|
fs.unlinkSync(filePath);
|
|
fs.unlinkSync(filePath);
|
|
- util_1.promisify(setTimeout)(60000).then(this.init);
|
|
|
|
|
|
+ (0, util_1.promisify)(setTimeout)(60000).then(this.init);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -76,7 +76,7 @@ class SessionManager {
|
|
logger.info(`/confirm-2fa?code=<the code you received>&token=${token}`);
|
|
logger.info(`/confirm-2fa?code=<the code you received>&token=${token}`);
|
|
let working;
|
|
let working;
|
|
const server = http.createServer((req, res) => {
|
|
const server = http.createServer((req, res) => {
|
|
- const { pathname, query } = url_1.parse(req.url, true);
|
|
|
|
|
|
+ const { pathname, query } = (0, url_1.parse)(req.url, true);
|
|
if (!working && pathname === '/confirm-2fa' && query.token === token &&
|
|
if (!working && pathname === '/confirm-2fa' && query.token === token &&
|
|
typeof (query.code) === 'string' && /^\d{6}$/.test(query.code)) {
|
|
typeof (query.code) === 'string' && /^\d{6}$/.test(query.code)) {
|
|
const code = query.code;
|
|
const code = query.code;
|
|
@@ -153,7 +153,7 @@ let sendAllStories = (username, receiver, startIndex, count) => {
|
|
throw Error();
|
|
throw Error();
|
|
};
|
|
};
|
|
exports.sendAllStories = sendAllStories;
|
|
exports.sendAllStories = sendAllStories;
|
|
-const logger = loggers_1.getLogger('instagram');
|
|
|
|
|
|
+const logger = (0, loggers_1.getLogger)('instagram');
|
|
const maxTrials = 3;
|
|
const maxTrials = 3;
|
|
const retryInterval = 1500;
|
|
const retryInterval = 1500;
|
|
const ordinal = (n) => {
|
|
const ordinal = (n) => {
|
|
@@ -233,7 +233,7 @@ class default_1 {
|
|
if (this.isInactiveTime)
|
|
if (this.isInactiveTime)
|
|
return;
|
|
return;
|
|
logger.debug(`current cache: ${JSON.stringify(this.cache)}`);
|
|
logger.debug(`current cache: ${JSON.stringify(this.cache)}`);
|
|
- utils_1.chainPromises(Object.entries(this.lock.threads).map(([feed, thread]) => () => {
|
|
|
|
|
|
+ (0, utils_1.chainPromises)(Object.entries(this.lock.threads).map(([feed, thread]) => () => {
|
|
const id = thread.id;
|
|
const id = thread.id;
|
|
const userName = parseLink(feed).userName;
|
|
const userName = parseLink(feed).userName;
|
|
logger.debug(`preparing to add user @${userName} to next pull task...`);
|
|
logger.debug(`preparing to add user @${userName} to next pull task...`);
|
|
@@ -243,7 +243,7 @@ class default_1 {
|
|
item.pullOrder = -1;
|
|
item.pullOrder = -1;
|
|
return Promise.resolve();
|
|
return Promise.resolve();
|
|
}
|
|
}
|
|
- return util_1.promisify(setTimeout)((Math.random() * 2 + 1) * 5000).then(() => this.client.user.info(id).then(({ pk, username, full_name }) => {
|
|
|
|
|
|
+ return (0, util_1.promisify)(setTimeout)((Math.random() * 2 + 1) * 5000).then(() => this.client.user.info(id).then(({ pk, username, full_name }) => {
|
|
this.cache[id] = { user: { pk, username, full_name }, stories: {}, pullOrder: -1 };
|
|
this.cache[id] = { user: { pk, username, full_name }, stories: {}, pullOrder: -1 };
|
|
fs.writeFileSync(path.resolve(this.cachefile), JSON.stringify(this.cache));
|
|
fs.writeFileSync(path.resolve(this.cachefile), JSON.stringify(this.cache));
|
|
logger.info(`initialized cache item for user ${full_name} (@${username})`);
|
|
logger.info(`initialized cache item for user ${full_name} (@${username})`);
|
|
@@ -253,10 +253,10 @@ class default_1 {
|
|
const userIdCache = Object.values(this.cache).some(item => item.pullOrder < 0) ?
|
|
const userIdCache = Object.values(this.cache).some(item => item.pullOrder < 0) ?
|
|
this.pullOrders = utils_1.Arr.shuffle(Object.keys(this.cache)).map(Number) :
|
|
this.pullOrders = utils_1.Arr.shuffle(Object.keys(this.cache)).map(Number) :
|
|
this.pullOrders;
|
|
this.pullOrders;
|
|
- return utils_1.chainPromises(utils_1.Arr.chunk(userIdCache, 20).map(userIds => () => {
|
|
|
|
|
|
+ return (0, utils_1.chainPromises)(utils_1.Arr.chunk(userIdCache, 20).map(userIds => () => {
|
|
logger.info(`pulling stories from users:${userIds.map(id => ` @${this.cache[id].user.username}`)}`);
|
|
logger.info(`pulling stories from users:${userIds.map(id => ` @${this.cache[id].user.username}`)}`);
|
|
return this.client.feed.reelsMedia({ userIds }).request()
|
|
return this.client.feed.reelsMedia({ userIds }).request()
|
|
- .then(({ reels }) => utils_1.chainPromises(Object.keys(reels).map(userId => this.cache[userId]).map(({ user, stories }) => () => this.queryUserObject(user.username)
|
|
|
|
|
|
+ .then(({ reels }) => (0, utils_1.chainPromises)(Object.keys(reels).map(userId => this.cache[userId]).map(({ user, stories }) => () => this.queryUserObject(user.username)
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
if (error instanceof instagram_private_api_1.IgExactUserNotFoundError) {
|
|
if (error instanceof instagram_private_api_1.IgExactUserNotFoundError) {
|
|
return this.client.user.info(user.pk)
|
|
return this.client.user.info(user.pk)
|
|
@@ -276,7 +276,7 @@ class default_1 {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- }), (lp1, lp2) => () => lp1().then(() => util_1.promisify(setTimeout)(this.workInterval * 1000 / this.lock.feed.length).then(lp2)));
|
|
|
|
|
|
+ }), (lp1, lp2) => () => lp1().then(() => (0, util_1.promisify)(setTimeout)(this.workInterval * 1000 / this.lock.feed.length).then(lp2)));
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
if (error instanceof instagram_private_api_1.IgNetworkError) {
|
|
if (error instanceof instagram_private_api_1.IgNetworkError) {
|
|
@@ -453,13 +453,13 @@ class default_1 {
|
|
.sort((i1, i2) => -utils_1.BigNumOps.compare(i2.pk, i1.pk));
|
|
.sort((i1, i2) => -utils_1.BigNumOps.compare(i2.pk, i1.pk));
|
|
if (storyItems.length === 0)
|
|
if (storyItems.length === 0)
|
|
return reply(`当前用户 (@${userName}) 没有可用的 Instagram 限时动态。`);
|
|
return reply(`当前用户 (@${userName}) 没有可用的 Instagram 限时动态。`);
|
|
- return reply('#. 编号:发送时间\n' + storyItems.map(({ original }, index) => `\n${index + 1}. ${original.pk}: ${datetime_1.relativeDate(original.taken_at * 1000)}`).join(''))
|
|
|
|
|
|
+ return reply('#. 编号:发送时间\n' + storyItems.map(({ original }, index) => `\n${index + 1}. ${original.pk}: ${(0, datetime_1.relativeDate)(original.taken_at * 1000)}`).join(''))
|
|
.then(() => reply(`请使用 /igstory_view ${userName} skip=<#-1> count=1
|
|
.then(() => reply(`请使用 /igstory_view ${userName} skip=<#-1> count=1
|
|
或 /igstory_view https://www.instagram.com/stories/${userName}/<编号>/
|
|
或 /igstory_view https://www.instagram.com/stories/${userName}/<编号>/
|
|
查看指定的限时动态。`));
|
|
查看指定的限时动态。`));
|
|
},
|
|
},
|
|
reply,
|
|
reply,
|
|
- retryAction: () => exports.sendTimeline(rawUserName, receiver),
|
|
|
|
|
|
+ retryAction: () => (0, exports.sendTimeline)(rawUserName, receiver),
|
|
});
|
|
});
|
|
};
|
|
};
|
|
exports.sendStory = (rawUserName, storyId, receiver) => {
|
|
exports.sendStory = (rawUserName, storyId, receiver) => {
|
|
@@ -473,7 +473,7 @@ class default_1 {
|
|
return this.workOnMedia([this.cache[userId].stories[storyId]], sender);
|
|
return this.workOnMedia([this.cache[userId].stories[storyId]], sender);
|
|
},
|
|
},
|
|
reply,
|
|
reply,
|
|
- retryAction: () => exports.sendStory(rawUserName, storyId, receiver),
|
|
|
|
|
|
+ retryAction: () => (0, exports.sendStory)(rawUserName, storyId, receiver),
|
|
});
|
|
});
|
|
};
|
|
};
|
|
exports.sendAllStories = (rawUserName, receiver, startIndex = 0, count = 10) => {
|
|
exports.sendAllStories = (rawUserName, receiver, startIndex = 0, count = 10) => {
|
|
@@ -499,7 +499,7 @@ class default_1 {
|
|
.then(() => reply(`已显示当前用户 ${storyItems.length} 条可用限时动态中的第 ${sendRangeText} 条。`));
|
|
.then(() => reply(`已显示当前用户 ${storyItems.length} 条可用限时动态中的第 ${sendRangeText} 条。`));
|
|
},
|
|
},
|
|
reply,
|
|
reply,
|
|
- retryAction: () => exports.sendAllStories(rawUserName, receiver, startIndex, count)
|
|
|
|
|
|
+ retryAction: () => (0, exports.sendAllStories)(rawUserName, receiver, startIndex, count)
|
|
});
|
|
});
|
|
};
|
|
};
|
|
}
|
|
}
|