Skip to content

A curated collection of practical AI projects implementing OCR systems, RAG, AI agents, and other AI use cases.

feat: add Daily AI News Digest project

Tiioluwani9db4eedb2393
diff --git a/daily-news-digest/.env.example b/daily-news-digest/.env.example
new file mode 100644
index 0000000..de7c527
--- /dev/null
+++ b/daily-news-digest/.env.example
@@ -0,0 +1,3 @@
+MINIMAX_API_KEY=your_minimax_api_key_here
+TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
+TELEGRAM_CHAT_ID=your_telegram_chat_id_here
diff --git a/daily-news-digest/.gitignore b/daily-news-digest/.gitignore
new file mode 100644
index 0000000..21e6900
--- /dev/null
+++ b/daily-news-digest/.gitignore
@@ -0,0 +1,8 @@
+__pycache__/
+*.pyc
+.env
+*.log
+delivered_urls.json
+.venv/
+.claude/
+.idea/
diff --git a/daily-news-digest/README.md b/daily-news-digest/README.md
new file mode 100644
index 0000000..b25d651
--- /dev/null
+++ b/daily-news-digest/README.md
@@ -0,0 +1,120 @@
+# Daily AI News Digest
+
+Automated daily digest from 92 Karpathy-curated tech blogs, delivered to Telegram at 8 AM every morning. MiniMax M2.7 scores every article fetched in the last 24 hours and picks the 3 most significant stories.
+
+## How it works
+
+```
+92 RSS Feeds → Fetch → Filter 24h → MiniMax M2.7 scores → Top 3 articles → Format → Telegram
+```
+
+1. `scripts/fetch_rss.py` fetches all feeds in parallel and keeps only articles published in the last 24 hours
+2. `skill.py` sends the article list to MiniMax M2.7, which scores each one and returns the top 3 as structured JSON
+3. Articles are grouped into categories — **Breaking**, **Important**, or **Notable** — and formatted as a Telegram message
+4. Empty categories are omitted automatically
+
+## Prerequisites
+
+- [OpenClaw](https://openclaw.dev) installed
+- MiniMax API key from [platform.minimax.io](https://platform.minimax.io)
+- Telegram bot token from [@BotFather](https://t.me/BotFather) and a chat/channel ID
+
+## Setup
+
+### 1. Install dependencies
+
+```bash
+pip install -r requirements.txt
+```
+
+### 2. Configure environment variables
+
+```bash
+cp .env.example .env
+```
+
+Open `.env` and fill in your credentials:
+
+```
+MINIMAX_API_KEY=your_minimax_api_key_here
+TELEGRAM_BOT_TOKEN=your_telegram_bot_token_here
+TELEGRAM_CHAT_ID=your_telegram_chat_id_here
+```
+
+| Variable | Where to get it |
+|---|---|
+| `MINIMAX_API_KEY` | [platform.minimax.io](https://platform.minimax.io) |
+| `TELEGRAM_BOT_TOKEN` | [@BotFather](https://t.me/BotFather) on Telegram |
+| `TELEGRAM_CHAT_ID` | The ID of the channel or chat to deliver the digest to |
+
+### 3. Onboard with OpenClaw
+
+```bash
+openclaw onboard
+```
+
+When prompted, select **MiniMax M2.7** as the model.
+
+### 4. Add the skill to OpenClaw
+
+Copy the skill folder to your OpenClaw workspace:
+
+```bash
+cp -r . ~/.openclaw/skills/daily-ai-news-digest
+```
+
+### 5. Schedule the daily run
+
+```bash
+openclaw cron add "0 8 * * *" skill.py
+```
+
+This schedules the digest to run every day at **08:00 UTC**. Adjust the cron expression to change the time — for example `"0 7 * * 1-5"` for weekdays at 07:00 UTC.
+
+## Running manually
+
+```bash
+py skill.py
+```
+
+## Output format
+
+```
+🗞️ Daily AI Digest — April 1, 2026
+
+🔴 BREAKING
+🔴 Article Title — Summary sentence one. Sentence two.
+Source: Blog Name | [Read more](https://...)
+
+🟡 IMPORTANT
+🟡 Article Title — Summary sentence one. Sentence two.
+Source: Blog Name | [Read more](https://...)
+
+🔵 NOTABLE
+🔵 Article Title — Summary sentence one. Sentence two.
+Source: Blog Name | [Read more](https://...)
+```
+
+## Project structure
+
+```
+daily-ai-news-digest/
+├── skill.py # Main pipeline — fetch, score, format, send
+├── scripts/
+│ └── fetch_rss.py # Parallel RSS fetcher with 24h date filter
+├── sources.json # 92 Karpathy-curated RSS feed sources
+├── requirements.txt # Python dependencies
+├── .env.example # Template for required environment variables
+├── .env # Local credentials (not committed)
+└── SKILL.md # OpenClaw skill manifest
+```
+
+## Customisation
+
+**Change the number of top articles** — edit the system prompt in `skill.py` and update the instruction from "top 3" to your preferred number.
+
+**Change the lookback window** — the `--hours` argument in `fetch_articles()` defaults to 24. Pass a different value to cast a wider or narrower net.
+
+**Add or remove sources** — edit `sources.json`. Each entry needs a `name`, `xmlUrl` (the feed URL), and `htmlUrl` (the site URL).
+
+**Change the schedule** — update the cron expression in the `trigger` field of `SKILL.md` and re-register with `openclaw cron add`.
diff --git a/daily-news-digest/SKILL.md b/daily-news-digest/SKILL.md
new file mode 100644
index 0000000..a2dc4ad
--- /dev/null
+++ b/daily-news-digest/SKILL.md
@@ -0,0 +1,71 @@
+---
+name: daily-ai-news-digest
+description: Fetches articles from 92 Karpathy-curated RSS feeds, scores them with an LLM, selects the top 3, and delivers a formatted digest to Telegram every morning.
+trigger: "0 8 * * *"
+metadata: {"openclaw": {"requires": {"env": ["TELEGRAM_BOT_TOKEN", "TELEGRAM_CHAT_ID"], "bins": ["py"]}, "primaryEnv": "TELEGRAM_BOT_TOKEN", "emoji": ["📰"]}}
+---
+
+# Daily AI News Digest
+
+A morning briefing skill that monitors 92 RSS feeds curated by Andrej Karpathy, surfaces the most important AI and tech stories from the last 24 hours, and delivers a clean digest to Telegram.
+
+## What It Does
+
+Each morning the skill wakes up, pulls fresh articles from a hand-picked list of RSS feeds, uses an LLM to score and rank them by relevance and significance, then writes a concise summary of the top 3 stories and pushes it to a Telegram chat.
+
+## Pipeline
+
+```
+92 RSS feeds
+ │
+ ▼
+fetch_rss.py — parallel feed fetching
+ │
+ ▼
+filter — keep only articles published in the last 24 hours
+ │
+ ▼
+LLM scoring — rate each article for relevance, novelty, and impact
+ │
+ ▼
+select top 3 — ranked by score, deduplicated by URL
+ │
+ ▼
+summarise — one-paragraph summary per article via LLM
+ │
+ ▼
+categorise — group into themes (Breaking, Important, Notable)
+ │
+ ▼
+Telegram — formatted message delivered to configured chat
+```
+
+## Required Environment Variables
+
+| Variable | Description |
+|---|---|
+| `TELEGRAM_BOT_TOKEN` | Token for the Telegram bot that sends the digest |
+| `TELEGRAM_CHAT_ID` | ID of the Telegram chat or channel to deliver to |
+
+Copy `.env.example` to `.env` and fill in these values before running.
+
+## Schedule
+
+The skill runs on the cron expression `0 8 * * *` — every day at **08:00 UTC**.
+
+To change the time, update the `trigger` field in the frontmatter above. For example:
+- `"0 7 * * 1-5"` — weekdays at 07:00 UTC
+- `"0 6 * * *"` — daily at 06:00 UTC
+
+## Running Manually
+
+```bash
+# Install dependencies
+pip install -r requirements.txt
+
+# Run the full pipeline
+python skill.py
+
+# Run only the RSS fetch step
+python scripts/fetch_rss.py
+```
diff --git a/daily-news-digest/docs/architecture.svg b/daily-news-digest/docs/architecture.svg
new file mode 100644
index 0000000..122338e
--- /dev/null
+++ b/daily-news-digest/docs/architecture.svg
@@ -0,0 +1,111 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="800" height="500" viewBox="0 0 800 500">
+ <defs>
+ <style>
+ .label {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ font-weight: 600;
+ fill: #ffffff;
+ text-anchor: middle;
+ dominant-baseline: middle;
+ }
+ .step-label {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
+ font-size: 11px;
+ font-weight: 500;
+ fill: #64748B;
+ text-anchor: middle;
+ dominant-baseline: middle;
+ }
+ .title {
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
+ font-size: 15px;
+ font-weight: 700;
+ fill: #0F172A;
+ text-anchor: middle;
+ dominant-baseline: middle;
+ }
+ </style>
+
+ <!-- Arrow marker -->
+ <marker id="arrow" markerWidth="9" markerHeight="7" refX="8" refY="3.5" orient="auto">
+ <polygon points="0 0, 9 3.5, 0 7" fill="#94A3B8"/>
+ </marker>
+
+ <!-- Soft drop shadow -->
+ <filter id="shadow" x="-8%" y="-8%" width="116%" height="130%">
+ <feDropShadow dx="0" dy="2" stdDeviation="3" flood-color="#1E293B" flood-opacity="0.10"/>
+ </filter>
+ </defs>
+
+ <!-- ── Background ─────────────────────────────────────────── -->
+ <rect width="800" height="500" fill="#F8FAFC"/>
+
+ <!-- Subtle vertical track line -->
+ <line x1="400" y1="28" x2="400" y2="472" stroke="#E2E8F0" stroke-width="2" stroke-dasharray="4 4"/>
+
+ <!-- ── Title ──────────────────────────────────────────────── -->
+ <text x="400" y="14" class="title" font-size="13" fill="#94A3B8">Daily AI News Digest — Architecture</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 1 — 92 RSS Feeds (gray) y=28
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="28" width="260" height="44" rx="9" fill="#6B7280" filter="url(#shadow)"/>
+ <text x="400" y="50" class="label">92 RSS Feeds</text>
+
+ <!-- Arrow 1 + label -->
+ <line x1="400" y1="72" x2="400" y2="107" stroke="#94A3B8" stroke-width="2" marker-end="url(#arrow)"/>
+ <rect x="316" y="80" width="168" height="19" rx="9" fill="#F1F5F9"/>
+ <text x="400" y="89" class="step-label">fetch every morning</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 2 — Python RSS Fetcher (blue) y=109
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="109" width="260" height="44" rx="9" fill="#3B82F6" filter="url(#shadow)"/>
+ <text x="400" y="131" class="label">Python RSS Fetcher</text>
+
+ <!-- Arrow 2 + label -->
+ <line x1="400" y1="153" x2="400" y2="188" stroke="#94A3B8" stroke-width="2" marker-end="url(#arrow)"/>
+ <rect x="323" y="161" width="154" height="19" rx="9" fill="#F1F5F9"/>
+ <text x="400" y="170" class="step-label">filter last 24h</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 3 — Article Pool (gray) y=190
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="190" width="260" height="44" rx="9" fill="#6B7280" filter="url(#shadow)"/>
+ <text x="400" y="212" class="label">Article Pool</text>
+
+ <!-- Arrow 3 + label -->
+ <line x1="400" y1="234" x2="400" y2="269" stroke="#94A3B8" stroke-width="2" marker-end="url(#arrow)"/>
+ <rect x="293" y="242" width="214" height="19" rx="9" fill="#F1F5F9"/>
+ <text x="400" y="251" class="step-label">score + select top 3</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 4 — MiniMax M2.7 (purple) y=271
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="271" width="260" height="44" rx="9" fill="#8B5CF6" filter="url(#shadow)"/>
+ <text x="400" y="293" class="label">MiniMax M2.7</text>
+
+ <!-- Arrow 4 + label -->
+ <line x1="400" y1="315" x2="400" y2="350" stroke="#94A3B8" stroke-width="2" marker-end="url(#arrow)"/>
+ <rect x="310" y="323" width="180" height="19" rx="9" fill="#F1F5F9"/>
+ <text x="400" y="332" class="step-label">formatted digest</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 5 — OpenClaw Agent (teal) y=352
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="352" width="260" height="44" rx="9" fill="#0D9488" filter="url(#shadow)"/>
+ <text x="400" y="374" class="label">OpenClaw Agent</text>
+
+ <!-- Arrow 5 + label -->
+ <line x1="400" y1="396" x2="400" y2="431" stroke="#94A3B8" stroke-width="2" marker-end="url(#arrow)"/>
+ <rect x="316" y="404" width="168" height="19" rx="9" fill="#F1F5F9"/>
+ <text x="400" y="413" class="step-label">deliver at 8 AM</text>
+
+ <!-- ═══════════════════════════════════════════════════════════
+ BOX 6 — Telegram (teal) y=433
+ ═══════════════════════════════════════════════════════════ -->
+ <rect x="270" y="433" width="260" height="44" rx="9" fill="#0D9488" filter="url(#shadow)"/>
+ <text x="400" y="455" class="label">Telegram</text>
+
+</svg>
diff --git a/daily-news-digest/requirements.txt b/daily-news-digest/requirements.txt
new file mode 100644
index 0000000..5a8c7df
--- /dev/null
+++ b/daily-news-digest/requirements.txt
@@ -0,0 +1,2 @@
+feedparser>=6.0.0
+python-dotenv>=1.0.0
diff --git a/daily-news-digest/scripts/fetch_rss.py b/daily-news-digest/scripts/fetch_rss.py
new file mode 100644
index 0000000..603e0cb
--- /dev/null
+++ b/daily-news-digest/scripts/fetch_rss.py
@@ -0,0 +1,214 @@
+"""
+fetch_rss.py — Fetch and filter articles from RSS feeds listed in sources.json.
+
+Importable as a module:
+ from scripts.fetch_rss import fetch_articles
+
+Or run directly:
+ python scripts/fetch_rss.py --hours 24 --sources sources.json
+"""
+
+import argparse
+import json
+import sys
+import time
+from concurrent.futures import ThreadPoolExecutor, as_completed
+from datetime import datetime, timezone, timedelta
+from pathlib import Path
+
+import feedparser
+
+
+FETCH_TIMEOUT = 15 # seconds per feed request
+
+
+def _dbg(msg: str) -> None:
+ print(msg, file=sys.stderr, flush=True)
+
+
+def load_sources(sources_path: str | Path) -> list[dict]:
+ """Load RSS feed list from a JSON file.
+
+ Expected format: a list of objects with at least a "url" key,
+ and an optional "name" key for display purposes.
+
+ Example:
+ [{"name": "Andrej Karpathy", "url": "https://karpathy.ai/feed.xml"}, ...]
+ """
+ path = Path(sources_path)
+ if not path.exists():
+ raise FileNotFoundError(f"Sources file not found: {path}")
+
+ with path.open("r", encoding="utf-8") as f:
+ sources = json.load(f)
+
+ if not isinstance(sources, list):
+ raise ValueError("sources.json must contain a JSON array")
+
+ return sources
+
+
+def _parse_entry_date(entry) -> datetime | None:
+ """Extract a timezone-aware datetime from a feedparser entry.
+
+ Tries published_parsed first, then updated_parsed.
+ Returns None if neither is available or parseable.
+ """
+ for attr in ("published_parsed", "updated_parsed"):
+ struct = getattr(entry, attr, None)
+ if struct is not None:
+ try:
+ # feedparser returns time.struct_time in UTC
+ ts = time.mktime(struct)
+ return datetime.fromtimestamp(ts, tz=timezone.utc)
+ except (OverflowError, OSError, ValueError):
+ continue
+ return None
+
+
+def _extract_content(entry) -> str:
+ """Return a short text snippet from the entry body.
+
+ Prefers the full content field, falls back to summary/description.
+ Strips to a max of 500 characters so downstream code gets a preview,
+ not the full HTML blob.
+ """
+ # Try content (may be a list of content objects)
+ content_list = getattr(entry, "content", None)
+ if content_list:
+ raw = content_list[0].get("value", "")
+ else:
+ raw = getattr(entry, "summary", "") or getattr(entry, "description", "") or ""
+
+ # Very light cleanup: collapse whitespace, no HTML stripping here
+ text = " ".join(raw.split())
+ return text[:500]
+
+
+def fetch_feed(source: dict, cutoff: datetime) -> list[dict]:
+ """Fetch a single RSS/Atom feed and return articles newer than cutoff.
+
+ Args:
+ source: dict with at least "url"; optionally "name".
+ cutoff: timezone-aware datetime; articles older than this are dropped.
+
+ Returns:
+ List of article dicts. Empty list on any error or if no recent articles.
+ """
+ url = (source.get("url") or source.get("xmlUrl") or "").strip()
+ name = source.get("name", url)
+
+ if not url:
+ return []
+
+ try:
+ # feedparser respects the timeout via socket default — we set it per call
+ import socket
+ old_timeout = socket.getdefaulttimeout()
+ socket.setdefaulttimeout(FETCH_TIMEOUT)
+ try:
+ feed = feedparser.parse(url)
+ finally:
+ socket.setdefaulttimeout(old_timeout)
+
+ # feedparser doesn't raise on HTTP errors; check bozo flag for malformed feeds
+ if feed.bozo and not feed.entries:
+ _dbg(f"ERROR {url} — bozo feed, no entries: {feed.bozo_exception}")
+ return []
+
+ articles = []
+ for entry in feed.entries:
+ pub_date = _parse_entry_date(entry)
+
+ # Skip articles we can't date, or that are older than the cutoff
+ if pub_date is None or pub_date < cutoff:
+ continue
+
+ articles.append({
+ "title": (getattr(entry, "title", "") or "").strip(),
+ "link": (getattr(entry, "link", "") or "").strip(),
+ "source": name,
+ "pubDate": pub_date.isoformat(),
+ "content": _extract_content(entry),
+ })
+
+ return articles
+
+ except Exception as exc:
+ _dbg(f"ERROR {url} — {type(exc).__name__}: {exc}")
+ # Swallow all errors (network, timeout, parse) so one bad feed
+ # never blocks the rest of the pipeline.
+ return []
+
+
+def fetch_articles(
+ sources_path: str | Path = "sources.json",
+ hours: int = 24,
+ max_workers: int = 15,
+) -> list[dict]:
+ """Fetch articles from all feeds in sources_path published within the last `hours`.
+
+ Args:
+ sources_path: Path to the JSON file listing RSS feeds.
+ hours: How far back to look (default 24 hours).
+ max_workers: Number of concurrent fetch threads (default 15).
+
+ Returns:
+ List of article dicts sorted by pubDate descending (newest first).
+ """
+ sources = load_sources(sources_path)
+ cutoff = datetime.now(tz=timezone.utc) - timedelta(hours=hours)
+
+ all_articles: list[dict] = []
+
+ with ThreadPoolExecutor(max_workers=max_workers) as executor:
+ futures = {
+ executor.submit(fetch_feed, source, cutoff): source
+ for source in sources
+ }
+ for future in as_completed(futures):
+ try:
+ articles = future.result()
+ all_articles.extend(articles)
+ except Exception:
+ # future.result() shouldn't raise since fetch_feed catches everything,
+ # but guard anyway.
+ pass
+
+ # Sort newest-first so callers can easily take the top N recent articles
+ all_articles.sort(key=lambda a: a["pubDate"], reverse=True)
+
+ return all_articles
+
+
+# ---------------------------------------------------------------------------
+# CLI entry point
+# ---------------------------------------------------------------------------
+
+def _build_parser() -> argparse.ArgumentParser:
+ parser = argparse.ArgumentParser(
+ description="Fetch recent articles from RSS feeds listed in sources.json."
+ )
+ parser.add_argument(
+ "--hours",
+ type=int,
+ default=24,
+ help="Only include articles published within this many hours (default: 24).",
+ )
+ parser.add_argument(
+ "--sources",
+ type=str,
+ default=str(Path(__file__).parent.parent / "sources.json"),
+ help="Path to sources.json (default: ../sources.json relative to this script).",
+ )
+ return parser
+
+
+if __name__ == "__main__":
+ args = _build_parser().parse_args()
+
+ articles = fetch_articles(sources_path=args.sources, hours=args.hours)
+
+ print(json.dumps(articles, indent=2, ensure_ascii=False))
+ print(f"\n# {len(articles)} articles fetched from the last {args.hours} hours.",
+ flush=True)
diff --git a/daily-news-digest/skill.py b/daily-news-digest/skill.py
new file mode 100644
index 0000000..e08b0c7
--- /dev/null
+++ b/daily-news-digest/skill.py
@@ -0,0 +1,218 @@
+"""
+skill.py — Standalone Daily AI Digest pipeline.
+
+Fetches articles from RSS feeds, calls MiniMax M2.7 to score and select
+the top 3, formats the digest, and sends it to Telegram.
+
+Usage:
+ py skill.py
+"""
+
+import json
+import os
+import sys
+import urllib.request
+import urllib.error
+from datetime import date
+from pathlib import Path
+
+# ---------------------------------------------------------------------------
+# Load .env before anything else
+# ---------------------------------------------------------------------------
+try:
+ from dotenv import load_dotenv
+ load_dotenv(Path(__file__).parent / ".env")
+except ImportError:
+ pass # dotenv optional; variables may already be in the environment
+
+# ---------------------------------------------------------------------------
+# Fetch articles
+# ---------------------------------------------------------------------------
+sys.path.insert(0, str(Path(__file__).parent))
+from scripts.fetch_rss import fetch_articles
+
+SOURCES_PATH = Path(__file__).parent / "sources.json"
+
+articles = fetch_articles(sources_path=SOURCES_PATH, hours=24)
+
+if not articles:
+ print("No articles fetched in the last 24 hours. Exiting.", file=sys.stderr)
+ sys.exit(0)
+
+
+# ---------------------------------------------------------------------------
+# Build article list for the LLM
+# ---------------------------------------------------------------------------
+today = date.today().strftime("%B %d, %Y").replace(" 0", " ")
+
+article_lines = []
+for i, article in enumerate(articles, start=1):
+ article_lines.append(f"[{i}] {article['title']}")
+ article_lines.append(f" Source: {article['source']}")
+ article_lines.append(f" Date: {article['pubDate']}")
+ article_lines.append(f" URL: {article['link']}")
+ if article.get("content"):
+ article_lines.append(f" Preview: {article['content']}")
+ article_lines.append("")
+
+article_block = "\n".join(article_lines)
+
+system_prompt = (
+ "You are an AI news curator. Your job is to select the 3 most significant "
+ "AI/ML articles from a list and produce a structured JSON response.\n\n"
+ "Return ONLY valid JSON with this exact structure:\n"
+ "{\n"
+ ' "selected": [\n'
+ " {\n"
+ ' "title": "...",\n'
+ ' "source": "...",\n'
+ ' "url": "...",\n'
+ ' "category": "Breaking" | "Important" | "Notable",\n'
+ ' "summary": "2-3 sentence summary"\n'
+ " }\n"
+ " ]\n"
+ "}\n\n"
+ "Rules:\n"
+ "- Select ONLY the 3 most significant articles. No more than 3.\n"
+ "- Score each article 1-10 for AI/ML relevance and quality, then pick the top 3.\n"
+ "- Assign each a category: Breaking (major announcements/releases), "
+ "Important (significant developments), or Notable (interesting but less urgent).\n"
+ "- Write a 2-3 sentence summary per article.\n"
+ "- Use the exact URL from the article listing.\n"
+ "- Return ONLY the JSON object, no other text."
+)
+
+user_prompt = (
+ f"Here are today's articles from 92 AI/tech blogs "
+ f"({len(articles)} fetched in the last 24 hours).\n\n"
+ f"---\nARTICLES:\n\n{article_block}"
+)
+
+# ---------------------------------------------------------------------------
+# Call MiniMax M2.7
+# ---------------------------------------------------------------------------
+MINIMAX_API_KEY = os.environ.get("MINIMAX_API_KEY", "")
+if not MINIMAX_API_KEY:
+ print("Error: MINIMAX_API_KEY is not set.", file=sys.stderr)
+ sys.exit(1)
+
+payload = json.dumps({
+ "model": "MiniMax-M2.7",
+ "messages": [
+ {"role": "system", "content": system_prompt},
+ {"role": "user", "content": user_prompt},
+ ],
+ "temperature": 0.2,
+}).encode("utf-8")
+
+req = urllib.request.Request(
+ "https://api.minimaxi.chat/v1/chat/completions",
+ data=payload,
+ headers={
+ "Content-Type": "application/json",
+ "Authorization": f"Bearer {MINIMAX_API_KEY}",
+ },
+ method="POST",
+)
+
+try:
+ with urllib.request.urlopen(req, timeout=120) as resp:
+ response_body = json.loads(resp.read().decode("utf-8"))
+except urllib.error.HTTPError as e:
+ print(f"MiniMax API error {e.code}: {e.read().decode()}", file=sys.stderr)
+ sys.exit(1)
+
+raw_content = response_body["choices"][0]["message"]["content"].strip()
+
+# Strip <think>...</think> block if present
+if "</think>" in raw_content:
+ raw_content = raw_content.split("</think>", 1)[1].strip()
+
+# Strip markdown code fences if present
+if raw_content.startswith("```"):
+ raw_content = raw_content.split("\n", 1)[1]
+ raw_content = raw_content.rsplit("```", 1)[0].strip()
+
+try:
+ llm_result = json.loads(raw_content)
+ selected = llm_result["selected"]
+except (json.JSONDecodeError, KeyError) as e:
+ print(f"Failed to parse LLM response: {e}", file=sys.stderr)
+ sys.exit(1)
+
+
+# ---------------------------------------------------------------------------
+# Format the Telegram message
+# ---------------------------------------------------------------------------
+CATEGORY_HEADERS = {
+ "Breaking": "🔴 BREAKING",
+ "Important": "🟡 IMPORTANT",
+ "Notable": "🔵 NOTABLE",
+}
+CATEGORY_EMOJI = {
+ "Breaking": "🔴",
+ "Important": "🟡",
+ "Notable": "🔵",
+}
+CATEGORY_ORDER = ["Breaking", "Important", "Notable"]
+
+# Group articles by category
+grouped: dict[str, list] = {}
+for article in selected:
+ cat = article.get("category", "Notable")
+ grouped.setdefault(cat, []).append(article)
+
+message_parts = [f"🗞️ *Daily AI Digest — {today}*"]
+
+for cat in CATEGORY_ORDER:
+ if cat not in grouped:
+ continue
+ message_parts.append("")
+ message_parts.append(f"*{CATEGORY_HEADERS[cat]}*")
+ for art in grouped[cat]:
+ emoji = CATEGORY_EMOJI[cat]
+ title = art["title"]
+ summary = art["summary"]
+ source = art["source"]
+ url = art["url"]
+ message_parts.append(
+ f"{emoji} *{title}* — {summary}\n"
+ f"Source: {source} | [Read more]({url})"
+ )
+
+digest = "\n".join(message_parts)
+
+# ---------------------------------------------------------------------------
+# Send to Telegram
+# ---------------------------------------------------------------------------
+BOT_TOKEN = os.environ.get("TELEGRAM_BOT_TOKEN", "")
+CHAT_ID = os.environ.get("TELEGRAM_CHAT_ID", "")
+
+if not BOT_TOKEN or not CHAT_ID:
+ print("Error: TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set.", file=sys.stderr)
+ sys.exit(1)
+
+tg_payload = json.dumps({
+ "chat_id": CHAT_ID,
+ "text": digest,
+ "parse_mode": "Markdown",
+ "disable_web_page_preview": False,
+}).encode("utf-8")
+
+tg_req = urllib.request.Request(
+ f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage",
+ data=tg_payload,
+ headers={"Content-Type": "application/json"},
+ method="POST",
+)
+
+try:
+ with urllib.request.urlopen(tg_req, timeout=30) as resp:
+ tg_response = json.loads(resp.read().decode("utf-8"))
+except urllib.error.HTTPError as e:
+ print(f"Telegram API error {e.code}: {e.read().decode()}", file=sys.stderr)
+ sys.exit(1)
+
+if not tg_response.get("ok"):
+ print(f"Telegram error: {tg_response}", file=sys.stderr)
+ sys.exit(1)
diff --git a/daily-news-digest/sources.json b/daily-news-digest/sources.json
new file mode 100644
index 0000000..c6bb73f
--- /dev/null
+++ b/daily-news-digest/sources.json
@@ -0,0 +1,94 @@
+[
+ {"name":"simonwillison.net","xmlUrl":"https://simonwillison.net/atom/everything/","htmlUrl":"https://simonwillison.net"},
+ {"name":"jeffgeerling.com","xmlUrl":"https://www.jeffgeerling.com/blog.xml","htmlUrl":"https://jeffgeerling.com"},
+ {"name":"seangoedecke.com","xmlUrl":"https://www.seangoedecke.com/rss.xml","htmlUrl":"https://seangoedecke.com"},
+ {"name":"krebsonsecurity.com","xmlUrl":"https://krebsonsecurity.com/feed/","htmlUrl":"https://krebsonsecurity.com"},
+ {"name":"daringfireball.net","xmlUrl":"https://daringfireball.net/feeds/main","htmlUrl":"https://daringfireball.net"},
+ {"name":"ericmigi.com","xmlUrl":"https://ericmigi.com/rss.xml","htmlUrl":"https://ericmigi.com"},
+ {"name":"antirez.com","xmlUrl":"http://antirez.com/rss","htmlUrl":"http://antirez.com"},
+ {"name":"idiallo.com","xmlUrl":"https://idiallo.com/feed.rss","htmlUrl":"https://idiallo.com"},
+ {"name":"maurycyz.com","xmlUrl":"https://maurycyz.com/index.xml","htmlUrl":"https://maurycyz.com"},
+ {"name":"pluralistic.net","xmlUrl":"https://pluralistic.net/feed/","htmlUrl":"https://pluralistic.net"},
+ {"name":"shkspr.mobi","xmlUrl":"https://shkspr.mobi/blog/feed/","htmlUrl":"https://shkspr.mobi"},
+ {"name":"lcamtuf.substack.com","xmlUrl":"https://lcamtuf.substack.com/feed","htmlUrl":"https://lcamtuf.substack.com"},
+ {"name":"mitchellh.com","xmlUrl":"https://mitchellh.com/feed.xml","htmlUrl":"https://mitchellh.com"},
+ {"name":"dynomight.net","xmlUrl":"https://dynomight.net/feed.xml","htmlUrl":"https://dynomight.net"},
+ {"name":"utcc.utoronto.ca/~cks","xmlUrl":"https://utcc.utoronto.ca/~cks/space/blog/?atom","htmlUrl":"https://utcc.utoronto.ca/~cks"},
+ {"name":"xeiaso.net","xmlUrl":"https://xeiaso.net/blog.rss","htmlUrl":"https://xeiaso.net"},
+ {"name":"devblogs.microsoft.com/oldnewthing","xmlUrl":"https://devblogs.microsoft.com/oldnewthing/feed","htmlUrl":"https://devblogs.microsoft.com/oldnewthing"},
+ {"name":"righto.com","xmlUrl":"https://www.righto.com/feeds/posts/default","htmlUrl":"https://righto.com"},
+ {"name":"lucumr.pocoo.org","xmlUrl":"https://lucumr.pocoo.org/feed.atom","htmlUrl":"https://lucumr.pocoo.org"},
+ {"name":"skyfall.dev","xmlUrl":"https://skyfall.dev/rss.xml","htmlUrl":"https://skyfall.dev"},
+ {"name":"garymarcus.substack.com","xmlUrl":"https://garymarcus.substack.com/feed","htmlUrl":"https://garymarcus.substack.com"},
+ {"name":"rachelbythebay.com","xmlUrl":"https://rachelbythebay.com/w/atom.xml","htmlUrl":"https://rachelbythebay.com"},
+ {"name":"overreacted.io","xmlUrl":"https://overreacted.io/rss.xml","htmlUrl":"https://overreacted.io"},
+ {"name":"timsh.org","xmlUrl":"https://timsh.org/rss/","htmlUrl":"https://timsh.org"},
+ {"name":"johndcook.com","xmlUrl":"https://www.johndcook.com/blog/feed/","htmlUrl":"https://johndcook.com"},
+ {"name":"gilesthomas.com","xmlUrl":"https://gilesthomas.com/feed/rss.xml","htmlUrl":"https://gilesthomas.com"},
+ {"name":"matklad.github.io","xmlUrl":"https://matklad.github.io/feed.xml","htmlUrl":"https://matklad.github.io"},
+ {"name":"derekthompson.org","xmlUrl":"https://www.theatlantic.com/feed/author/derek-thompson/","htmlUrl":"https://derekthompson.org"},
+ {"name":"evanhahn.com","xmlUrl":"https://evanhahn.com/feed.xml","htmlUrl":"https://evanhahn.com"},
+ {"name":"terriblesoftware.org","xmlUrl":"https://terriblesoftware.org/feed/","htmlUrl":"https://terriblesoftware.org"},
+ {"name":"rakhim.exotext.com","xmlUrl":"https://rakhim.exotext.com/rss.xml","htmlUrl":"https://rakhim.exotext.com"},
+ {"name":"joanwestenberg.com","xmlUrl":"https://joanwestenberg.com/rss","htmlUrl":"https://joanwestenberg.com"},
+ {"name":"xania.org","xmlUrl":"https://xania.org/feed","htmlUrl":"https://xania.org"},
+ {"name":"micahflee.com","xmlUrl":"https://micahflee.com/feed/","htmlUrl":"https://micahflee.com"},
+ {"name":"nesbitt.io","xmlUrl":"https://nesbitt.io/feed.xml","htmlUrl":"https://nesbitt.io"},
+ {"name":"construction-physics.com","xmlUrl":"https://www.construction-physics.com/feed","htmlUrl":"https://construction-physics.com"},
+ {"name":"tedium.co","xmlUrl":"https://feed.tedium.co/","htmlUrl":"https://tedium.co"},
+ {"name":"susam.net","xmlUrl":"https://susam.net/feed.xml","htmlUrl":"https://susam.net"},
+ {"name":"entropicthoughts.com","xmlUrl":"https://entropicthoughts.com/feed.xml","htmlUrl":"https://entropicthoughts.com"},
+ {"name":"buttondown.com/hillelwayne","xmlUrl":"https://buttondown.com/hillelwayne/rss","htmlUrl":"https://buttondown.com/hillelwayne"},
+ {"name":"dwarkesh.com","xmlUrl":"https://www.dwarkeshpatel.com/feed","htmlUrl":"https://dwarkesh.com"},
+ {"name":"borretti.me","xmlUrl":"https://borretti.me/feed.xml","htmlUrl":"https://borretti.me"},
+ {"name":"wheresyoured.at","xmlUrl":"https://www.wheresyoured.at/rss/","htmlUrl":"https://wheresyoured.at"},
+ {"name":"jayd.ml","xmlUrl":"https://jayd.ml/feed.xml","htmlUrl":"https://jayd.ml"},
+ {"name":"minimaxir.com","xmlUrl":"https://minimaxir.com/index.xml","htmlUrl":"https://minimaxir.com"},
+ {"name":"geohot.github.io","xmlUrl":"https://geohot.github.io/blog/feed.xml","htmlUrl":"https://geohot.github.io"},
+ {"name":"paulgraham.com","xmlUrl":"http://www.aaronsw.com/2002/feeds/pgessays.rss","htmlUrl":"https://paulgraham.com"},
+ {"name":"filfre.net","xmlUrl":"https://www.filfre.net/feed/","htmlUrl":"https://filfre.net"},
+ {"name":"blog.jim-nielsen.com","xmlUrl":"https://blog.jim-nielsen.com/feed.xml","htmlUrl":"https://blog.jim-nielsen.com"},
+ {"name":"dfarq.homeip.net","xmlUrl":"https://dfarq.homeip.net/feed/","htmlUrl":"https://dfarq.homeip.net"},
+ {"name":"jyn.dev","xmlUrl":"https://jyn.dev/atom.xml","htmlUrl":"https://jyn.dev"},
+ {"name":"geoffreylitt.com","xmlUrl":"https://www.geoffreylitt.com/feed.xml","htmlUrl":"https://geoffreylitt.com"},
+ {"name":"downtowndougbrown.com","xmlUrl":"https://www.downtowndougbrown.com/feed/","htmlUrl":"https://downtowndougbrown.com"},
+ {"name":"brutecat.com","xmlUrl":"https://brutecat.com/rss.xml","htmlUrl":"https://brutecat.com"},
+ {"name":"eli.thegreenplace.net","xmlUrl":"https://eli.thegreenplace.net/feeds/all.atom.xml","htmlUrl":"https://eli.thegreenplace.net"},
+ {"name":"abortretry.fail","xmlUrl":"https://www.abortretry.fail/feed","htmlUrl":"https://abortretry.fail"},
+ {"name":"fabiensanglard.net","xmlUrl":"https://fabiensanglard.net/rss.xml","htmlUrl":"https://fabiensanglard.net"},
+ {"name":"oldvcr.blogspot.com","xmlUrl":"https://oldvcr.blogspot.com/feeds/posts/default","htmlUrl":"https://oldvcr.blogspot.com"},
+ {"name":"bogdanthegeek.github.io","xmlUrl":"https://bogdanthegeek.github.io/blog/index.xml","htmlUrl":"https://bogdanthegeek.github.io"},
+ {"name":"hugotunius.se","xmlUrl":"https://hugotunius.se/feed.xml","htmlUrl":"https://hugotunius.se"},
+ {"name":"gwern.net","xmlUrl":"https://gwern.substack.com/feed","htmlUrl":"https://gwern.net"},
+ {"name":"berthub.eu","xmlUrl":"https://berthub.eu/articles/index.xml","htmlUrl":"https://berthub.eu"},
+ {"name":"chadnauseam.com","xmlUrl":"https://chadnauseam.com/rss.xml","htmlUrl":"https://chadnauseam.com"},
+ {"name":"simone.org","xmlUrl":"https://simone.org/feed/","htmlUrl":"https://simone.org"},
+ {"name":"it-notes.dragas.net","xmlUrl":"https://it-notes.dragas.net/feed/","htmlUrl":"https://it-notes.dragas.net"},
+ {"name":"beej.us","xmlUrl":"https://beej.us/blog/rss.xml","htmlUrl":"https://beej.us"},
+ {"name":"hey.paris","xmlUrl":"https://hey.paris/index.xml","htmlUrl":"https://hey.paris"},
+ {"name":"danielwirtz.com","xmlUrl":"https://danielwirtz.com/rss.xml","htmlUrl":"https://danielwirtz.com"},
+ {"name":"matduggan.com","xmlUrl":"https://matduggan.com/rss/","htmlUrl":"https://matduggan.com"},
+ {"name":"refactoringenglish.com","xmlUrl":"https://refactoringenglish.com/index.xml","htmlUrl":"https://refactoringenglish.com"},
+ {"name":"worksonmymachine.substack.com","xmlUrl":"https://worksonmymachine.substack.com/feed","htmlUrl":"https://worksonmymachine.substack.com"},
+ {"name":"philiplaine.com","xmlUrl":"https://philiplaine.com/index.xml","htmlUrl":"https://philiplaine.com"},
+ {"name":"steveblank.com","xmlUrl":"https://steveblank.com/feed/","htmlUrl":"https://steveblank.com"},
+ {"name":"bernsteinbear.com","xmlUrl":"https://bernsteinbear.com/feed.xml","htmlUrl":"https://bernsteinbear.com"},
+ {"name":"danieldelaney.net","xmlUrl":"https://danieldelaney.net/feed","htmlUrl":"https://danieldelaney.net"},
+ {"name":"troyhunt.com","xmlUrl":"https://www.troyhunt.com/rss/","htmlUrl":"https://troyhunt.com"},
+ {"name":"herman.bearblog.dev","xmlUrl":"https://herman.bearblog.dev/feed/","htmlUrl":"https://herman.bearblog.dev"},
+ {"name":"tomrenner.com","xmlUrl":"https://tomrenner.com/index.xml","htmlUrl":"https://tomrenner.com"},
+ {"name":"blog.pixelmelt.dev","xmlUrl":"https://blog.pixelmelt.dev/rss/","htmlUrl":"https://blog.pixelmelt.dev"},
+ {"name":"martinalderson.com","xmlUrl":"https://martinalderson.com/feed.xml","htmlUrl":"https://martinalderson.com"},
+ {"name":"danielchasehooper.com","xmlUrl":"https://danielchasehooper.com/feed.xml","htmlUrl":"https://danielchasehooper.com"},
+ {"name":"chiark.greenend.org.uk/~sgtatham","xmlUrl":"https://www.chiark.greenend.org.uk/~sgtatham/quasiblog/feed.xml","htmlUrl":"https://chiark.greenend.org.uk/~sgtatham"},
+ {"name":"grantslatton.com","xmlUrl":"https://grantslatton.com/rss.xml","htmlUrl":"https://grantslatton.com"},
+ {"name":"experimental-history.com","xmlUrl":"https://www.experimental-history.com/feed","htmlUrl":"https://experimental-history.com"},
+ {"name":"anildash.com","xmlUrl":"https://anildash.com/feed.xml","htmlUrl":"https://anildash.com"},
+ {"name":"aresluna.org","xmlUrl":"https://aresluna.org/main.rss","htmlUrl":"https://aresluna.org"},
+ {"name":"michael.stapelberg.ch","xmlUrl":"https://michael.stapelberg.ch/feed.xml","htmlUrl":"https://michael.stapelberg.ch"},
+ {"name":"miguelgrinberg.com","xmlUrl":"https://blog.miguelgrinberg.com/feed","htmlUrl":"https://miguelgrinberg.com"},
+ {"name":"keygen.sh","xmlUrl":"https://keygen.sh/blog/feed.xml","htmlUrl":"https://keygen.sh"},
+ {"name":"mjg59.dreamwidth.org","xmlUrl":"https://mjg59.dreamwidth.org/data/rss","htmlUrl":"https://mjg59.dreamwidth.org"},
+ {"name":"computer.rip","xmlUrl":"https://computer.rip/rss.xml","htmlUrl":"https://computer.rip"},
+ {"name":"tedunangst.com","xmlUrl":"https://www.tedunangst.com/flak/rss","htmlUrl":"https://tedunangst.com"}
+]
\ No newline at end of file