create-bunspace 0.2.5 → 0.3.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/dist/templates/monorepo/apps/example/package.json +1 -1
- package/dist/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/dist/templates/monorepo/tsconfig.json +3 -1
- package/dist/templates/telegram-bot/CLAUDE.deploy.md +2 -3
- package/dist/templates/telegram-bot/CLAUDE.dev.md +304 -5
- package/dist/templates/telegram-bot/CLAUDE.md +166 -89
- package/dist/templates/telegram-bot/README.md +252 -129
- package/dist/templates/telegram-bot/bun.lock +132 -3
- package/dist/templates/telegram-bot/core/.env.example +6 -0
- package/dist/templates/telegram-bot/core/package.json +11 -0
- package/dist/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/core/src/config/env.ts +130 -1
- package/dist/templates/telegram-bot/core/src/config/logging.ts +4 -4
- package/dist/templates/telegram-bot/core/src/handlers/config-export.ts +123 -0
- package/dist/templates/telegram-bot/core/src/handlers/control.ts +46 -11
- package/dist/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/dist/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/dist/templates/telegram-bot/core/src/handlers/health.ts +40 -37
- package/dist/templates/telegram-bot/core/src/handlers/info.ts +189 -0
- package/dist/templates/telegram-bot/core/src/handlers/listener.ts +168 -0
- package/dist/templates/telegram-bot/core/src/handlers/logs.ts +16 -7
- package/dist/templates/telegram-bot/core/src/index.ts +49 -1
- package/dist/templates/telegram-bot/core/src/utils/formatters.ts +14 -33
- package/dist/templates/telegram-bot/core/src/utils/instance-manager.ts +6 -2
- package/dist/templates/telegram-bot/core/src/utils/message-builder.ts +180 -0
- package/dist/templates/telegram-bot/core/tsconfig.json +2 -0
- package/dist/templates/telegram-bot/docs/automatizacion_integral_de_bots_de_telegram_con_type_script.md +326 -0
- package/dist/templates/telegram-bot/docs/cli-commands.md +514 -5
- package/dist/templates/telegram-bot/docs/environment.md +191 -3
- package/dist/templates/telegram-bot/docs/getting-started.md +202 -15
- package/dist/templates/telegram-bot/package.json +7 -3
- package/dist/templates/telegram-bot/packages/utils/package.json +12 -1
- package/dist/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/dist/templates/telegram-bot/packages/utils/src/logger.ts +1 -0
- package/dist/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/dist/templates/telegram-bot/tools/commands/doctor.ts +62 -0
- package/dist/templates/telegram-bot/tools/commands/setup.ts +984 -170
- package/dist/templates/telegram-bot/tsconfig.json +7 -2
- package/package.json +1 -1
- package/templates/monorepo/apps/example/package.json +1 -1
- package/templates/monorepo/core/packages/utils/rolldown.config.ts +30 -0
- package/templates/monorepo/tsconfig.json +3 -1
- package/templates/telegram-bot/CLAUDE.deploy.md +2 -3
- package/templates/telegram-bot/CLAUDE.dev.md +304 -5
- package/templates/telegram-bot/CLAUDE.md +166 -89
- package/templates/telegram-bot/README.md +252 -129
- package/templates/telegram-bot/bun.lock +132 -3
- package/templates/telegram-bot/core/.env.example +6 -0
- package/templates/telegram-bot/core/package.json +11 -0
- package/templates/telegram-bot/core/rolldown.config.ts +11 -0
- package/templates/telegram-bot/core/src/config/env.ts +130 -1
- package/templates/telegram-bot/core/src/config/logging.ts +4 -4
- package/templates/telegram-bot/core/src/handlers/config-export.ts +123 -0
- package/templates/telegram-bot/core/src/handlers/control.ts +46 -11
- package/templates/telegram-bot/core/src/handlers/demo-full.ts +58 -0
- package/templates/telegram-bot/core/src/handlers/demo-keyboard.ts +49 -0
- package/templates/telegram-bot/core/src/handlers/demo-media.ts +163 -0
- package/templates/telegram-bot/core/src/handlers/demo-text.ts +27 -0
- package/templates/telegram-bot/core/src/handlers/health.ts +40 -37
- package/templates/telegram-bot/core/src/handlers/info.ts +189 -0
- package/templates/telegram-bot/core/src/handlers/listener.ts +168 -0
- package/templates/telegram-bot/core/src/handlers/logs.ts +16 -7
- package/templates/telegram-bot/core/src/index.ts +49 -1
- package/templates/telegram-bot/core/src/utils/formatters.ts +14 -33
- package/templates/telegram-bot/core/src/utils/instance-manager.ts +6 -2
- package/templates/telegram-bot/core/tsconfig.json +2 -0
- package/templates/telegram-bot/docs/automatizacion_integral_de_bots_de_telegram_con_type_script.md +326 -0
- package/templates/telegram-bot/docs/cli-commands.md +514 -5
- package/templates/telegram-bot/docs/environment.md +191 -3
- package/templates/telegram-bot/docs/getting-started.md +202 -15
- package/templates/telegram-bot/package.json +7 -3
- package/templates/telegram-bot/packages/utils/package.json +12 -1
- package/templates/telegram-bot/packages/utils/rolldown.config.ts +11 -0
- package/templates/telegram-bot/packages/utils/src/logger.ts +1 -0
- package/templates/telegram-bot/packages/utils/tsconfig.json +10 -0
- package/templates/telegram-bot/tools/commands/doctor.ts +62 -0
- package/templates/telegram-bot/tools/commands/setup.ts +984 -170
- package/templates/telegram-bot/tsconfig.json +7 -2
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Referencia completa de comandos CLI disponibles para gestionar el bot.
|
|
4
4
|
|
|
5
|
+
## Flujo Recomendado
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# 1. Setup del entorno (configura todo)
|
|
9
|
+
bun run setup
|
|
10
|
+
|
|
11
|
+
# 2. Doctor (verifica que todo esté correcto)
|
|
12
|
+
bun run doctor
|
|
13
|
+
|
|
14
|
+
# 3. Arrancar bot
|
|
15
|
+
bun run dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
> **Setup → Doctor → Dev** es el flujo recomendado para cualquier cambio de configuración.
|
|
19
|
+
|
|
5
20
|
## Setup Command
|
|
6
21
|
|
|
7
22
|
Configura el entorno del bot de forma interactiva.
|
|
@@ -38,11 +53,27 @@ bun run setup --token "123:ABC"
|
|
|
38
53
|
|
|
39
54
|
### Qué Hace
|
|
40
55
|
|
|
41
|
-
1. **
|
|
42
|
-
2. **Pregunta**
|
|
43
|
-
3. **
|
|
44
|
-
4. **Configura**
|
|
45
|
-
5. **Muestra**
|
|
56
|
+
1. **Detecta** contexto actual (qué existe, qué falta)
|
|
57
|
+
2. **Pregunta** objetivo (new-bot, add-ids, create-topics, bootstrap, manual)
|
|
58
|
+
3. **Ejecuta** pre-checks de validación
|
|
59
|
+
4. **Configura** campos necesarios según modo seleccionado
|
|
60
|
+
5. **Muestra** resumen de cambios
|
|
61
|
+
6. **Sugiere** ejecutar `bun run doctor` para verificar
|
|
62
|
+
|
|
63
|
+
### Siguiente Paso Recomendado
|
|
64
|
+
|
|
65
|
+
Después de setup, **siempre ejecuta doctor**:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
bun run doctor
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Esto valida:
|
|
72
|
+
- Token válido contra Telegram API
|
|
73
|
+
- Variables de entorno configuradas
|
|
74
|
+
- Dependencias instaladas
|
|
75
|
+
- Puertos disponibles
|
|
76
|
+
- Permisos de directorios
|
|
46
77
|
|
|
47
78
|
### Flujo Interactivo
|
|
48
79
|
|
|
@@ -370,6 +401,484 @@ bun run ngrok --environment staging
|
|
|
370
401
|
bun run ngrok --environment production --webhook-url
|
|
371
402
|
```
|
|
372
403
|
|
|
404
|
+
## Bootstrap Command
|
|
405
|
+
|
|
406
|
+
Crea automáticamente un bot, grupo y topics mediante interacción con @BotFather.
|
|
407
|
+
|
|
408
|
+
> **Versión Multibot**: El bootstrapper ahora soporta gestión de múltiples bots con detección de existentes y reutilización.
|
|
409
|
+
|
|
410
|
+
> **Este es un "BotFather personal"** - automatiza todo el proceso de creación de bots.
|
|
411
|
+
|
|
412
|
+
### Uso
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
bun run bootstrap
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Flags
|
|
419
|
+
|
|
420
|
+
| Flag | Descripción | Default |
|
|
421
|
+
| ---- | ----------- | ------- |
|
|
422
|
+
| `-e, --environment <local\|staging\|production>` | Entorno objetivo | `local` |
|
|
423
|
+
| `--bot <username>` | Bot username específico (sin @) | Prompt interactivo |
|
|
424
|
+
| `--list` | Listar bots disponibles desde BotFather | `false` |
|
|
425
|
+
| `--reuse` | Reutilizar configuración existente sin prompts | `false` |
|
|
426
|
+
| `--force` | Forzar recreación de recursos | `false` |
|
|
427
|
+
| `--skip-topics` | Skip creación de topics | `false` |
|
|
428
|
+
| `--bot-name <value>` | Nombre del bot (display name) | Prompt interactivo |
|
|
429
|
+
| `--bot-username <value>` | Username del bot (debe terminar en "bot") | Prompt interactivo |
|
|
430
|
+
| `--group-name <value>` | Nombre del grupo/forum | Prompt interactivo |
|
|
431
|
+
|
|
432
|
+
### Ejemplos
|
|
433
|
+
|
|
434
|
+
```bash
|
|
435
|
+
# Bootstrap interactivo completo (recomendado)
|
|
436
|
+
bun run bootstrap
|
|
437
|
+
|
|
438
|
+
# Listar bots disponibles desde BotFather
|
|
439
|
+
bun run bootstrap --list
|
|
440
|
+
|
|
441
|
+
# Bootstrap para bot específico
|
|
442
|
+
bun run bootstrap --bot mybot123bot
|
|
443
|
+
|
|
444
|
+
# Bootstrap con nombres pre-proveídos
|
|
445
|
+
bun run bootstrap --bot-name "Mi Bot" --bot-username "mi_bot_v1" --group-name "Control Group"
|
|
446
|
+
|
|
447
|
+
# Bootstrap para staging
|
|
448
|
+
bun run bootstrap --environment staging
|
|
449
|
+
|
|
450
|
+
# Reutilizar configuración existente sin prompts
|
|
451
|
+
bun run bootstrap --reuse
|
|
452
|
+
|
|
453
|
+
# Bootstrap sin crear topics
|
|
454
|
+
bun run bootstrap --skip-topics
|
|
455
|
+
|
|
456
|
+
# Forzar recreación de recursos
|
|
457
|
+
bun run bootstrap --force
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### Requisitos Previos
|
|
461
|
+
|
|
462
|
+
Antes de ejecutar bootstrap, necesitas **credenciales MTProto API**:
|
|
463
|
+
|
|
464
|
+
1. Ve a [https://my.telegram.org](https://my.telegram.org)
|
|
465
|
+
2. Log in con tu número de teléfono
|
|
466
|
+
3. Click en "API development tools"
|
|
467
|
+
4. Llena el formulario:
|
|
468
|
+
- **App title**: My Bot App
|
|
469
|
+
- **Short name**: mybotapp
|
|
470
|
+
- **Platform**: Desktop o Web
|
|
471
|
+
- **Description**: (opcional)
|
|
472
|
+
5. Click "Create application"
|
|
473
|
+
6. Copia el `api_id` y `api_hash`
|
|
474
|
+
|
|
475
|
+
> **Puedes guardar las credenciales** en tu `.env` para evitar re-pedirlas:
|
|
476
|
+
> ```bash
|
|
477
|
+
> # MTProto API Credentials (for bootstrap command)
|
|
478
|
+
> TG_API_ID=12345678
|
|
479
|
+
> TG_API_HASH=abc123def456789...
|
|
480
|
+
> ```
|
|
481
|
+
|
|
482
|
+
### Flujo Interactivo
|
|
483
|
+
|
|
484
|
+
#### Paso 1: Verificación de Entorno
|
|
485
|
+
|
|
486
|
+
```
|
|
487
|
+
ℹ Environment file found: core/.env.local
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
#### Paso 2: Credenciales MTProto (si no están en .env)
|
|
491
|
+
|
|
492
|
+
```
|
|
493
|
+
📱 Telegram MTProto API Credentials
|
|
494
|
+
|
|
495
|
+
To create bots and groups automatically, you need MTProto API credentials.
|
|
496
|
+
|
|
497
|
+
📋 STEP-BY-STEP GUIDE:
|
|
498
|
+
|
|
499
|
+
1. Open https://my.telegram.org in your browser
|
|
500
|
+
2. Log in with your phone number (the same number you use in Telegram)
|
|
501
|
+
3. Click on "API development tools"
|
|
502
|
+
4. Fill in the form:
|
|
503
|
+
- App title: My Bot App
|
|
504
|
+
- Short name: mybotapp
|
|
505
|
+
- Platform: Desktop or Web
|
|
506
|
+
- Description: (optional)
|
|
507
|
+
5. Click "Create application"
|
|
508
|
+
6. Copy the api_id and api_hash from the next page
|
|
509
|
+
|
|
510
|
+
? Do you want to save API credentials to .env file for future use? (Y/n)
|
|
511
|
+
|
|
512
|
+
? Enter your API ID: ********
|
|
513
|
+
|
|
514
|
+
? Enter your API Hash: ************************************
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
#### Paso 3: Autorización de Telegram
|
|
518
|
+
|
|
519
|
+
Si es tu primera vez, te pedirá autorización:
|
|
520
|
+
|
|
521
|
+
```
|
|
522
|
+
🔐 Telegram Authorization Required
|
|
523
|
+
This is a one-time process. Your session will be saved for future use.
|
|
524
|
+
|
|
525
|
+
📝 STEP 1: Phone Number
|
|
526
|
+
Enter your phone number with country code.
|
|
527
|
+
Example: +34612345678 (Spain) or +12025551234 (USA)
|
|
528
|
+
|
|
529
|
+
? Enter your phone number: +34612345678
|
|
530
|
+
|
|
531
|
+
⏳ Sending verification code...
|
|
532
|
+
Check your Telegram app for the code.
|
|
533
|
+
|
|
534
|
+
📝 STEP 2: Verification Code
|
|
535
|
+
Enter the code you received in Telegram.
|
|
536
|
+
The code is 5-7 digits long.
|
|
537
|
+
|
|
538
|
+
? Enter the code: 12345
|
|
539
|
+
|
|
540
|
+
⏳ Verifying code...
|
|
541
|
+
✅ Code verified!
|
|
542
|
+
|
|
543
|
+
📝 STEP 3: Two-Factor Authentication (2FA)
|
|
544
|
+
You have Cloud Password enabled.
|
|
545
|
+
Enter your password to continue.
|
|
546
|
+
|
|
547
|
+
? Enter your 2FA password: ********
|
|
548
|
+
|
|
549
|
+
⏳ Verifying password...
|
|
550
|
+
✅ Password verified!
|
|
551
|
+
|
|
552
|
+
💾 Saving session...
|
|
553
|
+
|
|
554
|
+
✅ Successfully authorized!
|
|
555
|
+
Your session has been saved to: /Users/youruser/.mks-telegram-bot/session.txt
|
|
556
|
+
Next time you won't need to login again.
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
> **Tu sesión se guarda automáticamente** en `~/.mks-telegram-bot/session.txt` para futuros usos.
|
|
560
|
+
|
|
561
|
+
#### Paso 4: Creación del Bot
|
|
562
|
+
|
|
563
|
+
```
|
|
564
|
+
🚀 Complete Bot Bootstrap
|
|
565
|
+
|
|
566
|
+
🤖 Step 1: Creating Bot
|
|
567
|
+
|
|
568
|
+
⠋ Creating bot via @BotFather...
|
|
569
|
+
✓ Bot created: @mi_bot_v1
|
|
570
|
+
```
|
|
571
|
+
|
|
572
|
+
#### Paso 5: Creación del Grupo/Forum
|
|
573
|
+
|
|
574
|
+
```
|
|
575
|
+
💬 Step 2: Creating Group/Forum
|
|
576
|
+
|
|
577
|
+
⠋ Creating supergroup with forum mode...
|
|
578
|
+
✓ Group created: Control Group (ID: -1001234567890)
|
|
579
|
+
|
|
580
|
+
⠋ Adding bot as admin...
|
|
581
|
+
✓ Bot added as admin
|
|
582
|
+
```
|
|
583
|
+
|
|
584
|
+
#### Paso 6: Creación de Topics
|
|
585
|
+
|
|
586
|
+
```
|
|
587
|
+
🧵 Step 3: Creating Topics
|
|
588
|
+
|
|
589
|
+
⠋ Creating forum topics...
|
|
590
|
+
✓ Created 5 topics
|
|
591
|
+
General: 1
|
|
592
|
+
Control: 2
|
|
593
|
+
Logs: 3
|
|
594
|
+
Config: 4
|
|
595
|
+
Bugs: 5
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
#### Paso 7: Actualización de Configuración
|
|
599
|
+
|
|
600
|
+
```
|
|
601
|
+
🔧 Step 4: Updating Configuration
|
|
602
|
+
|
|
603
|
+
⠋ Updating .env file...
|
|
604
|
+
✓ Updated core/.env.local
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
### Resumen Final
|
|
608
|
+
|
|
609
|
+
```
|
|
610
|
+
✅ Bootstrap Complete
|
|
611
|
+
|
|
612
|
+
Bot Information:
|
|
613
|
+
Username: @mi_bot_v1
|
|
614
|
+
Token: 123456:ABC-...
|
|
615
|
+
|
|
616
|
+
Group Information:
|
|
617
|
+
Name: Control Group
|
|
618
|
+
Chat ID: -1001234567890
|
|
619
|
+
|
|
620
|
+
Topic IDs:
|
|
621
|
+
General: 1
|
|
622
|
+
Control: 2
|
|
623
|
+
Logs: 3
|
|
624
|
+
Config: 4
|
|
625
|
+
Bugs: 5
|
|
626
|
+
|
|
627
|
+
✓ Your bot is now ready to use!
|
|
628
|
+
|
|
629
|
+
ℹ Next steps:
|
|
630
|
+
1. Review the configuration in core/.env.local
|
|
631
|
+
2. Run: bun run dev
|
|
632
|
+
3. Send /start to your bot in Telegram
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### Qué Hace
|
|
636
|
+
|
|
637
|
+
El comando bootstrap automatiza **todo el proceso**:
|
|
638
|
+
|
|
639
|
+
1. **Verifica** que el entorno existe (ejecuta `setup` si es necesario)
|
|
640
|
+
2. **Obtiene** credenciales MTProto API (del .env o interactivo)
|
|
641
|
+
3. **Autentica** con tu cuenta de Telegram (sesión guardada para futuro)
|
|
642
|
+
4. **Crea el bot** vía @BotFather automáticamente
|
|
643
|
+
5. **Crea un supergroup/forum** para el bot
|
|
644
|
+
6. **Añade el bot como admin** del grupo
|
|
645
|
+
7. **Crea topics** automáticamente (General, Control, Logs, Config, Bugs)
|
|
646
|
+
8. **Actualiza el .env** con todos los IDs (bot token, chat ID, topic IDs)
|
|
647
|
+
9. **Muestra el resumen** con próximos pasos
|
|
648
|
+
|
|
649
|
+
### Variables de Entorno Configuradas
|
|
650
|
+
|
|
651
|
+
Después de bootstrap, tu `.env` tendrá:
|
|
652
|
+
|
|
653
|
+
```bash
|
|
654
|
+
# Configurado automáticamente por bootstrap
|
|
655
|
+
TG_BOT_TOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
|
|
656
|
+
TG_CONTROL_CHAT_ID=-1001234567890
|
|
657
|
+
TG_CONTROL_TOPIC_ID=2
|
|
658
|
+
TG_LOG_TOPIC_ID=3
|
|
659
|
+
TG_LOG_CHAT_ID=-1001234567890
|
|
660
|
+
|
|
661
|
+
# MTProto credentials (si guardaste)
|
|
662
|
+
TG_API_ID=12345678
|
|
663
|
+
TG_API_HASH=abc123def456789...
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
### Ventajas vs Setup Manual
|
|
667
|
+
|
|
668
|
+
| Feature | Bootstrap | Setup Manual |
|
|
669
|
+
|---------|-----------|--------------|
|
|
670
|
+
| Creación de bot | Automático (@BotFather) | Manual (hablar con @BotFather) |
|
|
671
|
+
| Creación de grupo | Automático | Manual |
|
|
672
|
+
| Creación de topics | Automática | Manual (o comando separado) |
|
|
673
|
+
| IDs detection | Automático | Requiere auto-configure |
|
|
674
|
+
| Tiempo total | ~3-5 minutos | ~10-15 minutos |
|
|
675
|
+
| Interacción | Una sola vez | Varios pasos |
|
|
676
|
+
|
|
677
|
+
### Troubleshooting
|
|
678
|
+
|
|
679
|
+
#### Error: "Environment file not found"
|
|
680
|
+
|
|
681
|
+
```bash
|
|
682
|
+
# Primero ejecuta setup para crear el entorno
|
|
683
|
+
bun run setup
|
|
684
|
+
# Luego bootstrap
|
|
685
|
+
bun run bootstrap
|
|
686
|
+
```
|
|
687
|
+
|
|
688
|
+
#### Error: "Authorization failed"
|
|
689
|
+
|
|
690
|
+
- Verifica que tu número de teléfono sea correcto (con código de país)
|
|
691
|
+
- Asegúrate de recibir el código de verificación en tu Telegram
|
|
692
|
+
- Si tienes 2FA, ten tu contraseña lista
|
|
693
|
+
|
|
694
|
+
#### Error: "Failed to create bot"
|
|
695
|
+
|
|
696
|
+
- El username puede estar en uso (prueba otro)
|
|
697
|
+
- El username debe terminar en "bot"
|
|
698
|
+
- Verifica que @BotFather no esté bloqueado
|
|
699
|
+
|
|
700
|
+
#### Sesión Corrupta
|
|
701
|
+
|
|
702
|
+
Si tienes problemas con la sesión guardada:
|
|
703
|
+
|
|
704
|
+
```bash
|
|
705
|
+
# Elimina la sesión
|
|
706
|
+
rm ~/.mks-telegram-bot/session.txt
|
|
707
|
+
|
|
708
|
+
# Vuelve a ejecutar bootstrap (te pedirá login de nuevo)
|
|
709
|
+
bun run bootstrap
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
### Seguridad
|
|
713
|
+
|
|
714
|
+
- **Las credenciales MTProto** se guardan en tu `.env` (nunca en el repo, está en `.gitignore`)
|
|
715
|
+
- **La sesión de Telegram** se guarda en `~/.mks-telegram-bot/session.txt` (fuera del repo)
|
|
716
|
+
- **El bot token** se guarda en el `.env` del entorno correspondiente
|
|
717
|
+
|
|
718
|
+
> **IMPORTANTE**: Nunca commits los archivos `.env.*` ni la sesión.
|
|
719
|
+
|
|
720
|
+
## Bot Management Commands
|
|
721
|
+
|
|
722
|
+
Comandos para gestionar múltiples configuraciones de bots en el mismo proyecto.
|
|
723
|
+
|
|
724
|
+
> **Sistema Multibot**: Gestiona múltiples bots desde un mismo proyecto con configuraciones independientes.
|
|
725
|
+
|
|
726
|
+
### `bot list`
|
|
727
|
+
|
|
728
|
+
Lista todos los bots configurados en el proyecto.
|
|
729
|
+
|
|
730
|
+
```bash
|
|
731
|
+
bun run bot list
|
|
732
|
+
```
|
|
733
|
+
|
|
734
|
+
#### Output
|
|
735
|
+
|
|
736
|
+
```
|
|
737
|
+
📋 Configured Bots
|
|
738
|
+
|
|
739
|
+
Found 2 configured bot(s):
|
|
740
|
+
|
|
741
|
+
✓ @mybot123bot
|
|
742
|
+
Environments: local, staging, production
|
|
743
|
+
Name: My Bot
|
|
744
|
+
Created: 01/07/2025
|
|
745
|
+
|
|
746
|
+
@anotherbot456bot
|
|
747
|
+
Environments: local
|
|
748
|
+
Name: Another Bot
|
|
749
|
+
Created: 01/05/2025
|
|
750
|
+
|
|
751
|
+
✓ Active bot: @mybot123bot
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
### `bot use <username>`
|
|
755
|
+
|
|
756
|
+
Establece un bot como activo.
|
|
757
|
+
|
|
758
|
+
```bash
|
|
759
|
+
bun run bot use mybot123bot
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
#### Qué Hace
|
|
763
|
+
|
|
764
|
+
- Actualiza el symlink `.active` para apuntar al bot seleccionado
|
|
765
|
+
- Todos los comandos subsecuentes (`bun run dev`, `bun run start`) usarán este bot
|
|
766
|
+
|
|
767
|
+
#### Output
|
|
768
|
+
|
|
769
|
+
```
|
|
770
|
+
✓ @mybot123bot is now the active bot
|
|
771
|
+
```
|
|
772
|
+
|
|
773
|
+
### `bot info <username>`
|
|
774
|
+
|
|
775
|
+
Muestra información detallada de un bot específico.
|
|
776
|
+
|
|
777
|
+
```bash
|
|
778
|
+
bun run bot info mybot123bot
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
#### Output
|
|
782
|
+
|
|
783
|
+
```
|
|
784
|
+
ℹ️ Bot Information: @mybot123bot
|
|
785
|
+
|
|
786
|
+
Basic Information:
|
|
787
|
+
Username: @mybot123bot
|
|
788
|
+
Active: Yes
|
|
789
|
+
|
|
790
|
+
Environments:
|
|
791
|
+
Local: ✓
|
|
792
|
+
Staging: ✓
|
|
793
|
+
Production: ✓
|
|
794
|
+
|
|
795
|
+
Metadata:
|
|
796
|
+
Name: My Bot
|
|
797
|
+
Created: 1/7/2025, 2:30:45 PM
|
|
798
|
+
Updated: 1/7/2025, 3:15:22 PM
|
|
799
|
+
Description: My awesome Telegram bot
|
|
800
|
+
Tags: test, demo
|
|
801
|
+
|
|
802
|
+
LOCAL Configuration:
|
|
803
|
+
Token: 123456:ABC...
|
|
804
|
+
Control Chat ID: -1001234567890
|
|
805
|
+
Control Topic ID: 2
|
|
806
|
+
Log Chat ID: -1001234567890
|
|
807
|
+
Log Topic ID: 3
|
|
808
|
+
|
|
809
|
+
STAGING Configuration:
|
|
810
|
+
Token: 789012:DEF...
|
|
811
|
+
Control Chat ID: -1009876543210
|
|
812
|
+
Control Topic ID: 5
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
### `bot delete <username>`
|
|
816
|
+
|
|
817
|
+
Elimina la configuración de un bot.
|
|
818
|
+
|
|
819
|
+
```bash
|
|
820
|
+
bun run bot delete mybot123bot
|
|
821
|
+
|
|
822
|
+
# Skip confirmación
|
|
823
|
+
bun run bot delete mybot123bot --force
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
#### Flags
|
|
827
|
+
|
|
828
|
+
| Flag | Descripción |
|
|
829
|
+
| ---- | ----------- |
|
|
830
|
+
| `-f, --force` | Skip confirmación prompt |
|
|
831
|
+
|
|
832
|
+
#### Qué Hace
|
|
833
|
+
|
|
834
|
+
- Elimina el directorio `.envs/{bot}/` completo
|
|
835
|
+
- Si el bot estaba activo, limpia el symlink `.active`
|
|
836
|
+
- Pide confirmación unless `--force`
|
|
837
|
+
|
|
838
|
+
#### Output
|
|
839
|
+
|
|
840
|
+
```
|
|
841
|
+
⠋ Deleting bot '@mybot123bot'...
|
|
842
|
+
✓ Bot '@mybot123bot' deleted
|
|
843
|
+
ℹ Active bot cleared. Use "bun run bot use <username>" to set a new active bot.
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
### `bot migrate`
|
|
847
|
+
|
|
848
|
+
Migra archivos `.env.{env}` antiguos a la nueva estructura `.envs/{bot}/{env}.env`.
|
|
849
|
+
|
|
850
|
+
```bash
|
|
851
|
+
bun run bot migrate
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
#### Qué Hace
|
|
855
|
+
|
|
856
|
+
- Detecta archivos `.env.local`, `.env.staging`, `.env.production` en `core/`
|
|
857
|
+
- Extrae el bot token para determinar el bot username
|
|
858
|
+
- Crea la nueva estructura `.envs/{bot}/{env}.env`
|
|
859
|
+
- Mueve las variables de entorno a los nuevos archivos
|
|
860
|
+
- Crea `metadata.json` con información del bot
|
|
861
|
+
- Actualiza el symlink `.active`
|
|
862
|
+
- Hace backup de archivos antiguos como `.env.{env}.backup`
|
|
863
|
+
|
|
864
|
+
#### Output
|
|
865
|
+
|
|
866
|
+
```
|
|
867
|
+
🔄 Migrate Old .env Files
|
|
868
|
+
|
|
869
|
+
This command will migrate old .env.{environment} files
|
|
870
|
+
to the new .envs/{bot}/{environment}.env structure.
|
|
871
|
+
Old files will be backed up as .env.{environment}.backup
|
|
872
|
+
|
|
873
|
+
? Do you want to proceed with migration? (Y/n)
|
|
874
|
+
|
|
875
|
+
⠋ Migrating .env files...
|
|
876
|
+
✓ Migration completed successfully
|
|
877
|
+
|
|
878
|
+
Migrated bots:
|
|
879
|
+
@mybot123bot
|
|
880
|
+
```
|
|
881
|
+
|
|
373
882
|
## Referencias
|
|
374
883
|
|
|
375
884
|
- [Getting Started](./getting-started.md) - Guía de inicio
|