|
20 | 20 | ┌─────────────────────┐ guarda datos ┌──────▼──────────┐ |
21 | 21 | │ Repo: cYHBernews │ ◄──────────────── │ noticias.json │ |
22 | 22 | └─────────────────────┘ └─────────────────┘ |
23 | | -``` |
24 | | - |
25 | | -### Componentes |
26 | | - |
27 | | -1. **GitHub Actions** (`.github/workflows/bot.yml`): El motor del bot. Se ejecuta automáticamente cada 3 horas o manualmente vía webhook. Realiza el scraping, resume con IA y envía a Telegram. |
28 | | -2. **Cloudflare Workers** (`api/webhook.js`): El receptor. Recibe mensajes de Telegram y dispara el Action de GitHub cuando se usa `/noticias`. |
29 | | -3. **Repositorio externo** (`DevCop95/cYHBernews`): El historial. Las noticias se guardan en `noticias.json` para deduplicación y persistencia. |
30 | | - |
31 | | ---- |
32 | | - |
33 | | -## 🚀 Setup |
34 | | - |
35 | | -### 1. GitHub Secrets |
36 | | - |
37 | | -Ve a **Settings > Secrets and variables > Actions** en este repositorio y configura: |
38 | | - |
39 | | -| Secreto | Descripción | |
40 | | -|---------|-------------| |
41 | | -| `GIT_TOKEN` | Personal Access Token (Classic) con scopes `repo` y `workflow` | |
42 | | -| `TELEGRAM_TOKEN` | Token del bot obtenido con @BotFather | |
43 | | -| `TELEGRAM_CHAT_ID` | Tu ID de Telegram (obtenido con @userinfobot) | |
44 | | -| `GROQ_API_KEY` | API Key de [console.groq.com](https://console.groq.com/) | |
45 | | -| `UNSPLASH_ACCESS_KEY` | (Opcional) Para imágenes aleatorias en las noticias | |
46 | | - |
47 | | -### 2. Cloudflare Workers — Variables de entorno |
48 | | - |
49 | | -En tu dashboard de Cloudflare Workers > tu worker > **Settings > Variables and Secrets**: |
50 | | - |
51 | | -| Variable | Valor | |
52 | | -|----------|-------| |
53 | | -| `TELEGRAM_TOKEN_ENV` | El mismo token de Telegram | |
54 | | -| `TELEGRAM_CHAT_ID_ENV` | Tu ID de Telegram | |
55 | | -| `GH_PAT_ENV` | El mismo `GIT_TOKEN` de GitHub | |
56 | | - |
57 | | -### 3. Registrar el Webhook en Telegram |
58 | | - |
59 | | -Ejecuta una sola vez en el navegador o con curl: |
60 | | - |
61 | | -``` |
62 | | -https://api.telegram.org/bot<TU_TOKEN>/setWebhook?url=https://dev101_bot.dev101-bot.workers.dev |
63 | | -``` |
64 | | - |
65 | | ---- |
66 | | - |
67 | | -## 🤖 Comandos disponibles |
68 | | - |
69 | | -| Comando | Descripción | |
70 | | -|---------|-------------| |
71 | | -| `/noticias` | Fuerza la búsqueda y envío de noticias al instante | |
72 | | -| `/help` | Muestra los comandos disponibles | |
73 | | - |
74 | | -El bot también envía noticias automáticamente **cada 3 horas** vía cron en GitHub Actions. |
75 | | - |
76 | | ---- |
77 | | - |
78 | | -## 📁 Estructura del proyecto |
79 | | - |
80 | | -``` |
81 | | -dev101_bot/ |
82 | | -├── .github/ |
83 | | -│ └── workflows/ |
84 | | -│ └── bot.yml # Workflow de GitHub Actions (cron + dispatch) |
85 | | -├── api/ |
86 | | -│ └── webhook.js # Cloudflare Worker — recibe mensajes de Telegram |
87 | | -├── run_job.py # Script principal — scraping, IA y publicación |
88 | | -├── requirements.txt # Dependencias Python |
89 | | -├── wrangler.toml # Config de Cloudflare Workers |
90 | | -├── .env.example # Plantilla de variables de entorno |
91 | | -└── .gitignore |
92 | | -``` |
93 | | - |
94 | | ---- |
95 | | - |
96 | | -## 📰 Fuentes de noticias |
97 | | - |
98 | | -| Fuente | Categoría | |
99 | | -|--------|-----------| |
100 | | -| CyberSecurity News | Ciberseguridad / IA | |
101 | | -| WeLiveSecurity (ESET) | Ciberseguridad | |
102 | | -| Xataka | IA | |
103 | | -| WIRED en Español | IA | |
104 | | - |
105 | | ---- |
106 | | - |
107 | | -## 📦 Dependencias |
108 | | - |
109 | | -``` |
110 | | -requests |
111 | | -beautifulsoup4 |
112 | | -groq |
113 | | -python-dotenv |
114 | | -``` |
115 | 23 |
|
116 | 24 | --- |
117 | 25 |
|
|
0 commit comments