natureco-cli 1.0.40 → 1.0.42
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
|
@@ -234,11 +234,6 @@ async function startWhatsAppProvider(sessionDir, config) {
|
|
|
234
234
|
log('whatsapp', `messages.upsert event triggered, ${messages.length} message(s)`, 'gray');
|
|
235
235
|
|
|
236
236
|
for (const msg of messages) {
|
|
237
|
-
if (msg.key.fromMe) {
|
|
238
|
-
log('whatsapp', 'skipping own message', 'gray');
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
237
|
const sender = msg.key.remoteJid?.split('@')[0].split(':')[0];
|
|
243
238
|
const allowedNumbers = config.whatsappAllowedNumbers || [];
|
|
244
239
|
|
package/src/commands/whatsapp.js
CHANGED
|
@@ -95,22 +95,6 @@ async function connectWhatsApp() {
|
|
|
95
95
|
|
|
96
96
|
const selectedBot = botList.bots.find(b => b.id === botId);
|
|
97
97
|
|
|
98
|
-
// Ask for allowed numbers
|
|
99
|
-
process.stdin.resume();
|
|
100
|
-
const { allowedNumbers } = await inquirer.prompt([
|
|
101
|
-
{
|
|
102
|
-
type: 'input',
|
|
103
|
-
name: 'allowedNumbers',
|
|
104
|
-
message: 'Hangi numaralar mesaj gönderebilir? (virgülle ayırın, zorunlu)',
|
|
105
|
-
validate: (input) => {
|
|
106
|
-
if (!input || input.trim().length === 0) {
|
|
107
|
-
return 'En az bir numara girmelisiniz';
|
|
108
|
-
}
|
|
109
|
-
return true;
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
]);
|
|
113
|
-
|
|
114
98
|
console.log(chalk.cyan('\n📱 WhatsApp bağlantısı başlatılıyor...'));
|
|
115
99
|
console.log(chalk.gray('Telefonunuzda WhatsApp\'ı açın ve QR kodu taratın.\n'));
|
|
116
100
|
|
|
@@ -123,17 +107,11 @@ async function connectWhatsApp() {
|
|
|
123
107
|
fs.mkdirSync(sessionDir, { recursive: true });
|
|
124
108
|
}
|
|
125
109
|
|
|
126
|
-
// Parse allowed numbers
|
|
127
|
-
const allowedNumbersList = allowedNumbers
|
|
128
|
-
.split(',')
|
|
129
|
-
.map(n => n.trim().replace(/[\s\+\-\(\)]/g, ''))
|
|
130
|
-
.filter(n => n.length > 0);
|
|
131
|
-
|
|
132
110
|
// Start connection (only for QR code)
|
|
133
|
-
await startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
111
|
+
await startWhatsAppConnection(sessionDir, botId, selectedBot, config);
|
|
134
112
|
}
|
|
135
113
|
|
|
136
|
-
async function startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
114
|
+
async function startWhatsAppConnection(sessionDir, botId, selectedBot, config) {
|
|
137
115
|
try {
|
|
138
116
|
// Create auth state
|
|
139
117
|
const { state, saveCreds } = await useMultiFileAuthState(sessionDir);
|
|
@@ -184,7 +162,7 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config, a
|
|
|
184
162
|
if (statusCode === 515 || statusCode === 408) {
|
|
185
163
|
// Normal — yeniden bağlan, logout değil
|
|
186
164
|
console.log(chalk.yellow('🔄 Yeniden bağlanıyor...'));
|
|
187
|
-
setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config
|
|
165
|
+
setTimeout(() => startWhatsAppConnection(sessionDir, botId, selectedBot, config), 2000);
|
|
188
166
|
return;
|
|
189
167
|
} else if (statusCode === 401) {
|
|
190
168
|
console.log(chalk.red('❌ Oturum sonlandı, tekrar bağlanın.'));
|
|
@@ -207,17 +185,19 @@ async function startWhatsAppConnection(sessionDir, botId, selectedBot, config, a
|
|
|
207
185
|
console.log(chalk.cyan('Telefon:'), chalk.white(sock.user?.id || 'Unknown'));
|
|
208
186
|
console.log(chalk.gray('\nSession kaydedildi: ~/.natureco/whatsapp-sessions/'));
|
|
209
187
|
|
|
210
|
-
//
|
|
188
|
+
// Extract own number and add to allowed list
|
|
189
|
+
const ownNumber = sock.user?.id?.split(':')[0].replace('@s.whatsapp.net', '') || '';
|
|
190
|
+
const allowedNumbers = ownNumber ? [ownNumber] : [];
|
|
191
|
+
|
|
192
|
+
// Save to config with own number in allowed list
|
|
211
193
|
config.whatsappConnected = true;
|
|
212
194
|
config.whatsappBotId = botId;
|
|
213
195
|
config.whatsappPhone = sock.user?.id;
|
|
214
|
-
config.whatsappAllowedNumbers =
|
|
196
|
+
config.whatsappAllowedNumbers = allowedNumbers;
|
|
215
197
|
saveConfig(config);
|
|
216
198
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
allowedNumbersList.forEach(num => console.log(chalk.gray(` - +${num}`)));
|
|
220
|
-
}
|
|
199
|
+
console.log(chalk.cyan('\nİzin verilen numara:'), chalk.white(`+${ownNumber} (kendi numaranız)`));
|
|
200
|
+
console.log(chalk.gray('Başka numara eklemek için: natureco whatsapp allow <numara>'));
|
|
221
201
|
|
|
222
202
|
console.log(chalk.green('\n✅ Kurulum tamamlandı!\n'));
|
|
223
203
|
console.log(chalk.yellow('Gateway ile başlatmak için:'), chalk.cyan('natureco gateway start'));
|