natureco-cli 5.5.0 → 5.5.2
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "natureco-cli",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.2",
|
|
4
4
|
"description": "OpenClaw'dan daha güvenli, daha hızlı, daha ucuz AI agent CLI. Multi-agent, self-evolving skills, audit log, maliyet optimizasyonu ve NatureCo platform-native.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"natureco": "bin/natureco.js"
|
|
@@ -170,8 +170,12 @@ async function runGatewayWorker() {
|
|
|
170
170
|
log('whatsapp', 'not configured, skipping', 'gray');
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
// Start Telegram if configured
|
|
174
|
-
if (config.telegramToken
|
|
173
|
+
// Start Telegram if configured (v5.5.2: sadece token yeterli, botId otomatik)
|
|
174
|
+
if (config.telegramToken) {
|
|
175
|
+
if (!config.telegramBotId) {
|
|
176
|
+
config.telegramBotId = `telegram_${Date.now()}`;
|
|
177
|
+
saveConfig(config);
|
|
178
|
+
}
|
|
175
179
|
log('telegram', 'starting bot...', 'cyan');
|
|
176
180
|
startTelegramProvider(config);
|
|
177
181
|
} else {
|
package/src/commands/setup.js
CHANGED
|
@@ -122,6 +122,28 @@ async function cmdWizard() {
|
|
|
122
122
|
console.log(chalk.gray(' Or use your own provider API key.\n'));
|
|
123
123
|
|
|
124
124
|
const currentKey = cfg.providerApiKey || '';
|
|
125
|
+
if (currentKey) {
|
|
126
|
+
console.log('');
|
|
127
|
+
console.log(chalk.yellow(' ⚠️ Mevcut API key tespit edildi (son 4 karakter: ' + currentKey.slice(-4) + ')'));
|
|
128
|
+
const reset = await inquirer.prompt([{
|
|
129
|
+
type: 'confirm',
|
|
130
|
+
name: 'fresh',
|
|
131
|
+
message: 'Sıfırdan yeni kurulum mu yapacaksın? (N = mevcut korunur)',
|
|
132
|
+
default: false,
|
|
133
|
+
}]);
|
|
134
|
+
if (reset.fresh) {
|
|
135
|
+
// Sifirla - tum eski kanallari temizle
|
|
136
|
+
delete cfg.telegramToken;
|
|
137
|
+
delete cfg.whatsappPhone;
|
|
138
|
+
delete cfg.discordToken;
|
|
139
|
+
delete cfg.slackToken;
|
|
140
|
+
delete cfg.signalBot;
|
|
141
|
+
delete cfg.mattermostBot;
|
|
142
|
+
delete cfg.smsTwilioSid;
|
|
143
|
+
delete cfg.webhooks;
|
|
144
|
+
console.log(chalk.green(' ✓ Eski ayarlar temizlendi'));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
125
147
|
const apiKey = await rlQuestion(` API Key ${currentKey ? '(leave blank to keep current)' : ''}: `);
|
|
126
148
|
if (apiKey) {
|
|
127
149
|
cfg.providerApiKey = apiKey;
|
package/src/commands/telegram.js
CHANGED
|
@@ -1,220 +1,279 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
|
-
const { getConfig, saveConfig } = require('../utils/config');
|
|
4
|
-
|
|
5
|
-
async function telegram(action, chatId) {
|
|
6
|
-
if (!action || action === 'connect') {
|
|
7
|
-
return connectTelegram();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (action === 'disconnect') {
|
|
11
|
-
return disconnectTelegram();
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (action === 'status') {
|
|
15
|
-
return statusTelegram();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (action === 'allow') {
|
|
19
|
-
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
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
return allowChat(chatId);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
console.log(chalk.
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
console.log(chalk.
|
|
116
|
-
|
|
117
|
-
console.log(chalk.
|
|
118
|
-
console.log(chalk.
|
|
119
|
-
console.log(chalk.gray('
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
allowedChats.
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
const inquirer = require('../utils/inquirer-wrapper');
|
|
3
|
+
const { getConfig, saveConfig } = require('../utils/config');
|
|
4
|
+
|
|
5
|
+
async function telegram(action, chatId) {
|
|
6
|
+
if (!action || action === 'connect') {
|
|
7
|
+
return connectTelegram();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
if (action === 'disconnect') {
|
|
11
|
+
return disconnectTelegram();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (action === 'status') {
|
|
15
|
+
return statusTelegram();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (action === 'allow') {
|
|
19
|
+
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
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
return allowChat(chatId);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (action === 'chatid' || action === 'auto-allow') {
|
|
28
|
+
return autoDetectChatId();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
console.log(chalk.red('\n❌ Unknown action\n'));
|
|
32
|
+
console.log(chalk.gray('Available actions: connect, disconnect, status, allow, chatid\n'));
|
|
33
|
+
console.log(chalk.gray(' chatid: Bot'u çalıştır, ilk mesajı bekle, chat ID'yi otomatik algıla\n'));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function connectTelegram() {
|
|
38
|
+
const config = getConfig();
|
|
39
|
+
|
|
40
|
+
if (!config.providerUrl) {
|
|
41
|
+
console.log(chalk.red('\n❌ Setup yapılmamış. Önce "natureco setup" çalıştırın.\n'));
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// v5.4.21: Eğer zaten token kaydedilmişse, kullanıcıya sor — değiştirmek ister mi?
|
|
46
|
+
if (config.telegramToken) {
|
|
47
|
+
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'));
|
|
51
|
+
const ans = await inquirer.prompt([{
|
|
52
|
+
type: 'confirm',
|
|
53
|
+
name: 'change',
|
|
54
|
+
message: 'Token değiştirmek istiyor musun?',
|
|
55
|
+
default: false,
|
|
56
|
+
}]);
|
|
57
|
+
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
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
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'));
|
|
70
|
+
|
|
71
|
+
process.stdin.resume();
|
|
72
|
+
|
|
73
|
+
const answers = await inquirer.prompt([
|
|
74
|
+
{
|
|
75
|
+
type: 'input',
|
|
76
|
+
name: 'token',
|
|
77
|
+
message: 'Telegram bot token:',
|
|
78
|
+
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
|
+
return true;
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
|
|
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'));
|
|
90
|
+
|
|
91
|
+
const chatIdAnswer = await inquirer.prompt([
|
|
92
|
+
{
|
|
93
|
+
type: 'input',
|
|
94
|
+
name: 'chatId',
|
|
95
|
+
message: 'Telegram Chat ID\'n:',
|
|
96
|
+
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
|
+
return true;
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
]);
|
|
103
|
+
|
|
104
|
+
// Telegram için bot ID oluştur (timestamp-based)
|
|
105
|
+
const botId = `telegram_${Date.now()}`;
|
|
106
|
+
|
|
107
|
+
console.log(chalk.yellow('\n⏳ Telegram bağlantısı kaydediliyor...\n'));
|
|
108
|
+
|
|
109
|
+
// Save to config (v2.x - no backend call)
|
|
110
|
+
config.telegramToken = answers.token.trim();
|
|
111
|
+
config.telegramBotId = botId;
|
|
112
|
+
config.telegramAllowedChats = [chatIdAnswer.chatId.trim()];
|
|
113
|
+
saveConfig(config);
|
|
114
|
+
|
|
115
|
+
console.log(chalk.green('✅ Telegram bot token kaydedildi!\n'));
|
|
116
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(botId));
|
|
117
|
+
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>'));
|
|
121
|
+
|
|
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'));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
async function disconnectTelegram() {
|
|
128
|
+
const config = getConfig();
|
|
129
|
+
|
|
130
|
+
if (!config.telegramToken) {
|
|
131
|
+
console.log(chalk.gray('\n⚠️ No Telegram connection found\n'));
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
process.stdin.resume();
|
|
136
|
+
|
|
137
|
+
const { confirm } = await inquirer.prompt([
|
|
138
|
+
{
|
|
139
|
+
type: 'confirm',
|
|
140
|
+
name: 'confirm',
|
|
141
|
+
message: 'Are you sure you want to disconnect Telegram?',
|
|
142
|
+
default: false,
|
|
143
|
+
},
|
|
144
|
+
]);
|
|
145
|
+
|
|
146
|
+
if (!confirm) {
|
|
147
|
+
console.log(chalk.gray('\nCancelled\n'));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Remove from config
|
|
152
|
+
delete config.telegramToken;
|
|
153
|
+
delete config.telegramBotId;
|
|
154
|
+
delete config.telegramAllowedChats;
|
|
155
|
+
saveConfig(config);
|
|
156
|
+
|
|
157
|
+
console.log(chalk.green('\n✅ Telegram disconnected\n'));
|
|
158
|
+
console.log(chalk.gray('Note: The bot is still active on Telegram.'));
|
|
159
|
+
console.log(chalk.gray('You may need to manually delete it via @BotFather.\n'));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function statusTelegram() {
|
|
163
|
+
const config = getConfig();
|
|
164
|
+
|
|
165
|
+
if (!config.telegramToken) {
|
|
166
|
+
console.log(chalk.gray('\n⚠️ Telegram not connected\n'));
|
|
167
|
+
console.log(chalk.gray('Connect with: natureco telegram connect\n'));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
console.log(chalk.green('\n✅ Telegram connected\n'));
|
|
172
|
+
console.log(chalk.cyan('Token:'), chalk.white(config.telegramToken.slice(0, 20) + '...'));
|
|
173
|
+
|
|
174
|
+
if (config.telegramBotId) {
|
|
175
|
+
console.log(chalk.cyan('Bot ID:'), chalk.white(config.telegramBotId));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// Show allowed chats
|
|
179
|
+
const allowedChats = config.telegramAllowedChats || [];
|
|
180
|
+
if (allowedChats.length === 0) {
|
|
181
|
+
console.log(chalk.cyan('İzin listesi:'), chalk.gray('Boş (herkesten mesaj kabul edilir)'));
|
|
182
|
+
} else {
|
|
183
|
+
console.log(chalk.cyan('İzin listesi:'));
|
|
184
|
+
allowedChats.forEach(chatId => console.log(chalk.white(` - ${chatId}`)));
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
console.log(chalk.gray('\nDisconnect with: natureco telegram disconnect\n'));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function allowChat(chatId) {
|
|
191
|
+
const config = getConfig();
|
|
192
|
+
|
|
193
|
+
if (!config.telegramToken) {
|
|
194
|
+
console.log(chalk.red('\n❌ Telegram not connected\n'));
|
|
195
|
+
console.log(chalk.gray('Connect first with: natureco telegram connect\n'));
|
|
196
|
+
process.exit(1);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Validate chat ID (should be numeric, can be negative for groups)
|
|
200
|
+
const normalized = chatId.trim();
|
|
201
|
+
|
|
202
|
+
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
|
+
process.exit(1);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const allowedChats = config.telegramAllowedChats || [];
|
|
209
|
+
|
|
210
|
+
if (allowedChats.includes(normalized)) {
|
|
211
|
+
console.log(chalk.yellow('\n⚠️ Bu chat ID zaten izin listesinde\n'));
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
allowedChats.push(normalized);
|
|
216
|
+
config.telegramAllowedChats = allowedChats;
|
|
217
|
+
saveConfig(config);
|
|
218
|
+
|
|
219
|
+
console.log(chalk.green('\n✅ Chat ID izin listesine eklendi\n'));
|
|
220
|
+
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
|
+
}
|
|
224
|
+
|
|
225
|
+
module.exports = telegram;
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* v5.5.2: Otomatik chat ID algilama
|
|
230
|
+
* Bot'u polling'de calistirir, ilk mesaji gelene kadar bekler
|
|
231
|
+
* Chat ID'yi otomatik kaydeder
|
|
232
|
+
*/
|
|
233
|
+
async function autoDetectChatId() {
|
|
234
|
+
const config = getConfig();
|
|
235
|
+
if (!config.telegramToken) {
|
|
236
|
+
console.log(chalk.red('\n❌ Once natureco telegram connect yapin\n'));
|
|
237
|
+
process.exit(1);
|
|
238
|
+
}
|
|
239
|
+
|
|
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
|
+
|
|
243
|
+
const TelegramBot = require('node-telegram-bot-api');
|
|
244
|
+
const bot = new TelegramBot(config.telegramToken, { polling: true });
|
|
245
|
+
|
|
246
|
+
let detected = false;
|
|
247
|
+
|
|
248
|
+
bot.on('message', (msg) => {
|
|
249
|
+
if (detected) return;
|
|
250
|
+
detected = true;
|
|
251
|
+
|
|
252
|
+
const chatId = String(msg.chat.id);
|
|
253
|
+
const name = msg.from?.first_name || msg.from?.username || 'Bilinmeyen';
|
|
254
|
+
|
|
255
|
+
console.log(chalk.green('\n✓ Mesaj alindi!'));
|
|
256
|
+
console.log(chalk.cyan(` Kullanici: ${name}`));
|
|
257
|
+
console.log(chalk.cyan(` Chat ID: ${chatId}`));
|
|
258
|
+
|
|
259
|
+
// Kaydet
|
|
260
|
+
if (!config.telegramAllowedChats) config.telegramAllowedChats = [];
|
|
261
|
+
if (!config.telegramAllowedChats.includes(chatId)) {
|
|
262
|
+
config.telegramAllowedChats.push(chatId);
|
|
263
|
+
}
|
|
264
|
+
saveConfig(config);
|
|
265
|
+
|
|
266
|
+
console.log(chalk.green('\n✅ Chat ID kaydedildi: ' + chatId + '\n'));
|
|
267
|
+
bot.stopPolling();
|
|
268
|
+
process.exit(0);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
// 60 saniye timeout
|
|
272
|
+
setTimeout(() => {
|
|
273
|
+
if (!detected) {
|
|
274
|
+
console.log(chalk.red('\n⏱ 60 saniye icinde mesaj gelmedi. Tekrar deneyin.\n'));
|
|
275
|
+
bot.stopPolling();
|
|
276
|
+
process.exit(1);
|
|
277
|
+
}
|
|
278
|
+
}, 60000);
|
|
279
|
+
}
|