Skip to content

Commit

Permalink
Revert "Add ping to keep bot connection alive"
Browse files Browse the repository at this point in the history
This reverts commit 1e7a443.
  • Loading branch information
SleeplessOne1917 committed Apr 25, 2023
1 parent 8399e71 commit 5ea308c
Showing 1 changed file with 1 addition and 27 deletions.
28 changes: 1 addition & 27 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,8 +571,6 @@ class LemmyBot {
? 1
: minutesBeforeRetryConnection;

const handlerOptions = parseHandlers(handlers);

const {
comment: commentOptions,
post: postOptions,
Expand All @@ -593,7 +591,7 @@ class LemmyBot {
modTransferCommunity: modTransferCommunityOptions,
modAddAdmin: modAddAdminOptions,
modBanFromSite: modBanFromSiteOptions
} = handlerOptions;
} = parseHandlers(handlers);

client.on('connectFailed', () => {
if (!this.#isSecureConnection) {
Expand Down Expand Up @@ -1466,16 +1464,6 @@ class LemmyBot {
}
};

if (
defaultSecondsBetweenPolls > 10 &&
Object.values(handlerOptions).every(
({ secondsBetweenPolls }) =>
!secondsBetweenPolls || secondsBetweenPolls > 10
)
) {
this.#ping();
}

await runBot();
});
}
Expand Down Expand Up @@ -1677,20 +1665,6 @@ class LemmyBot {
}, 1000 * 60 * minutesBeforeRetry);
this.#timeouts.push(timeout);
}

#ping() {
const pingTimeout = setTimeout(() => {
if (this.#connection?.connected) {
this.#connection.ping('Keep me alive!');
this.#ping();
}

this.#timeouts = this.#timeouts.filter((t) => t !== pingTimeout);
clearTimeout(pingTimeout);
}, 10000);

this.#timeouts.push(pingTimeout);
}
}

export default LemmyBot;

0 comments on commit 5ea308c

Please sign in to comment.