Prioritize conversation replies
This commit is contained in:
1 parent
f55ae7ddf8
commit
9b86cee9be
13 files changed
+535
-39
No files matched your search
@@ -265,8 +265,10 @@ class AccountRuntimeLoop {
|
||||
}
|
||||
|
||||
private async run(signal: AbortSignal): Promise<void> {
|
||||
let nextResponseCheckAt = 0;
|
||||
const responseInterval = Math.max(this.config.reddit.pollIntervalMs * 5, 60_000);
|
||||
let nextReplyCheckAt = 0;
|
||||
let nextPerformanceCheckAt = 0;
|
||||
const replyInterval = 30_000;
|
||||
const performanceInterval = Math.max(this.config.reddit.pollIntervalMs * 5, 60_000);
|
||||
while (!signal.aborted) {
|
||||
try {
|
||||
if (!this.isBotRunning()) {
|
||||
@@ -278,9 +280,8 @@ class AccountRuntimeLoop {
|
||||
await delay(1_000, signal);
|
||||
continue;
|
||||
}
|
||||
if (Date.now() >= nextResponseCheckAt) {
|
||||
nextResponseCheckAt = Date.now() + responseInterval;
|
||||
await this.resources.responseChecker.checkForResponses();
|
||||
if (Date.now() >= nextReplyCheckAt) {
|
||||
nextReplyCheckAt = Date.now() + replyInterval;
|
||||
const automationResults = await this.resources.conversationAutomation.processUnreadConversations(signal);
|
||||
for (const result of automationResults) {
|
||||
if (result.kind === 'sent') continue;
|
||||
@@ -296,7 +297,11 @@ class AccountRuntimeLoop {
|
||||
});
|
||||
}
|
||||
}
|
||||
await delay(this.config.reddit.pollIntervalMs, signal);
|
||||
if (Date.now() >= nextPerformanceCheckAt) {
|
||||
nextPerformanceCheckAt = Date.now() + performanceInterval;
|
||||
await this.resources.responseChecker.checkForResponses();
|
||||
}
|
||||
await delay(5_000, signal);
|
||||
} catch (error) {
|
||||
if (signal.aborted) return;
|
||||
if (error instanceof RedditRateLimitError) {
|
||||
|
||||
Reference in new issue
Block a user