natureco-cli 5.56.0 → 5.57.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 +1 -1
- package/src/commands/discord.js +7 -5
- package/src/commands/imessage.js +50 -48
- package/src/commands/irc.js +27 -25
- package/src/commands/mattermost.js +34 -32
- package/src/commands/signal.js +61 -59
- package/src/commands/slack.js +7 -5
- package/src/commands/sms.js +35 -33
- package/src/commands/telegram.js +50 -48
- package/src/commands/whatsapp.js +43 -41
package/src/commands/telegram.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
+
const { getLang: _gl } = require('../utils/i18n');
|
|
3
|
+
const L = (tr, en) => (_gl() === 'en' ? en : tr);
|
|
2
4
|
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
5
|
const { getConfig, saveConfig } = require('../utils/config');
|
|
4
6
|
|
|
@@ -17,8 +19,8 @@ async function telegram(action, chatId) {
|
|
|
17
19
|
|
|
18
20
|
if (action === 'allow') {
|
|
19
21
|
if (!chatId) {
|
|
20
|
-
console.log(chalk.red('\n❌ Chat ID belirtmelisiniz\n'));
|
|
21
|
-
console.log(chalk.gray('Kullanım: natureco telegram allow <chatId>\n'));
|
|
22
|
+
console.log(chalk.red(L('\n❌ Chat ID belirtmelisiniz\n', '\n❌ You must specify a Chat ID\n')));
|
|
23
|
+
console.log(chalk.gray(L('Kullanım: natureco telegram allow <chatId>\n', 'Usage: natureco telegram allow <chatId>\n')));
|
|
22
24
|
process.exit(1);
|
|
23
25
|
}
|
|
24
26
|
return allowChat(chatId);
|
|
@@ -38,35 +40,35 @@ async function connectTelegram() {
|
|
|
38
40
|
const config = getConfig();
|
|
39
41
|
|
|
40
42
|
if (!config.providerUrl) {
|
|
41
|
-
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
43
|
+
console.log(chalk.red(L('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n', '\n❌ Setup not done. Run "natureco setup" first.\n')));
|
|
42
44
|
process.exit(1);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
// v5.4.21: Eğer zaten token kaydedilmişse, kullanıcıya sor — değiştirmek ister mi?
|
|
46
48
|
if (config.telegramToken) {
|
|
47
49
|
const masked = config.telegramToken.slice(0, 15) + '...' + config.telegramToken.slice(-5);
|
|
48
|
-
console.log(chalk.green('\n✓ Telegram token zaten kayıtlı: ' + masked));
|
|
49
|
-
console.log(chalk.gray(' Bot ID: ' + (config.telegramBotId || 'yok')));
|
|
50
|
-
console.log(chalk.gray(' İzinli chat: ' + (config.telegramAllowedChats || []).join(', ') + '\n'));
|
|
50
|
+
console.log(chalk.green(L('\n✓ Telegram token zaten kayıtlı: ', '\n✓ Telegram token already saved: ') + masked));
|
|
51
|
+
console.log(chalk.gray(' Bot ID: ' + (config.telegramBotId || L('yok', 'none'))));
|
|
52
|
+
console.log(chalk.gray(L(' İzinli chat: ', ' Allowed chat: ') + (config.telegramAllowedChats || []).join(', ') + '\n'));
|
|
51
53
|
const ans = await inquirer.prompt([{
|
|
52
54
|
type: 'confirm',
|
|
53
55
|
name: 'change',
|
|
54
|
-
message: 'Token değiştirmek istiyor musun?',
|
|
56
|
+
message: L('Token değiştirmek istiyor musun?', 'Do you want to change the token?'),
|
|
55
57
|
default: false,
|
|
56
58
|
}]);
|
|
57
59
|
if (!ans.change) {
|
|
58
|
-
console.log(chalk.green('\n✅ Mevcut token kullanılacak.\n'));
|
|
59
|
-
console.log(chalk.gray('Gateway başlat: natureco gateway start\n'));
|
|
60
|
+
console.log(chalk.green(L('\n✅ Mevcut token kullanılacak.\n', '\n✅ Existing token will be used.\n')));
|
|
61
|
+
console.log(chalk.gray(L('Gateway başlat: natureco gateway start\n', 'Start gateway: natureco gateway start\n')));
|
|
60
62
|
return;
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
|
|
64
|
-
console.log(chalk.yellow('\n⏳ Telegram bot bağlantısı hazırlanıyor...\n'));
|
|
65
|
-
console.log(chalk.gray('Telegram bot token almak için:'));
|
|
66
|
-
console.log(chalk.gray('1. Telegram\'da @BotFather\'ı aç'));
|
|
67
|
-
console.log(chalk.gray('2. /newbot komutunu gönder'));
|
|
68
|
-
console.log(chalk.gray('3. Bot adı ve kullanıcı adı belirle'));
|
|
69
|
-
console.log(chalk.gray('4. Aldığın token\'ı buraya gir\n'));
|
|
66
|
+
console.log(chalk.yellow(L('\n⏳ Telegram bot bağlantısı hazırlanıyor...\n', '\n⏳ Preparing Telegram bot connection...\n')));
|
|
67
|
+
console.log(chalk.gray(L('Telegram bot token almak için:', 'To get a Telegram bot token:')));
|
|
68
|
+
console.log(chalk.gray(L('1. Telegram\'da @BotFather\'ı aç', '1. Open @BotFather on Telegram')));
|
|
69
|
+
console.log(chalk.gray(L('2. /newbot komutunu gönder', '2. Send the /newbot command')));
|
|
70
|
+
console.log(chalk.gray(L('3. Bot adı ve kullanıcı adı belirle', '3. Set a bot name and username')));
|
|
71
|
+
console.log(chalk.gray(L('4. Aldığın token\'ı buraya gir\n', '4. Enter the token you received here\n')));
|
|
70
72
|
|
|
71
73
|
process.stdin.resume();
|
|
72
74
|
|
|
@@ -76,26 +78,26 @@ async function connectTelegram() {
|
|
|
76
78
|
name: 'token',
|
|
77
79
|
message: 'Telegram bot token:',
|
|
78
80
|
validate: (val) => {
|
|
79
|
-
if (val.trim() === '') return 'Token boş olamaz';
|
|
80
|
-
if (!val.includes(':')) return 'Geçersiz token formatı (örnek: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)';
|
|
81
|
+
if (val.trim() === '') return L('Token boş olamaz', 'Token cannot be empty');
|
|
82
|
+
if (!val.includes(':')) return L('Geçersiz token formatı (örnek: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)', 'Invalid token format (example: 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11)');
|
|
81
83
|
return true;
|
|
82
84
|
},
|
|
83
85
|
},
|
|
84
86
|
]);
|
|
85
87
|
|
|
86
|
-
console.log(chalk.yellow('\n⏳ Telegram Chat ID almak için:\n'));
|
|
87
|
-
console.log(chalk.gray('1. Telegram\'da @userinfobot veya @getmyid_bot\'a mesaj gönder'));
|
|
88
|
-
console.log(chalk.gray('2. Sana chat ID\'ni söyleyecek'));
|
|
89
|
-
console.log(chalk.gray('3. Chat ID\'yi buraya gir (örnek: 123456789)\n'));
|
|
88
|
+
console.log(chalk.yellow(L('\n⏳ Telegram Chat ID almak için:\n', '\n⏳ To get your Telegram Chat ID:\n')));
|
|
89
|
+
console.log(chalk.gray(L('1. Telegram\'da @userinfobot veya @getmyid_bot\'a mesaj gönder', '1. Message @userinfobot or @getmyid_bot on Telegram')));
|
|
90
|
+
console.log(chalk.gray(L('2. Sana chat ID\'ni söyleyecek', '2. It will tell you your chat ID')));
|
|
91
|
+
console.log(chalk.gray(L('3. Chat ID\'yi buraya gir (örnek: 123456789)\n', '3. Enter the Chat ID here (example: 123456789)\n')));
|
|
90
92
|
|
|
91
93
|
const chatIdAnswer = await inquirer.prompt([
|
|
92
94
|
{
|
|
93
95
|
type: 'input',
|
|
94
96
|
name: 'chatId',
|
|
95
|
-
message: 'Telegram Chat ID\'n:',
|
|
97
|
+
message: L('Telegram Chat ID\'n:', 'Your Telegram Chat ID:'),
|
|
96
98
|
validate: (val) => {
|
|
97
|
-
if (val.trim() === '') return 'Chat ID boş olamaz';
|
|
98
|
-
if (!/^-?\d+$/.test(val.trim())) return 'Geçersiz Chat ID formatı (sadece rakam olmalı)';
|
|
99
|
+
if (val.trim() === '') return L('Chat ID boş olamaz', 'Chat ID cannot be empty');
|
|
100
|
+
if (!/^-?\d+$/.test(val.trim())) return L('Geçersiz Chat ID formatı (sadece rakam olmalı)', 'Invalid Chat ID format (must be digits only)');
|
|
99
101
|
return true;
|
|
100
102
|
},
|
|
101
103
|
},
|
|
@@ -104,7 +106,7 @@ async function connectTelegram() {
|
|
|
104
106
|
// Telegram için bot ID oluştur (timestamp-based)
|
|
105
107
|
const botId = `telegram_${Date.now()}`;
|
|
106
108
|
|
|
107
|
-
console.log(chalk.yellow('\n⏳ Telegram bağlantısı kaydediliyor...\n'));
|
|
109
|
+
console.log(chalk.yellow(L('\n⏳ Telegram bağlantısı kaydediliyor...\n', '\n⏳ Saving Telegram connection...\n')));
|
|
108
110
|
|
|
109
111
|
// Save to config (v2.x - no backend call)
|
|
110
112
|
config.telegramToken = answers.token.trim();
|
|
@@ -112,16 +114,16 @@ async function connectTelegram() {
|
|
|
112
114
|
config.telegramAllowedChats = [chatIdAnswer.chatId.trim()];
|
|
113
115
|
saveConfig(config);
|
|
114
116
|
|
|
115
|
-
console.log(chalk.green('✅ Telegram bot token kaydedildi!\n'));
|
|
117
|
+
console.log(chalk.green(L('✅ Telegram bot token kaydedildi!\n', '✅ Telegram bot token saved!\n')));
|
|
116
118
|
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
117
119
|
console.log(chalk.cyan('Token:'), chalk.white(answers.token.slice(0, 20) + '...'));
|
|
118
|
-
console.log(chalk.cyan('İzin verilen chat:'), chalk.white(chatIdAnswer.chatId.trim()));
|
|
119
|
-
console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/config.json'));
|
|
120
|
-
console.log(chalk.gray('Başka chat eklemek için: natureco telegram allow <chatId>'));
|
|
120
|
+
console.log(chalk.cyan(L('İzin verilen chat:', 'Allowed chat:')), chalk.white(chatIdAnswer.chatId.trim()));
|
|
121
|
+
console.log(chalk.gray(L('\nSession kaydedildi: ~/.natureco/config.json', '\nSession saved: ~/.natureco/config.json')));
|
|
122
|
+
console.log(chalk.gray(L('Başka chat eklemek için: natureco telegram allow <chatId>', 'To add another chat: natureco telegram allow <chatId>')));
|
|
121
123
|
|
|
122
|
-
console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
|
|
123
|
-
console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
|
|
124
|
-
console.log(chalk.gray('Gateway, Telegram botunu otomatik olarak başlatacak.\n'));
|
|
124
|
+
console.log(chalk.green(L('\n✅ Kurulum tamamlandı!\n', '\n✅ Setup complete!\n')));
|
|
125
|
+
console.log(chalk.yellow(L('Gateway ile başlatmak için:', 'To start with the gateway:')), chalk.cyan('natureco gateway start'));
|
|
126
|
+
console.log(chalk.gray(L('Gateway, Telegram botunu otomatik olarak başlatacak.\n', 'The gateway will start the Telegram bot automatically.\n')));
|
|
125
127
|
}
|
|
126
128
|
|
|
127
129
|
async function disconnectTelegram() {
|
|
@@ -178,9 +180,9 @@ function statusTelegram() {
|
|
|
178
180
|
// Show allowed chats
|
|
179
181
|
const allowedChats = config.telegramAllowedChats || [];
|
|
180
182
|
if (allowedChats.length === 0) {
|
|
181
|
-
console.log(chalk.cyan('İzin listesi:'), chalk.gray('Boş (herkesten mesaj kabul edilir)'));
|
|
183
|
+
console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')), chalk.gray(L('Boş (herkesten mesaj kabul edilir)', 'Empty (accepts messages from anyone)')));
|
|
182
184
|
} else {
|
|
183
|
-
console.log(chalk.cyan('İzin listesi:'));
|
|
185
|
+
console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')));
|
|
184
186
|
allowedChats.forEach(chatId => console.log(chalk.white(` - ${chatId}`)));
|
|
185
187
|
}
|
|
186
188
|
|
|
@@ -200,15 +202,15 @@ function allowChat(chatId) {
|
|
|
200
202
|
const normalized = chatId.trim();
|
|
201
203
|
|
|
202
204
|
if (!/^-?\d+$/.test(normalized)) {
|
|
203
|
-
console.log(chalk.red('\n❌ Geçersiz Chat ID formatı\n'));
|
|
204
|
-
console.log(chalk.gray('Chat ID sadece rakamlardan oluşmalı (örnek: 123456789 veya -123456789)\n'));
|
|
205
|
+
console.log(chalk.red(L('\n❌ Geçersiz Chat ID formatı\n', '\n❌ Invalid Chat ID format\n')));
|
|
206
|
+
console.log(chalk.gray(L('Chat ID sadece rakamlardan oluşmalı (örnek: 123456789 veya -123456789)\n', 'Chat ID must consist of digits only (example: 123456789 or -123456789)\n')));
|
|
205
207
|
process.exit(1);
|
|
206
208
|
}
|
|
207
209
|
|
|
208
210
|
const allowedChats = config.telegramAllowedChats || [];
|
|
209
211
|
|
|
210
212
|
if (allowedChats.includes(normalized)) {
|
|
211
|
-
console.log(chalk.yellow('\n⚠️ Bu chat ID zaten izin listesinde\n'));
|
|
213
|
+
console.log(chalk.yellow(L('\n⚠️ Bu chat ID zaten izin listesinde\n', '\n⚠️ This chat ID is already in the allowlist\n')));
|
|
212
214
|
return;
|
|
213
215
|
}
|
|
214
216
|
|
|
@@ -216,10 +218,10 @@ function allowChat(chatId) {
|
|
|
216
218
|
config.telegramAllowedChats = allowedChats;
|
|
217
219
|
saveConfig(config);
|
|
218
220
|
|
|
219
|
-
console.log(chalk.green('\n✅ Chat ID izin listesine eklendi\n'));
|
|
221
|
+
console.log(chalk.green(L('\n✅ Chat ID izin listesine eklendi\n', '\n✅ Chat ID added to allowlist\n')));
|
|
220
222
|
console.log(chalk.cyan('Chat ID:'), chalk.white(normalized));
|
|
221
|
-
console.log(chalk.cyan('Toplam:'), chalk.white(`${allowedChats.length} chat`));
|
|
222
|
-
console.log(chalk.gray('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n'));
|
|
223
|
+
console.log(chalk.cyan(L('Toplam:', 'Total:')), chalk.white(`${allowedChats.length} chat`));
|
|
224
|
+
console.log(chalk.gray(L('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n', '\nRestart the gateway: natureco gateway stop && natureco gateway start\n')));
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
module.exports = telegram;
|
|
@@ -233,12 +235,12 @@ module.exports = telegram;
|
|
|
233
235
|
async function autoDetectChatId() {
|
|
234
236
|
const config = getConfig();
|
|
235
237
|
if (!config.telegramToken) {
|
|
236
|
-
console.log(chalk.red('\n❌ Once natureco telegram connect yapin\n'));
|
|
238
|
+
console.log(chalk.red(L('\n❌ Once natureco telegram connect yapin\n', '\n❌ First run natureco telegram connect\n')));
|
|
237
239
|
process.exit(1);
|
|
238
240
|
}
|
|
239
241
|
|
|
240
|
-
console.log(chalk.cyan('\n🤖 Telegram bot calistiriliyor, ilk mesaji bekliyorum...\n'));
|
|
241
|
-
console.log(chalk.gray('Telegramda botunuza /start yazin veya bir mesaj gonderin\n'));
|
|
242
|
+
console.log(chalk.cyan(L('\n🤖 Telegram bot calistiriliyor, ilk mesaji bekliyorum...\n', '\n🤖 Running Telegram bot, waiting for first message...\n')));
|
|
243
|
+
console.log(chalk.gray(L('Telegramda botunuza /start yazin veya bir mesaj gonderin\n', 'Send /start or a message to your bot on Telegram\n')));
|
|
242
244
|
|
|
243
245
|
const TelegramBot = require('node-telegram-bot-api');
|
|
244
246
|
const bot = new TelegramBot(config.telegramToken, { polling: true });
|
|
@@ -250,10 +252,10 @@ async function autoDetectChatId() {
|
|
|
250
252
|
detected = true;
|
|
251
253
|
|
|
252
254
|
const chatId = String(msg.chat.id);
|
|
253
|
-
const name = msg.from?.first_name || msg.from?.username || 'Bilinmeyen';
|
|
255
|
+
const name = msg.from?.first_name || msg.from?.username || L('Bilinmeyen', 'Unknown');
|
|
254
256
|
|
|
255
|
-
console.log(chalk.green('\n✓ Mesaj alindi!'));
|
|
256
|
-
console.log(chalk.cyan(` Kullanici: ${name}`));
|
|
257
|
+
console.log(chalk.green(L('\n✓ Mesaj alindi!', '\n✓ Message received!')));
|
|
258
|
+
console.log(chalk.cyan(` ${L('Kullanici', 'User')}: ${name}`));
|
|
257
259
|
console.log(chalk.cyan(` Chat ID: ${chatId}`));
|
|
258
260
|
|
|
259
261
|
// Kaydet
|
|
@@ -263,7 +265,7 @@ async function autoDetectChatId() {
|
|
|
263
265
|
}
|
|
264
266
|
saveConfig(config);
|
|
265
267
|
|
|
266
|
-
console.log(chalk.green('\n✅ Chat ID kaydedildi: ' + chatId + '\n'));
|
|
268
|
+
console.log(chalk.green(L('\n✅ Chat ID kaydedildi: ', '\n✅ Chat ID saved: ') + chatId + '\n'));
|
|
267
269
|
bot.stopPolling();
|
|
268
270
|
process.exit(0);
|
|
269
271
|
});
|
|
@@ -271,7 +273,7 @@ async function autoDetectChatId() {
|
|
|
271
273
|
// 60 saniye timeout
|
|
272
274
|
setTimeout(() => {
|
|
273
275
|
if (!detected) {
|
|
274
|
-
console.log(chalk.red('\n⏱ 60 saniye icinde mesaj gelmedi. Tekrar deneyin.\n'));
|
|
276
|
+
console.log(chalk.red(L('\n⏱ 60 saniye icinde mesaj gelmedi. Tekrar deneyin.\n', '\n⏱ No message within 60 seconds. Try again.\n')));
|
|
275
277
|
bot.stopPolling();
|
|
276
278
|
process.exit(1);
|
|
277
279
|
}
|
package/src/commands/whatsapp.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const chalk = require('chalk');
|
|
2
|
+
const { getLang: _gl } = require('../utils/i18n');
|
|
3
|
+
const L = (tr, en) => (_gl() === 'en' ? en : tr);
|
|
2
4
|
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
5
|
const qrcode = require('qrcode-terminal');
|
|
4
6
|
const QRCode = require('qrcode');
|
|
@@ -33,8 +35,8 @@ async function whatsapp(action, number) {
|
|
|
33
35
|
|
|
34
36
|
if (action === 'allow') {
|
|
35
37
|
if (!number) {
|
|
36
|
-
console.log(chalk.red('\n❌ Numara belirtmelisiniz\n'));
|
|
37
|
-
console.log(chalk.gray('Kullanım: natureco whatsapp allow <numara>\n'));
|
|
38
|
+
console.log(chalk.red(L('\n❌ Numara belirtmelisiniz\n', '\n❌ You must specify a number\n')));
|
|
39
|
+
console.log(chalk.gray(L('Kullanım: natureco whatsapp allow <numara>\n', 'Usage: natureco whatsapp allow <number>\n')));
|
|
38
40
|
process.exit(1);
|
|
39
41
|
}
|
|
40
42
|
return allowNumber(number);
|
|
@@ -49,18 +51,18 @@ async function connectWhatsApp() {
|
|
|
49
51
|
const config = getConfig();
|
|
50
52
|
|
|
51
53
|
if (!config.providerUrl) {
|
|
52
|
-
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
54
|
+
console.log(chalk.red(L('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n', '\n❌ Setup not done. Run "natureco setup" first.\n')));
|
|
53
55
|
process.exit(1);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
console.log(chalk.yellow('\n⏳ WhatsApp bağlantısı hazırlanıyor...\n'));
|
|
58
|
+
console.log(chalk.yellow(L('\n⏳ WhatsApp bağlantısı hazırlanıyor...\n', '\n⏳ Preparing WhatsApp connection...\n')));
|
|
57
59
|
|
|
58
60
|
// WhatsApp için bot ID oluştur (timestamp-based)
|
|
59
61
|
const botId = `whatsapp_${Date.now()}`;
|
|
60
62
|
const selectedBot = { name: 'WhatsApp Bot', id: botId };
|
|
61
63
|
|
|
62
|
-
console.log(chalk.cyan('\n📱 WhatsApp bağlantısı başlatılıyor...'));
|
|
63
|
-
console.log(chalk.gray('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n'));
|
|
64
|
+
console.log(chalk.cyan(L('\n📱 WhatsApp bağlantısı başlatılıyor...', '\n📱 Starting WhatsApp connection...')));
|
|
65
|
+
console.log(chalk.gray(L('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n', 'Open WhatsApp on your phone and scan the QR code.\n')));
|
|
64
66
|
|
|
65
67
|
// Create session directory
|
|
66
68
|
const sessionDir = path.join(WHATSAPP_SESSION_DIR, botId);
|
|
@@ -82,7 +84,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
82
84
|
// Get latest Baileys version
|
|
83
85
|
const { version } = await fetchLatestBaileysVersion();
|
|
84
86
|
|
|
85
|
-
console.log(chalk.yellow('⏳ WhatsApp client başlatılıyor...\n'));
|
|
87
|
+
console.log(chalk.yellow(L('⏳ WhatsApp client başlatılıyor...\n', '⏳ Starting WhatsApp client...\n')));
|
|
86
88
|
|
|
87
89
|
// Create socket
|
|
88
90
|
const sock = makeWASocket({
|
|
@@ -105,7 +107,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
105
107
|
const { connection, lastDisconnect, qr } = update;
|
|
106
108
|
|
|
107
109
|
if (qr && !qrDisplayed) {
|
|
108
|
-
console.log(chalk.green('✅ QR kod hazır!\n'));
|
|
110
|
+
console.log(chalk.green(L('✅ QR kod hazır!\n', '✅ QR code ready!\n')));
|
|
109
111
|
|
|
110
112
|
// Display QR code in terminal
|
|
111
113
|
qrcode.generate(qr, { small: true });
|
|
@@ -119,17 +121,17 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
119
121
|
margin: 4,
|
|
120
122
|
color: { dark: '#000000', light: '#FFFFFF' }
|
|
121
123
|
});
|
|
122
|
-
console.log(chalk.green('\n📸 QR PNG kaydedildi: ' + qrPngPath));
|
|
123
|
-
console.log(chalk.cyan('🔗 Browserda acmak icin: open ' + qrPngPath));
|
|
124
|
+
console.log(chalk.green(L('\n📸 QR PNG kaydedildi: ', '\n📸 QR PNG saved: ') + qrPngPath));
|
|
125
|
+
console.log(chalk.cyan(L('🔗 Browserda acmak icin: open ', '🔗 To open in browser: open ') + qrPngPath));
|
|
124
126
|
} catch (e) {
|
|
125
127
|
// Sessizce gec, terminal QR yeterli
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
console.log('');
|
|
129
|
-
console.log(chalk.gray('1. WhatsApp\'ı açın'));
|
|
130
|
-
console.log(chalk.gray('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla'));
|
|
131
|
-
console.log(chalk.gray('3. Bu QR kodu taratın\n'));
|
|
132
|
-
console.log(chalk.yellow('⏳ QR kod taranması bekleniyor...\n'));
|
|
131
|
+
console.log(chalk.gray(L('1. WhatsApp\'ı açın', '1. Open WhatsApp')));
|
|
132
|
+
console.log(chalk.gray(L('2. Ayarlar > Bağlı Cihazlar > Cihaz Bağla', '2. Settings > Linked Devices > Link a Device')));
|
|
133
|
+
console.log(chalk.gray(L('3. Bu QR kodu taratın\n', '3. Scan this QR code\n')));
|
|
134
|
+
console.log(chalk.yellow(L('⏳ QR kod taranması bekleniyor...\n', '⏳ Waiting for QR code scan...\n')));
|
|
133
135
|
|
|
134
136
|
qrDisplayed = true;
|
|
135
137
|
}
|
|
@@ -139,29 +141,29 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
139
141
|
|
|
140
142
|
if (statusCode === 515 || statusCode === 408) {
|
|
141
143
|
// Normal — yeniden bağlan, logout değil
|
|
142
|
-
console.log(chalk.yellow('🔄 Yeniden bağlanıyor...'));
|
|
144
|
+
console.log(chalk.yellow(L('🔄 Yeniden bağlanıyor...', '🔄 Reconnecting...')));
|
|
143
145
|
setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config), 2000);
|
|
144
146
|
return;
|
|
145
147
|
} else if (statusCode === 401) {
|
|
146
|
-
console.log(chalk.red('❌ Oturum sonlandı, tekrar bağlanın.'));
|
|
148
|
+
console.log(chalk.red(L('❌ Oturum sonlandı, tekrar bağlanın.', '❌ Session ended, reconnect.')));
|
|
147
149
|
process.exit(1);
|
|
148
150
|
} else if (statusCode === DisconnectReason.loggedOut) {
|
|
149
|
-
console.log(chalk.red('\n❌ WhatsApp oturumu kapatıldı\n'));
|
|
151
|
+
console.log(chalk.red(L('\n❌ WhatsApp oturumu kapatıldı\n', '\n❌ WhatsApp session logged out\n')));
|
|
150
152
|
process.exit(0);
|
|
151
153
|
} else if (!isConnected) {
|
|
152
|
-
console.log(chalk.red('\n❌ Bağlantı başarısız\n'));
|
|
153
|
-
console.log(chalk.gray(
|
|
154
|
+
console.log(chalk.red(L('\n❌ Bağlantı başarısız\n', '\n❌ Connection failed\n')));
|
|
155
|
+
console.log(chalk.gray(`${L('Hata kodu', 'Error code')}: ${statusCode}\n`));
|
|
154
156
|
process.exit(1);
|
|
155
157
|
} else {
|
|
156
|
-
console.log(chalk.red(`❌ Bağlantı kesildi: ${statusCode}\n`));
|
|
158
|
+
console.log(chalk.red(`❌ ${L('Bağlantı kesildi', 'Connection lost')}: ${statusCode}\n`));
|
|
157
159
|
process.exit(1);
|
|
158
160
|
}
|
|
159
161
|
} else if (connection === 'open') {
|
|
160
162
|
isConnected = true;
|
|
161
|
-
console.log(chalk.green('✅ WhatsApp bağlandı!\n'));
|
|
163
|
+
console.log(chalk.green(L('✅ WhatsApp bağlandı!\n', '✅ WhatsApp connected!\n')));
|
|
162
164
|
console.log(chalk.cyan('Bot:'), chalk.white(selectedBot.name));
|
|
163
|
-
console.log(chalk.cyan('Telefon:'), chalk.white(sock.user?.id || 'Unknown'));
|
|
164
|
-
console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/'));
|
|
165
|
+
console.log(chalk.cyan(L('Telefon:', 'Phone:')), chalk.white(sock.user?.id || 'Unknown'));
|
|
166
|
+
console.log(chalk.gray(L('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/', '\nSession saved: ~/.natureco/whatsapp-sessions/')));
|
|
165
167
|
|
|
166
168
|
// Extract own number and add to allowed list
|
|
167
169
|
const ownNumber = sock.user?.id?.split(':')[0].replace('@s.whatsapp.net', '') || '';
|
|
@@ -174,12 +176,12 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
174
176
|
config.whatsappAllowedNumbers = allowedNumbers;
|
|
175
177
|
saveConfig(config);
|
|
176
178
|
|
|
177
|
-
console.log(chalk.cyan('\nİzin verilen numara:'), chalk.white(`+${ownNumber} (kendi numaranız)`));
|
|
178
|
-
console.log(chalk.gray('Başka numara eklemek için: natureco whatsapp allow <numara>'));
|
|
179
|
+
console.log(chalk.cyan(L('\nİzin verilen numara:', '\nAllowed number:')), chalk.white(`+${ownNumber} ${L('(kendi numaranız)', '(your own number)')}`));
|
|
180
|
+
console.log(chalk.gray(L('Başka numara eklemek için: natureco whatsapp allow <numara>', 'To add another number: natureco whatsapp allow <number>')));
|
|
179
181
|
|
|
180
|
-
console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
|
|
181
|
-
console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
|
|
182
|
-
console.log(chalk.gray('Gateway, WhatsApp\'ı otomatik olarak başlatacak.\n'));
|
|
182
|
+
console.log(chalk.green(L('\n✅ Kurulum tamamlandı!\n', '\n✅ Setup complete!\n')));
|
|
183
|
+
console.log(chalk.yellow(L('Gateway ile başlatmak için:', 'To start with the gateway:')), chalk.cyan('natureco gateway start'));
|
|
184
|
+
console.log(chalk.gray(L('Gateway, WhatsApp\'ı otomatik olarak başlatacak.\n', 'The gateway will start WhatsApp automatically.\n')));
|
|
183
185
|
|
|
184
186
|
// Exit after setup
|
|
185
187
|
setTimeout(() => {
|
|
@@ -195,7 +197,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
195
197
|
|
|
196
198
|
// Handle Ctrl+C
|
|
197
199
|
process.on('SIGINT', () => {
|
|
198
|
-
console.log(chalk.yellow('\n\n⚠️ Bağlantı iptal edildi\n'));
|
|
200
|
+
console.log(chalk.yellow(L('\n\n⚠️ Bağlantı iptal edildi\n', '\n\n⚠️ Connection cancelled\n')));
|
|
199
201
|
process.exit(0);
|
|
200
202
|
});
|
|
201
203
|
|
|
@@ -203,8 +205,8 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
|
203
205
|
const msg = err instanceof NatureCoError ? err.message : err?.message ?? 'Unknown error';
|
|
204
206
|
console.log(chalk.red(`\n❌ Connection failed: ${msg}\n`));
|
|
205
207
|
if (err?.message?.includes('Cannot find module')) {
|
|
206
|
-
console.log(chalk.yellow('⚠️ Baileys paketi yüklü değil. Yükleniyor...\n'));
|
|
207
|
-
console.log(chalk.gray('Lütfen şu komutu çalıştırın:\n'));
|
|
208
|
+
console.log(chalk.yellow(L('⚠️ Baileys paketi yüklü değil. Yükleniyor...\n', '⚠️ Baileys package not installed. Installing...\n')));
|
|
209
|
+
console.log(chalk.gray(L('Lütfen şu komutu çalıştırın:\n', 'Please run this command:\n')));
|
|
208
210
|
console.log(chalk.cyan('npm install -g @whiskeysockets/baileys pino\n'));
|
|
209
211
|
}
|
|
210
212
|
process.exit(1);
|
|
@@ -240,7 +242,7 @@ async function disconnectWhatsApp() {
|
|
|
240
242
|
const sessionDir = path.join(WHATSAPP_SESSION_DIR, config.whatsappBotId);
|
|
241
243
|
if (fs.existsSync(sessionDir)) {
|
|
242
244
|
fs.rmSync(sessionDir, { recursive: true, force: true });
|
|
243
|
-
console.log(chalk.green('\n✅ Session dosyaları silindi\n'));
|
|
245
|
+
console.log(chalk.green(L('\n✅ Session dosyaları silindi\n', '\n✅ Session files deleted\n')));
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
// Remove from config
|
|
@@ -278,9 +280,9 @@ function statusWhatsApp() {
|
|
|
278
280
|
// Show allowed numbers
|
|
279
281
|
const allowedNumbers = config.whatsappAllowedNumbers || [];
|
|
280
282
|
if (allowedNumbers.length === 0) {
|
|
281
|
-
console.log(chalk.cyan('İzin listesi:'), chalk.gray('Boş (herkesten mesaj kabul edilir)'));
|
|
283
|
+
console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')), chalk.gray(L('Boş (herkesten mesaj kabul edilir)', 'Empty (accepts messages from anyone)')));
|
|
282
284
|
} else {
|
|
283
|
-
console.log(chalk.cyan('İzin listesi:'));
|
|
285
|
+
console.log(chalk.cyan(L('İzin listesi:', 'Allowlist:')));
|
|
284
286
|
allowedNumbers.forEach(num => console.log(chalk.white(` - +${num}`)));
|
|
285
287
|
}
|
|
286
288
|
|
|
@@ -309,15 +311,15 @@ function allowNumber(number) {
|
|
|
309
311
|
const normalized = number.replace(/[\s\+\-\(\)]/g, '');
|
|
310
312
|
|
|
311
313
|
if (!/^\d+$/.test(normalized)) {
|
|
312
|
-
console.log(chalk.red('\n❌ Geçersiz numara formatı\n'));
|
|
313
|
-
console.log(chalk.gray('Örnek: natureco whatsapp allow 905551234567\n'));
|
|
314
|
+
console.log(chalk.red(L('\n❌ Geçersiz numara formatı\n', '\n❌ Invalid number format\n')));
|
|
315
|
+
console.log(chalk.gray(L('Örnek: natureco whatsapp allow 905551234567\n', 'Example: natureco whatsapp allow 905551234567\n')));
|
|
314
316
|
process.exit(1);
|
|
315
317
|
}
|
|
316
318
|
|
|
317
319
|
const allowedNumbers = config.whatsappAllowedNumbers || [];
|
|
318
320
|
|
|
319
321
|
if (allowedNumbers.includes(normalized)) {
|
|
320
|
-
console.log(chalk.yellow('\n⚠️ Bu numara zaten izin listesinde\n'));
|
|
322
|
+
console.log(chalk.yellow(L('\n⚠️ Bu numara zaten izin listesinde\n', '\n⚠️ This number is already in the allowlist\n')));
|
|
321
323
|
return;
|
|
322
324
|
}
|
|
323
325
|
|
|
@@ -325,10 +327,10 @@ function allowNumber(number) {
|
|
|
325
327
|
config.whatsappAllowedNumbers = allowedNumbers;
|
|
326
328
|
saveConfig(config);
|
|
327
329
|
|
|
328
|
-
console.log(chalk.green('\n✅ Numara izin listesine eklendi\n'));
|
|
329
|
-
console.log(chalk.cyan('Numara:'), chalk.white(`+${normalized}`));
|
|
330
|
-
console.log(chalk.cyan('Toplam:'), chalk.white(`${allowedNumbers.length} numara`));
|
|
331
|
-
console.log(chalk.gray('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n'));
|
|
330
|
+
console.log(chalk.green(L('\n✅ Numara izin listesine eklendi\n', '\n✅ Number added to allowlist\n')));
|
|
331
|
+
console.log(chalk.cyan(L('Numara:', 'Number:')), chalk.white(`+${normalized}`));
|
|
332
|
+
console.log(chalk.cyan(L('Toplam:', 'Total:')), chalk.white(`${allowedNumbers.length} numara`));
|
|
333
|
+
console.log(chalk.gray(L('\nGateway\'i yeniden başlatın: natureco gateway stop && natureco gateway start\n', '\nRestart the gateway: natureco gateway stop && natureco gateway start\n')));
|
|
332
334
|
}
|
|
333
335
|
|
|
334
336
|
module.exports = whatsapp;
|