add initial config
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
88
setup_config.py
Executable file
88
setup_config.py
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script de inicialización de configuración para WallaMonitor.
|
||||
|
||||
Este script copia los archivos de configuración de muestra (.sample)
|
||||
a sus ubicaciones finales si estos no existen.
|
||||
|
||||
Uso:
|
||||
python setup_config.py
|
||||
"""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
def setup_configuration():
|
||||
"""
|
||||
Inicializa los archivos de configuración necesarios.
|
||||
"""
|
||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
config_files = [
|
||||
{
|
||||
'name': 'config.yaml',
|
||||
'sample': 'config.sample.yaml',
|
||||
'description': 'Configuración de Telegram (token y canal)'
|
||||
},
|
||||
{
|
||||
'name': 'workers.json',
|
||||
'sample': 'workers.sample.json',
|
||||
'description': 'Configuración de búsquedas y monitores'
|
||||
}
|
||||
]
|
||||
|
||||
print("="*60)
|
||||
print(" WallaMonitor - Configuración Inicial")
|
||||
print("="*60)
|
||||
print()
|
||||
|
||||
files_created = False
|
||||
files_exist = []
|
||||
|
||||
for config in config_files:
|
||||
config_path = os.path.join(base_dir, config['name'])
|
||||
sample_path = os.path.join(base_dir, config['sample'])
|
||||
|
||||
if os.path.exists(config_path):
|
||||
files_exist.append(config['name'])
|
||||
print(f"✓ '{config['name']}' ya existe (no se sobrescribirá)")
|
||||
elif os.path.exists(sample_path):
|
||||
try:
|
||||
shutil.copy2(sample_path, config_path)
|
||||
files_created = True
|
||||
print(f"✓ '{config['name']}' creado desde '{config['sample']}'")
|
||||
print(f" → {config['description']}")
|
||||
except Exception as e:
|
||||
print(f"✗ Error al crear '{config['name']}': {e}")
|
||||
return False
|
||||
else:
|
||||
print(f"✗ ERROR: No se encontró el archivo de muestra '{config['sample']}'")
|
||||
return False
|
||||
|
||||
print()
|
||||
print("="*60)
|
||||
|
||||
if files_created:
|
||||
print("\n⚠️ IMPORTANTE: Edita los archivos de configuración antes de ejecutar:")
|
||||
print()
|
||||
print(" 1. config.yaml:")
|
||||
print(" - Añade tu token de Telegram Bot")
|
||||
print(" - Configura el canal/grupo de destino")
|
||||
print()
|
||||
print(" 2. workers.json:")
|
||||
print(" - Ajusta las búsquedas según tus necesidades")
|
||||
print(" - Configura los thread_id para tus hilos de Telegram")
|
||||
print()
|
||||
print(" Luego ejecuta: python wallamonitor.py")
|
||||
elif files_exist:
|
||||
print("\n✓ Todos los archivos de configuración ya existen.")
|
||||
print(" El sistema está listo para usar.")
|
||||
|
||||
print("\n" + "="*60)
|
||||
return True
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = setup_configuration()
|
||||
sys.exit(0 if success else 1)
|
||||
|
||||
Reference in New Issue
Block a user