|
1 | 1 | import enquirer from 'enquirer';
|
2 | 2 | import { JSONFileSyncPreset } from 'lowdb/node';
|
3 | 3 | import { setupNewAccount } from './onboarding.js';
|
4 |
| -import { Config, defaultConfig } from './util/config-schema.js'; |
| 4 | +import { |
| 5 | + Config, |
| 6 | + defaultConfig, |
| 7 | + defaultMuskEmpireAccount, |
| 8 | + MuskEmpireAccount, |
| 9 | +} from './util/config-schema.js'; |
5 | 10 | import { startHeartbeat } from 'modules/heartbeat.js';
|
6 | 11 | import axios from 'axios';
|
7 | 12 | import * as process from 'node:process';
|
8 |
| -export const storage = JSONFileSyncPreset<Config>('config.json', defaultConfig); |
| 13 | + |
| 14 | +export const storage = JSONFileSyncPreset<Config>( |
| 15 | + process.env.CONFIG_PATH + 'config.json', |
| 16 | + defaultConfig |
| 17 | +); |
| 18 | +// storage.update((data) => { |
| 19 | +// Object.entries(data.accounts).forEach(([key, account]) => { |
| 20 | +// Object.keys(defaultMuskEmpireAccount).forEach((defaultKey) => { |
| 21 | +// const keyOfAccount = defaultKey as keyof MuskEmpireAccount; |
| 22 | +// |
| 23 | +// // Check if the current key is undefined in the account |
| 24 | +// if (account[keyOfAccount] === undefined) { |
| 25 | +// // If undefined, assign the value from defaultMuskEmpireAccounts |
| 26 | +// account[keyOfAccount] = defaultMuskEmpireAccount[ |
| 27 | +// keyOfAccount |
| 28 | +// ] as any; |
| 29 | +// } |
| 30 | +// }); |
| 31 | +// // Update the account in storage |
| 32 | +// data.accounts[key] = account; |
| 33 | +// }); |
| 34 | +// }); |
| 35 | + |
9 | 36 | if (!storage.data.accounts) {
|
10 | 37 | await setupNewAccount(true);
|
11 | 38 | }
|
| 39 | + |
12 | 40 | axios.interceptors.response.use(
|
13 | 41 | function (response) {
|
14 | 42 | // Any status code that lie within the range of 2xx cause this function to trigger
|
@@ -47,6 +75,7 @@ const menuResponse = !!process.env.ACTION
|
47 | 75 |
|
48 | 76 | switch (menuResponse.action) {
|
49 | 77 | case 'run':
|
| 78 | + console.log('запуск бота'); |
50 | 79 | await startHeartbeat();
|
51 | 80 | break;
|
52 | 81 | case 'add':
|
|
0 commit comments