|
@@ -247,7 +247,8 @@ export default class {
|
|
|
this.queryUser(rawUserName)
|
|
|
.then(userNameId => {
|
|
|
const [userName, userId] = userNameId.split(':');
|
|
|
- if (userName in this.cache && Object.keys(this.cache[userName].stories).length > 0) {
|
|
|
+ if (Date.now() - this.cache[userName]?.updated?.getTime() > this.workInterval * 10000 &&
|
|
|
+ Object.keys(this.cache[userName].stories).length > 0) {
|
|
|
return Promise.resolve(
|
|
|
Object.values(this.cache[userName].stories)
|
|
|
.map(story => ({...story, user: this.cache[userName].user}))
|
|
@@ -262,6 +263,7 @@ export default class {
|
|
|
this.cache[userName].stories[item.pk] = item;
|
|
|
}
|
|
|
});
|
|
|
+ this.cache[userName].updated = new Date();
|
|
|
if (storyItems.length === 0) this.bot.sendTo(receiver, `当前用户 (@${userName}) 没有可用的推特故事。`);
|
|
|
return storyItems;
|
|
|
});
|
|
@@ -336,6 +338,7 @@ export default class {
|
|
|
user: UserFeedResponseUser & ReelsMediaFeedResponseItem['user'],
|
|
|
stories: {[storyId: string]: MediaItem},
|
|
|
pullOrder: number, // one-based; -1: subscribed, awaiting shuffle; 0: not subscribed
|
|
|
+ updated?: Date,
|
|
|
},
|
|
|
} = {};
|
|
|
|
|
@@ -385,7 +388,9 @@ export default class {
|
|
|
}
|
|
|
}))
|
|
|
.finally(() => Object.values(this.lock.threads).forEach(thread => {
|
|
|
- if (userIds.includes(thread.id)) thread.updatedAt = new Date().toString();
|
|
|
+ if (userIds.includes(thread.id)) {
|
|
|
+ thread.updatedAt = (this.cache[idToUserMap[thread.id].username].updated = new Date()).toString();
|
|
|
+ }
|
|
|
}));
|
|
|
}),
|
|
|
(lp1, lp2) => () => lp1().then(() => promisify(setTimeout)(this.workInterval * 1000).then(lp2))
|