|
@@ -389,12 +389,10 @@ export default class {
|
|
this.pullOrders = Arr.shuffle(userIdCache);
|
|
this.pullOrders = Arr.shuffle(userIdCache);
|
|
fs.writeFileSync(path.resolve(this.cachefile), JSON.stringify(this.cache));
|
|
fs.writeFileSync(path.resolve(this.cachefile), JSON.stringify(this.cache));
|
|
}
|
|
}
|
|
- setTimeout(this.workForAll, this.workInterval * 1000 / this.lock.feed.length);
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.work();
|
|
|
|
- setInterval(() => { this.pullOrders = Arr.shuffle(this.pullOrders); }, 21600000);
|
|
|
|
- setInterval(this.workForAll, this.workInterval * 1000);
|
|
|
|
- }, this.workInterval * 1200 / this.lock.feed.length);
|
|
|
|
|
|
+ const timeout = this.workInterval * 1000 / this.lock.feed.length;
|
|
|
|
+ setInterval(() => { this.pullOrders = Arr.shuffle(this.pullOrders); }, 21600000);
|
|
|
|
+ setTimeout(this.workForAll, timeout);
|
|
|
|
+ setTimeout(this.work, timeout * 1.2);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
};
|
|
};
|
|
@@ -529,7 +527,10 @@ export default class {
|
|
} else {
|
|
} else {
|
|
logger.error(`unhandled error on fetching media for all: ${error}`);
|
|
logger.error(`unhandled error on fetching media for all: ${error}`);
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ })
|
|
|
|
+ .then(() => {
|
|
|
|
+ setTimeout(this.workForAll, this.workInterval * 1000);
|
|
|
|
+ })
|
|
};
|
|
};
|
|
|
|
|
|
public get isInactiveTime() {
|
|
public get isInactiveTime() {
|
|
@@ -589,25 +590,26 @@ export default class {
|
|
const currentThread = lock.threads[currentFeed];
|
|
const currentThread = lock.threads[currentFeed];
|
|
|
|
|
|
if (!mediaItems || mediaItems.length === 0) return;
|
|
if (!mediaItems || mediaItems.length === 0) return;
|
|
-
|
|
|
|
- const question = mediaItems.find(story => story.original.story_questions);
|
|
|
|
- const topOfFeed = question? question.pk : mediaItems[0].pk;
|
|
|
|
- const updateOffset = () => currentThread.offset = topOfFeed;
|
|
|
|
|
|
+ const updateOffset = () => currentThread.offset = mediaItems[0].pk;
|
|
|
|
|
|
if (currentThread.offset === '-1') { updateOffset(); return; }
|
|
if (currentThread.offset === '-1') { updateOffset(); return; }
|
|
|
|
+
|
|
|
|
+ const questionIndex = mediaItems.findIndex(story => story.original.story_questions);
|
|
|
|
+ if (questionIndex > -1) mediaItems.splice(0, questionIndex);
|
|
if (currentThread.offset === '0') mediaItems.splice(1);
|
|
if (currentThread.offset === '0') mediaItems.splice(1);
|
|
|
|
|
|
return this.workOnMedia(mediaItems.reverse(), this.sendStories(`thread ${currentFeed}`, ...currentThread.subscribers))
|
|
return this.workOnMedia(mediaItems.reverse(), this.sendStories(`thread ${currentFeed}`, ...currentThread.subscribers))
|
|
.then(updateOffset)
|
|
.then(updateOffset)
|
|
.then(() => {
|
|
.then(() => {
|
|
- if (question) {
|
|
|
|
|
|
+ if (questionIndex > -1) {
|
|
currentThread.subscribers.forEach(subscriber => {
|
|
currentThread.subscribers.forEach(subscriber => {
|
|
const username = cachedFeed.user.username;
|
|
const username = cachedFeed.user.username;
|
|
const author = `${cachedFeed.user.full_name} (@${username}) `;
|
|
const author = `${cachedFeed.user.full_name} (@${username}) `;
|
|
this.bot.sendTo(subscriber,
|
|
this.bot.sendTo(subscriber,
|
|
`请注意,用户${author}已开启问答互动。需退订请回复:/igstory_unsub ${username}${
|
|
`请注意,用户${author}已开启问答互动。需退订请回复:/igstory_unsub ${username}${
|
|
- Object.keys(cachedFeed.stories).some(id => id > topOfFeed) ?
|
|
|
|
- `\n本次推送已截止于此条动态,下次推送在 ${Math.floor(this.workInterval / lock.feed.length)} 秒后。` : ''}`);
|
|
|
|
|
|
+ (questionIndex > 0) ? `\n本次推送已截止于此条动态,下次推送在 ${this.workInterval} 秒后。` : ''
|
|
|
|
+ }`
|
|
|
|
+ );
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|