natureco-cli 2.6.0 → 2.6.1
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
CHANGED
|
@@ -211,7 +211,7 @@ body::before{
|
|
|
211
211
|
<div class="header-bot-name" id="header-bot-name">Nature Bot</div>
|
|
212
212
|
<div class="header-bot-model" id="header-bot-model">NatureCo</div>
|
|
213
213
|
</div>
|
|
214
|
-
<div class="version-badge" id="version-badge">v2.6.
|
|
214
|
+
<div class="version-badge" id="version-badge">v2.6.1</div>
|
|
215
215
|
</div>
|
|
216
216
|
<div class="messages" id="messages"></div>
|
|
217
217
|
<div class="input-area">
|
|
@@ -341,7 +341,7 @@ function dashboard(action) {
|
|
|
341
341
|
apiKey: cfg.apiKey,
|
|
342
342
|
defaultBot: cfg.defaultBot,
|
|
343
343
|
defaultBotId: cfg.defaultBotId,
|
|
344
|
-
version: 'v2.6.
|
|
344
|
+
version: 'v2.6.1',
|
|
345
345
|
bots: cfg.bots || [],
|
|
346
346
|
telegramToken: cfg.telegramToken || null,
|
|
347
347
|
whatsappConnected: cfg.whatsappConnected || false,
|
|
@@ -128,7 +128,7 @@ async function startGateway() {
|
|
|
128
128
|
|
|
129
129
|
async function runGatewayWorker() {
|
|
130
130
|
// This runs in the background
|
|
131
|
-
log('gateway', 'Starting NatureCo Gateway v2.6.
|
|
131
|
+
log('gateway', 'Starting NatureCo Gateway v2.6.1...', 'green');
|
|
132
132
|
|
|
133
133
|
// Load config
|
|
134
134
|
const { getConfig } = require('../utils/config');
|
|
@@ -382,6 +382,13 @@ async function startTelegramProvider(config) {
|
|
|
382
382
|
return;
|
|
383
383
|
}
|
|
384
384
|
|
|
385
|
+
// Access control - check allowed chats
|
|
386
|
+
const allowedChats = config.telegramAllowedChats || [];
|
|
387
|
+
if (allowedChats.length > 0 && !allowedChats.includes(String(chatId))) {
|
|
388
|
+
log('telegram', `Blocked message from chat ${chatId} (not in allowed list)`, 'yellow');
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
|
|
385
392
|
log('telegram', `Inbound message from chat ${chatId} (${messageText.length} chars)`, 'cyan');
|
|
386
393
|
|
|
387
394
|
try {
|
package/src/commands/telegram.js
CHANGED
|
@@ -15,8 +15,18 @@ async function telegram(action) {
|
|
|
15
15
|
return statusTelegram();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
if (action === 'allow') {
|
|
19
|
+
const chatId = process.argv[4];
|
|
20
|
+
if (!chatId) {
|
|
21
|
+
console.log(chalk.red('\n❌ Chat ID belirtmelisiniz\n'));
|
|
22
|
+
console.log(chalk.gray('Kullanım: natureco telegram allow <chatId>\n'));
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
return allowChat(chatId);
|
|
26
|
+
}
|
|
27
|
+
|
|
18
28
|
console.log(chalk.red('\n❌ Unknown action\n'));
|
|
19
|
-
console.log(chalk.gray('Available actions: connect, disconnect, status\n'));
|
|
29
|
+
console.log(chalk.gray('Available actions: connect, disconnect, status, allow\n'));
|
|
20
30
|
process.exit(1);
|
|
21
31
|
}
|
|
22
32
|
|
|
@@ -50,6 +60,24 @@ async function connectTelegram() {
|
|
|
50
60
|
},
|
|
51
61
|
]);
|
|
52
62
|
|
|
63
|
+
console.log(chalk.yellow('\n⏳ Telegram Chat ID almak için:\n'));
|
|
64
|
+
console.log(chalk.gray('1. Telegram\'da @userinfobot veya @getmyid_bot\'a mesaj gönder'));
|
|
65
|
+
console.log(chalk.gray('2. Sana chat ID\'ni söyleyecek'));
|
|
66
|
+
console.log(chalk.gray('3. Chat ID\'yi buraya gir (örnek: 123456789)\n'));
|
|
67
|
+
|
|
68
|
+
const chatIdAnswer = await inquirer.prompt([
|
|
69
|
+
{
|
|
70
|
+
type: 'input',
|
|
71
|
+
name: 'chatId',
|
|
72
|
+
message: 'Telegram Chat ID\'n:',
|
|
73
|
+
validate: (val) => {
|
|
74
|
+
if (val.trim() === '') return 'Chat ID boş olamaz';
|
|
75
|
+
if (!/^-?\d+$/.test(val.trim())) return 'Geçersiz Chat ID formatı (sadece rakam olmalı)';
|
|
76
|
+
return true;
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
]);
|
|
80
|
+
|
|
53
81
|
// Telegram için bot ID oluştur (timestamp-based)
|
|
54
82
|
const botId = `telegram_${Date.now()}`;
|
|
55
83
|
|
|
@@ -58,12 +86,15 @@ async function connectTelegram() {
|
|
|
58
86
|
// Save to config (v2.x - no backend call)
|
|
59
87
|
config.telegramToken = answers.token.trim();
|
|
60
88
|
config.telegramBotId = botId;
|
|
89
|
+
config.telegramAllowedChats = [chatIdAnswer.chatId.trim()];
|
|
61
90
|
saveConfig(config);
|
|
62
91
|
|
|
63
92
|
console.log(chalk.green('✅ Telegram bot token kaydedildi!\n'));
|
|
64
93
|
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
65
94
|
console.log(chalk.cyan('Token:'), chalk.white(answers.token.slice(0, 20) + '...'));
|
|
95
|
+
console.log(chalk.cyan('İzin verilen chat:'), chalk.white(chatIdAnswer.chatId.trim()));
|
|
66
96
|
console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/config.json'));
|
|
97
|
+
console.log(chalk.gray('Başka chat eklemek için: natureco telegram allow <chatId>'));
|
|
67
98
|
|
|
68
99
|
console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
|
|
69
100
|
console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
|
|
@@ -97,6 +128,7 @@ async function disconnectTelegram() {
|
|
|
97
128
|
// Remove from config
|
|
98
129
|
delete config.telegramToken;
|
|
99
130
|
delete config.telegramBotId;
|
|
131
|
+
delete config.telegramAllowedChats;
|
|
100
132
|
saveConfig(config);
|
|
101
133
|
|
|
102
134
|
console.log(chalk.green('\n✅ Telegram disconnected\n'));
|
|
@@ -120,7 +152,51 @@ function statusTelegram() {
|
|
|
120
152
|
console.log(chalk.cyan('Bot ID:'), chalk.white(config.telegramBotId));
|
|
121
153
|
}
|
|
122
154
|
|
|
155
|
+
// Show allowed chats
|
|
156
|
+
const allowedChats = config.telegramAllowedChats || [];
|
|
157
|
+
if (allowedChats.length === 0) {
|
|
158
|
+
console.log(chalk.cyan('İzin listesi:'), chalk.gray('Boş (herkesten mesaj kabul edilir)'));
|
|
159
|
+
} else {
|
|
160
|
+
console.log(chalk.cyan('İzin listesi:'));
|
|
161
|
+
allowedChats.forEach(chatId => console.log(chalk.white(` - ${chatId}`)));
|
|
162
|
+
}
|
|
163
|
+
|
|
123
164
|
console.log(chalk.gray('\nDisconnect with: natureco telegram disconnect\n'));
|
|
124
165
|
}
|
|
125
166
|
|
|
167
|
+
function allowChat(chatId) {
|
|
168
|
+
const config = getConfig();
|
|
169
|
+
|
|
170
|
+
if (!config.telegramToken) {
|
|
171
|
+
console.log(chalk.red('\n❌ Telegram not connected\n'));
|
|
172
|
+
console.log(chalk.gray('Connect first with: natureco telegram connect\n'));
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Validate chat ID (should be numeric, can be negative for groups)
|
|
177
|
+
const normalized = chatId.trim();
|
|
178
|
+
|
|
179
|
+
if (!/^-?\d+$/.test(normalized)) {
|
|
180
|
+
console.log(chalk.red('\n❌ Geçersiz Chat ID formatı\n'));
|
|
181
|
+
console.log(chalk.gray('Chat ID sadece rakamlardan oluşmalı (örnek: 123456789 veya -123456789)\n'));
|
|
182
|
+
process.exit(1);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const allowedChats = config.telegramAllowedChats || [];
|
|
186
|
+
|
|
187
|
+
if (allowedChats.includes(normalized)) {
|
|
188
|
+
console.log(chalk.yellow('\n⚠️ Bu chat ID zaten izin listesinde\n'));
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
allowedChats.push(normalized);
|
|
193
|
+
config.telegramAllowedChats = allowedChats;
|
|
194
|
+
saveConfig(config);
|
|
195
|
+
|
|
196
|
+
console.log(chalk.green('\n✅ Chat ID izin listesine eklendi\n'));
|
|
197
|
+
console.log(chalk.cyan('Chat ID:'), chalk.white(normalized));
|
|
198
|
+
console.log(chalk.cyan('Toplam:'), chalk.white(`${allowedChats.length} chat`));
|
|
199
|
+
console.log(chalk.gray('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n'));
|
|
200
|
+
}
|
|
201
|
+
|
|
126
202
|
module.exports = telegram;
|
package/src/utils/api.js
CHANGED