Skip to content

Commit 77754e9

Browse files
committed
feat: bug fixes and improvements
1 parent 2db1090 commit 77754e9

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

src/components/client.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,4 @@ client.on("auth_failure", (msg: string) => {
7575
log.error("Auth", "Authentication failed. Please try again.");
7676
});
7777

78-
client.initialize();
79-
8078
export { client };

src/components/phishtank.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ export default class PhishTankClient {
2727
private phishingSet: Set<string> = new Set();
2828
private autoUpdateTimer: NodeJS.Timeout | null = null;
2929

30-
constructor() {
31-
if (this.autoUpdateDaily && this.isPhishtankEnable)
32-
this.startAutoUpdateLoop();
33-
}
30+
constructor() {}
3431

3532
async init(): Promise<void> {
3633
if (!this.isPhishtankEnable) return;
@@ -171,7 +168,7 @@ export default class PhishTankClient {
171168
}
172169

173170
startAutoUpdateLoop() {
174-
if (this.autoUpdateTimer) return;
171+
if (this.autoUpdateDaily || this.autoUpdateTimer) return;
175172

176173
const scheduleNext = async () => {
177174
try {

src/components/process.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ process.on("exit", (code) => {
3232
console.log("");
3333
});
3434

35+
log.info("Bot", `Initiating ${process.env.PROJECT_CANIS_ALIAS || "Canis"}...`);
36+
log.info("Bot", `prefix: ${process.env.COMMAND_PREFIX || "!"}`);
3537
log.info("Process", "Event listeners for process signals have been set up.");

src/index.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ import { mapCommands } from "./components/utils/cmd/loader";
77
import watcher from "./components/utils/cmd/watcher";
88
import "./components/process";
99
import "./components/server";
10+
import { client } from "./components/client";
1011
import MemoryMonitor from "./components/utils/memMonitor";
1112
import PhishTankClient from "./components/phishtank";
1213

14+
const autoReload = process.env.AUTO_RELOAD === "true";
1315
const monitor = new MemoryMonitor({
1416
interval: 60000,
1517
thresholdMB: parseInt(process.env.PROJECT_THRESHOLD_MEMORY || "1024", 10),
1618
});
17-
18-
monitor.start();
19-
checkRequirements();
2019
const phishtank = new PhishTankClient();
21-
phishtank.init();
2220
const phishingSet: Set<string> = phishtank.getPhishingSet();
2321

24-
const commandPrefix = process.env.COMMAND_PREFIX || "!";
25-
const botName = process.env.PROJECT_CANIS_ALIAS || "Canis";
26-
const autoReload = process.env.AUTO_RELOAD === "true";
22+
async function main() {
23+
checkRequirements();
24+
monitor.start();
25+
phishtank.startAutoUpdateLoop();
26+
await phishtank.init();
27+
await client.initialize();
2728

28-
log.info("Bot", `Initiating ${botName}...`);
29-
log.info("Bot", `prefix: ${commandPrefix}`);
29+
mapCommands();
30+
// Watch for changes
31+
if (autoReload) watcher();
32+
}
3033

31-
mapCommands();
32-
// Watch for changes
33-
if (autoReload) watcher();
34+
main();
3435

3536
export { phishingSet };

0 commit comments

Comments
 (0)