File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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-
8078export { client } ;
Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 || "!" } ` ) ;
3537log . info ( "Process" , "Event listeners for process signals have been set up." ) ;
Original file line number Diff line number Diff line change @@ -7,29 +7,30 @@ import { mapCommands } from "./components/utils/cmd/loader";
77import watcher from "./components/utils/cmd/watcher" ;
88import "./components/process" ;
99import "./components/server" ;
10+ import { client } from "./components/client" ;
1011import MemoryMonitor from "./components/utils/memMonitor" ;
1112import PhishTankClient from "./components/phishtank" ;
1213
14+ const autoReload = process . env . AUTO_RELOAD === "true" ;
1315const monitor = new MemoryMonitor ( {
1416 interval : 60000 ,
1517 thresholdMB : parseInt ( process . env . PROJECT_THRESHOLD_MEMORY || "1024" , 10 ) ,
1618} ) ;
17-
18- monitor . start ( ) ;
19- checkRequirements ( ) ;
2019const phishtank = new PhishTankClient ( ) ;
21- phishtank . init ( ) ;
2220const 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
3536export { phishingSet } ;
You can’t perform that action at this time.
0 commit comments