@@ -15,11 +15,14 @@ const require = createRequire(__dirname)
1515const { say } = cfonts
1616const rl = createInterface ( process . stdin , process . stdout )
1717
18- function isWIBMidnight ( ) {
18+ function getWIBTime ( ) {
1919 const now = new Date ( )
2020 const utc = now . getTime ( ) + now . getTimezoneOffset ( ) * 60000
21- const wib = new Date ( utc + 7 * 3600000 )
22- return wib . getHours ( ) === 0
21+ return new Date ( utc + 7 * 3600000 )
22+ }
23+
24+ function isWIBMidnight ( ) {
25+ return getWIBTime ( ) . getHours ( ) === 0
2326}
2427
2528async function runUpdater ( ) {
@@ -38,11 +41,22 @@ async function runUpdater() {
3841 const updaterPath = new URL ( './lib/system.js' , import . meta. url )
3942 const { default : checkUpdate } = await import ( updaterPath )
4043
41- if ( global . config . cekupdate && isWIBMidnight ( ) ) {
42- await checkUpdate ( )
43- } else {
44+ logs . push ( {
45+ waktu : new Date ( ) . toLocaleTimeString ( ) ,
46+ pesan : 'NODE CHECK START'
47+ } )
48+
49+ await checkUpdate ( )
50+
51+ logs . push ( {
52+ waktu : new Date ( ) . toLocaleTimeString ( ) ,
53+ pesan : 'NODE CHECK OK'
54+ } )
55+
56+ if ( global . config . cekupdate === true && isWIBMidnight ( ) ) {
4457 await checkUpdate ( )
4558 }
59+
4660 } catch ( e ) {
4761 logs . push ( {
4862 waktu : new Date ( ) . toLocaleTimeString ( ) ,
@@ -53,11 +67,9 @@ async function runUpdater() {
5367
5468 console . log = originalLog
5569
56- if ( logs . length ) {
57- originalLog ( '\n=== UPDATE LOG TABLE ===' )
58- console . table ( logs )
59- originalLog ( '=== END UPDATE LOG ===\n' )
60- }
70+ originalLog ( '\n=== UPDATE LOG TABLE ===' )
71+ console . table ( logs )
72+ originalLog ( '=== END UPDATE LOG ===\n' )
6173}
6274
6375say ( global . config . namebot , {
@@ -146,10 +158,10 @@ function start(file) {
146158
147159async function countdown ( sec ) {
148160 for ( let i = sec ; i >= 1 ; i -- ) {
149- process . stdout . write ( `\r ⏳ Starting in ${ i } ... `)
161+ console . log ( ` ⏳ Starting in ${ i } ...`)
150162 await new Promise ( r => setTimeout ( r , 1000 ) )
151163 }
152- console . log ( '\n ' )
164+ console . log ( '' )
153165}
154166
155167await runUpdater ( )
0 commit comments