natureco-cli 5.4.20 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -2
- package/src/commands/channel-helper.js +51 -0
- package/src/commands/discord.js +116 -114
- package/src/commands/gateway-server.js +2107 -1977
- package/src/commands/imessage.js +2 -0
- package/src/commands/signal.js +2 -0
- package/src/commands/slack.js +121 -119
- package/src/commands/telegram.js +21 -2
- package/src/commands/whatsapp.js +318 -316
- package/src/utils/api.js +1158 -1054
- package/src/utils/tools.js +27 -8
package/src/commands/imessage.js
CHANGED
|
@@ -4,6 +4,8 @@ const { getConfig, saveConfig } = require('../utils/config');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
const { execSync } = require('child_process');
|
|
6
6
|
|
|
7
|
+
const { checkExistingToken } = require('./channel-helper');
|
|
8
|
+
|
|
7
9
|
async function imessage(action) {
|
|
8
10
|
if (!action || action === 'connect') return connectImessage();
|
|
9
11
|
if (action === 'disconnect') return disconnectImessage();
|
package/src/commands/signal.js
CHANGED
|
@@ -11,6 +11,8 @@ const SIGNAL_PID_FILE = path.join(SIGNAL_DIR, 'daemon.pid');
|
|
|
11
11
|
const SIGNAL_LOG_FILE = path.join(SIGNAL_DIR, 'daemon.log');
|
|
12
12
|
const SIGNAL_CLI_VERSION = '0.13.6';
|
|
13
13
|
|
|
14
|
+
const { checkExistingToken } = require('./channel-helper');
|
|
15
|
+
|
|
14
16
|
async function signal(action, subAction) {
|
|
15
17
|
if (!action || action === 'connect') return connectSignal();
|
|
16
18
|
if (action === 'disconnect') return disconnectSignal();
|
package/src/commands/slack.js
CHANGED
|
@@ -1,119 +1,121 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
|
-
const { getApiKey, getConfig, saveConfig } = require('../utils/config');
|
|
4
|
-
const { getBots } = require('../utils/api');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
config.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log(chalk.
|
|
62
|
-
console.log(chalk.
|
|
63
|
-
console.log(chalk.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
console.log(chalk.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
|
+
const { getApiKey, getConfig, saveConfig } = require('../utils/config');
|
|
4
|
+
const { getBots } = require('../utils/api');
|
|
5
|
+
|
|
6
|
+
const { checkExistingToken } = require('./channel-helper');
|
|
7
|
+
|
|
8
|
+
async function slack(action) {
|
|
9
|
+
if (!action || action === 'connect') {
|
|
10
|
+
return connectSlack();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (action === 'disconnect') {
|
|
14
|
+
return disconnectSlack();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (action === 'status') {
|
|
18
|
+
return statusSlack();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
console.log(chalk.red('\n❌ Unknown action\n'));
|
|
22
|
+
console.log(chalk.gray('Available actions: connect, disconnect, status\n'));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function connectSlack() {
|
|
27
|
+
const config = getConfig();
|
|
28
|
+
|
|
29
|
+
if (!config.providerUrl) {
|
|
30
|
+
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
process.stdin.resume();
|
|
35
|
+
|
|
36
|
+
const answers = await inquirer.prompt([
|
|
37
|
+
{
|
|
38
|
+
type: 'input',
|
|
39
|
+
name: 'token',
|
|
40
|
+
message: 'Slack bot token (starts with xoxb-):',
|
|
41
|
+
validate: (val) => {
|
|
42
|
+
const trimmed = val.trim();
|
|
43
|
+
if (trimmed === '') return 'Token cannot be empty';
|
|
44
|
+
if (!trimmed.startsWith('xoxb-')) return 'Slack bot token must start with xoxb-';
|
|
45
|
+
return true;
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
// Slack için bot ID oluştur (timestamp-based)
|
|
51
|
+
const botId = `slack_${Date.now()}`;
|
|
52
|
+
const selectedBot = { name: 'Slack Bot', id: botId };
|
|
53
|
+
|
|
54
|
+
console.log(chalk.yellow('\n⏳ Slack bağlantısı kaydediliyor...\n'));
|
|
55
|
+
|
|
56
|
+
// Save to config (v2.x - no backend call)
|
|
57
|
+
config.slackToken = answers.token.trim();
|
|
58
|
+
config.slackBotId = botId;
|
|
59
|
+
saveConfig(config);
|
|
60
|
+
|
|
61
|
+
console.log(chalk.green('✅ Slack token kaydedildi!\n'));
|
|
62
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
63
|
+
console.log(chalk.cyan('Token:'), chalk.white(answers.token.slice(0, 20) + '...'));
|
|
64
|
+
console.log(chalk.gray('\nNot: Slack botunuzu Slack App settings\'ten yapılandırmanız gerekiyor.'));
|
|
65
|
+
console.log(chalk.gray('Token config\'e kaydedildi: ~/.natureco/config.json\n'));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
async function disconnectSlack() {
|
|
69
|
+
const config = getConfig();
|
|
70
|
+
|
|
71
|
+
if (!config.slackToken) {
|
|
72
|
+
console.log(chalk.gray('\n⚠️ No Slack connection found\n'));
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
process.stdin.resume();
|
|
77
|
+
|
|
78
|
+
const { confirm } = await inquirer.prompt([
|
|
79
|
+
{
|
|
80
|
+
type: 'confirm',
|
|
81
|
+
name: 'confirm',
|
|
82
|
+
message: 'Are you sure you want to disconnect Slack?',
|
|
83
|
+
default: false,
|
|
84
|
+
},
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
if (!confirm) {
|
|
88
|
+
console.log(chalk.gray('\nCancelled\n'));
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Remove from config
|
|
93
|
+
delete config.slackToken;
|
|
94
|
+
delete config.slackBotId;
|
|
95
|
+
saveConfig(config);
|
|
96
|
+
|
|
97
|
+
console.log(chalk.green('\n✅ Slack disconnected\n'));
|
|
98
|
+
console.log(chalk.gray('Note: The bot is still registered on Slack.'));
|
|
99
|
+
console.log(chalk.gray('You may need to manually remove it from Slack App settings.\n'));
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function statusSlack() {
|
|
103
|
+
const config = getConfig();
|
|
104
|
+
|
|
105
|
+
if (!config.slackToken) {
|
|
106
|
+
console.log(chalk.gray('\n⚠️ Slack not connected\n'));
|
|
107
|
+
console.log(chalk.gray('Connect with: natureco slack connect\n'));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
console.log(chalk.green('\n✅ Slack connected\n'));
|
|
112
|
+
console.log(chalk.cyan('Token:'), chalk.white(config.slackToken.slice(0, 20) + '...'));
|
|
113
|
+
|
|
114
|
+
if (config.slackBotId) {
|
|
115
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(config.slackBotId));
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
console.log(chalk.gray('\nDisconnect with: natureco slack disconnect\n'));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
module.exports = slack;
|
package/src/commands/telegram.js
CHANGED
|
@@ -31,12 +31,31 @@ async function telegram(action, chatId) {
|
|
|
31
31
|
|
|
32
32
|
async function connectTelegram() {
|
|
33
33
|
const config = getConfig();
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
if (!config.providerUrl) {
|
|
36
36
|
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
37
37
|
process.exit(1);
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
// v5.4.21: Eğer zaten token kaydedilmişse, kullanıcıya sor — değiştirmek ister mi?
|
|
41
|
+
if (config.telegramToken) {
|
|
42
|
+
const masked = config.telegramToken.slice(0, 15) + '...' + config.telegramToken.slice(-5);
|
|
43
|
+
console.log(chalk.green('\n✓ Telegram token zaten kayıtlı: ' + masked));
|
|
44
|
+
console.log(chalk.gray(' Bot ID: ' + (config.telegramBotId || 'yok')));
|
|
45
|
+
console.log(chalk.gray(' İzinli chat: ' + (config.telegramAllowedChats || []).join(', ') + '\n'));
|
|
46
|
+
const ans = await inquirer.prompt([{
|
|
47
|
+
type: 'confirm',
|
|
48
|
+
name: 'change',
|
|
49
|
+
message: 'Token değiştirmek istiyor musun?',
|
|
50
|
+
default: false,
|
|
51
|
+
}]);
|
|
52
|
+
if (!ans.change) {
|
|
53
|
+
console.log(chalk.green('\n✅ Mevcut token kullanılacak.\n'));
|
|
54
|
+
console.log(chalk.gray('Gateway başlat: natureco gateway start\n'));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
40
59
|
console.log(chalk.yellow('\n⏳ Telegram bot bağlantısı hazırlanıyor...\n'));
|
|
41
60
|
console.log(chalk.gray('Telegram bot token almak için:'));
|
|
42
61
|
console.log(chalk.gray('1. Telegram\'da @BotFather\'ı aç'));
|