Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
A lightweight Telegram bot that monitors GitHub issues, estimates difficulty/urgency, suggests what to work on, and can autonomously work on issues using Claude Code.

<!-- BEGIN LINE COUNT -->
📏 Core bot in **1171 lines** of Python (run `bash core_lines.sh` to verify)
📏 Core bot in **1188 lines** of Python (run `bash core_lines.sh` to verify)
<!-- END LINE COUNT -->

## Quick Start
Expand Down
19 changes: 18 additions & 1 deletion minbot/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import contextlib
import json
import os
import tempfile
from pathlib import Path
from pydantic import BaseModel

Expand All @@ -23,4 +26,18 @@ def load_config(path: Path = CONFIG_PATH) -> Config:

def save_config(config: Config, path: Path = CONFIG_PATH) -> None:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_text(config.model_dump_json(indent=2))
os.chmod(path.parent, 0o700)
fd, tmp = tempfile.mkstemp(dir=path.parent, suffix=".tmp")
closed = False
try:
os.write(fd, config.model_dump_json(indent=2).encode())
os.fchmod(fd, 0o600)
os.close(fd)
closed = True
os.rename(tmp, path)
except BaseException:
if not closed:
os.close(fd)
with contextlib.suppress(FileNotFoundError):
os.unlink(tmp)
raise