()
| 149 | } |
| 150 | } |
| 151 | async function initializeSession() { |
| 152 | ensureSessionDirectory(); |
| 153 | const txt = config.sessionId; |
| 154 | if (!txt) { |
| 155 | if (hasValidSession()) { |
| 156 | printLog('success', 'Existing session found. Using saved credentials'); |
| 157 | return true; |
| 158 | } |
| 159 | return false; |
| 160 | } |
| 161 | if (hasValidSession()) |
| 162 | return true; |
| 163 | try { |
| 164 | await SaveCreds(txt); |
| 165 | await delay(2000); |
| 166 | if (hasValidSession()) { |
| 167 | printLog('success', 'Session file verified and valid'); |
| 168 | await delay(1000); |
| 169 | return true; |
| 170 | } |
| 171 | else { |
| 172 | printLog('error', 'Session file not valid after download'); |
| 173 | return false; |
| 174 | } |
| 175 | } |
| 176 | catch (error) { |
| 177 | printLog('error', `Error downloading session: ${error.message}`); |
| 178 | return false; |
| 179 | } |
| 180 | } |
| 181 | server.listen(PORT, () => { |
| 182 | printLog('success', `Server listening on port ${PORT}`); |
| 183 | }); |
no test coverage detected