diff --git a/AGENTS.md b/AGENTS.md index aee991b..f6c25fe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -13,7 +13,7 @@ Read `README.md` for the user-facing behaviour and setup. ## Layout ``` -src/signal_cal_bot/ +src/sigcal_bot/ config.py TOML loading, defaults, duration/time parsers feed.py conditional GET; validators committed only after parse expand.py iCalendar -> Event; series-ID heuristics; recurrence expansion @@ -34,9 +34,9 @@ python -m venv .venv && . .venv/bin/activate pip install -e '.[dev]' pytest # must pass, no network -signal-cal-bot --config config.toml --dump # render the feed without sending -signal-cal-bot --config config.toml --check # config + Signal account check -signal-cal-bot --config config.toml --once # one tick +sigcal-bot --config config.toml --dump # render the feed without sending +sigcal-bot --config config.toml --check # config + Signal account check +sigcal-bot --config config.toml --once # one tick ``` `--dump` uses a throwaway database and never sends; keep it that way. @@ -97,7 +97,7 @@ signal-cal-bot --config config.toml --once # one tick default, parse it in `load_config`, document it in `config.example.toml` and the README table. - **Schema change**: append to `SCHEMA` in `store.py`. There is no migration - framework; deleting `data/signal-cal-bot.sqlite3` re-seeds silently. + framework; deleting `data/sigcal-bot.sqlite3` re-seeds silently. ## Changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index c558327..66739c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,9 +36,9 @@ Unreleased. To make the first release, rename that section to ### Changed -- Renamed from `calbot` to `signal-cal-bot`: Python package - `signal_cal_bot`, CLI `signal-cal-bot`, environment variables - `SIGNAL_CAL_BOT_*`, database `data/signal-cal-bot.sqlite3`. +- Renamed from `calbot` to `sigcal-bot`: Python package + `sigcal_bot`, CLI `sigcal-bot`, environment variables + `SIGCAL_BOT_*`, database `data/sigcal-bot.sqlite3`. ### Fixed diff --git a/Dockerfile b/Dockerfile index f72b490..b65f04a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ RUN pip install . # The compose file runs the bot as uid/gid 1000; these must be writable. RUN mkdir -p /app/data /app/cache && chown -R 1000:1000 /app/data /app/cache -CMD ["python", "-m", "signal_cal_bot", "--config", "/app/config.toml"] +CMD ["python", "-m", "sigcal_bot", "--config", "/app/config.toml"] diff --git a/README.md b/README.md index 9a79a9e..223defb 100644 --- a/README.md +++ b/README.md @@ -111,14 +111,14 @@ the phone must scan, and the server has no browser. Either: ssh -L 8080:localhost:8080 you@server ``` - Then open + Then open in your local browser and scan it from **Signal → Settings → Linked devices → +**. - **Fetch the QR as a file.** On the server: ```bash - curl -s "http://localhost:8080/v1/qrcodelink?device_name=signal-cal-bot" \ + curl -s "http://localhost:8080/v1/qrcodelink?device_name=sigcal-bot" \ -o /tmp/link-qr.png ``` @@ -199,8 +199,8 @@ https. ### 3. Verify, preview, run ```bash -docker compose run --rm bot python -m signal_cal_bot --check # config + account -docker compose run --rm bot python -m signal_cal_bot --dump # rendered posts, no sending +docker compose run --rm bot python -m sigcal_bot --check # config + account +docker compose run --rm bot python -m sigcal_bot --dump # rendered posts, no sending docker compose up -d bot docker compose logs -f bot ``` @@ -209,10 +209,10 @@ docker compose logs -f bot | Command | Purpose | |---|---| -| `signal-cal-bot --config config.toml` | Run the loop | -| `signal-cal-bot --once` | Run a single tick and exit | -| `signal-cal-bot --dump` | Print rendered posts for the feed; uses a temporary DB, sends nothing | -| `signal-cal-bot --check` | Validate config and confirm the Signal account is linked | +| `sigcal-bot --config config.toml` | Run the loop | +| `sigcal-bot --once` | Run a single tick and exit | +| `sigcal-bot --dump` | Print rendered posts for the feed; uses a temporary DB, sends nothing | +| `sigcal-bot --check` | Validate config and confirm the Signal account is linked | All commands accept `--log-level` (or `LOG_LEVEL`). @@ -258,7 +258,7 @@ All commands accept `--log-level` (or `LOG_LEVEL`). | Follow logs | `docker compose logs -f bot` | | Apply config changes | edit `config.toml`, then `docker compose restart bot` | | Update code | `git pull && docker compose up -d --build` | -| Reset duplicate/seen state | stop bot, delete `data/signal-cal-bot.sqlite3`, start (re-seeds silently) | +| Reset duplicate/seen state | stop bot, delete `data/sigcal-bot.sqlite3`, start (re-seeds silently) | | Clear image cache | `rm -rf cache/images` | | Back up | `signal-data/` (linked-device keys) and `config.toml` | diff --git a/config.example.toml b/config.example.toml index 6ed0f5f..ee8851b 100644 --- a/config.example.toml +++ b/config.example.toml @@ -59,5 +59,5 @@ alert_cooldown_hours = 6 daily_heartbeat = false [storage] -db = "data/signal-cal-bot.sqlite3" +db = "data/sigcal-bot.sqlite3" cache = "cache" diff --git a/docker-compose.yml b/docker-compose.yml index c1cc861..13f6227 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: signal-api: image: bbernhard/signal-cli-rest-api:latest - container_name: signal-cal-bot-signal + container_name: sigcal-bot-signal restart: unless-stopped environment: - MODE=json-rpc-native @@ -17,13 +17,13 @@ services: bot: build: . - container_name: signal-cal-bot + container_name: sigcal-bot restart: unless-stopped depends_on: - signal-api user: "1000:1000" environment: - - SIGNAL_CAL_BOT_CONFIG=/app/config.toml + - SIGCAL_BOT_CONFIG=/app/config.toml - LOG_LEVEL=info - TZ=Europe/London volumes: diff --git a/pyproject.toml b/pyproject.toml index 45eb9a3..312505d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [project] -name = "signal-cal-bot" +name = "sigcal-bot" version = "0.1.0" description = "Announce iCalendar events to a Signal group" requires-python = ">=3.11" @@ -18,7 +18,7 @@ dependencies = [ dev = ["pytest>=8.0", "ruff>=0.6"] [project.scripts] -signal-cal-bot = "signal_cal_bot.__main__:main" +sigcal-bot = "sigcal_bot.__main__:main" [build-system] requires = ["setuptools>=77"] diff --git a/src/signal_cal_bot/__init__.py b/src/sigcal_bot/__init__.py similarity index 59% rename from src/signal_cal_bot/__init__.py rename to src/sigcal_bot/__init__.py index f10838f..e775c6c 100644 --- a/src/signal_cal_bot/__init__.py +++ b/src/sigcal_bot/__init__.py @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-3.0-or-later # Copyright (C) 2026 kawaiipunk -"""signal-cal-bot: announce iCalendar events to a Signal group.""" +"""sigcal-bot: announce iCalendar events to a Signal group.""" __version__ = "0.1.0" diff --git a/src/signal_cal_bot/__main__.py b/src/sigcal_bot/__main__.py similarity index 90% rename from src/signal_cal_bot/__main__.py rename to src/sigcal_bot/__main__.py index adff5bb..0000f18 100644 --- a/src/signal_cal_bot/__main__.py +++ b/src/sigcal_bot/__main__.py @@ -28,7 +28,7 @@ from .signal_client import SignalClient from .store import Store from .watchdog import Watchdog -log = logging.getLogger("signal_cal_bot") +log = logging.getLogger("sigcal_bot") TICK_SECONDS = 30 @@ -43,7 +43,7 @@ def _logging(level: str) -> None: def _http_client() -> httpx.Client: return httpx.Client( follow_redirects=True, - headers={"User-Agent": "signal-cal-bot/0.1 (iCalendar to Signal bridge)"}, + headers={"User-Agent": "sigcal-bot/0.1 (iCalendar to Signal bridge)"}, limits=httpx.Limits(max_connections=8, max_keepalive_connections=4), ) @@ -102,11 +102,11 @@ def dump(config: Config) -> int: def main(argv: list[str] | None = None) -> int: - parser = argparse.ArgumentParser(prog="signal-cal-bot", description=__doc__) + parser = argparse.ArgumentParser(prog="sigcal-bot", description=__doc__) parser.add_argument( "--config", - default=os.environ.get("SIGNAL_CAL_BOT_CONFIG", "config.toml"), - help="path to config.toml (default: $SIGNAL_CAL_BOT_CONFIG or ./config.toml)", + default=os.environ.get("SIGCAL_BOT_CONFIG", "config.toml"), + help="path to config.toml (default: $SIGCAL_BOT_CONFIG or ./config.toml)", ) parser.add_argument("--once", action="store_true", help="run a single tick and exit") parser.add_argument("--dump", action="store_true", help="print posts for upcoming events") @@ -142,7 +142,7 @@ def main(argv: list[str] | None = None) -> int: else: log.error( "Signal account %s not found at %s. Link it first: " - "open %s/v1/qrcodelink?device_name=signal-cal-bot and scan the QR code.", + "open %s/v1/qrcodelink?device_name=sigcal-bot and scan the QR code.", config.signal.number, config.signal.api_url, config.signal.api_url, @@ -175,10 +175,10 @@ def main(argv: list[str] | None = None) -> int: signal.signal(signal.SIGTERM, stop) signal.signal(signal.SIGINT, stop) - log.info("signal-cal-bot started (feed=%s, group=%s)", config.calendar.url, config.signal.group_id) + log.info("sigcal-bot started (feed=%s, group=%s)", config.calendar.url, config.signal.group_id) if not sender.account_exists(): log.warning( - "Signal account not linked yet. Open %s/v1/qrcodelink?device_name=signal-cal-bot", + "Signal account not linked yet. Open %s/v1/qrcodelink?device_name=sigcal-bot", config.signal.api_url, ) @@ -191,7 +191,7 @@ def main(argv: list[str] | None = None) -> int: while not stopping and time.monotonic() < deadline: time.sleep(0.5) - log.info("signal-cal-bot stopped") + log.info("sigcal-bot stopped") store.close() http.close() sender.close() diff --git a/src/signal_cal_bot/config.py b/src/sigcal_bot/config.py similarity index 97% rename from src/signal_cal_bot/config.py rename to src/sigcal_bot/config.py index bf7c586..6e48cf5 100644 --- a/src/signal_cal_bot/config.py +++ b/src/sigcal_bot/config.py @@ -142,7 +142,7 @@ class Config: images: ImagesConfig = field(default_factory=ImagesConfig) format: FormatConfig = field(default_factory=FormatConfig) watchdog: WatchdogConfig = field(default_factory=WatchdogConfig) - db_path: Path = Path("data/signal-cal-bot.sqlite3") + db_path: Path = Path("data/sigcal-bot.sqlite3") cache_dir: Path = Path("cache") config_path: Path | None = None base_dir: Path = Path(".") @@ -194,8 +194,8 @@ def load_config(path: str | Path) -> Config: for lead in lead_times: parse_duration(lead) - db_path = Path(os.environ.get("SIGNAL_CAL_BOT_DB", storage.get("db", "data/signal-cal-bot.sqlite3"))) - cache_dir = Path(os.environ.get("SIGNAL_CAL_BOT_CACHE", storage.get("cache", "cache"))) + db_path = Path(os.environ.get("SIGCAL_BOT_DB", storage.get("db", "data/sigcal-bot.sqlite3"))) + cache_dir = Path(os.environ.get("SIGCAL_BOT_CACHE", storage.get("cache", "cache"))) if not db_path.is_absolute(): db_path = base_dir / db_path if not cache_dir.is_absolute(): diff --git a/src/signal_cal_bot/expand.py b/src/sigcal_bot/expand.py similarity index 100% rename from src/signal_cal_bot/expand.py rename to src/sigcal_bot/expand.py diff --git a/src/signal_cal_bot/feed.py b/src/sigcal_bot/feed.py similarity index 97% rename from src/signal_cal_bot/feed.py rename to src/sigcal_bot/feed.py index da6d516..26858ca 100644 --- a/src/signal_cal_bot/feed.py +++ b/src/sigcal_bot/feed.py @@ -15,7 +15,7 @@ from .store import Store, from_iso, iso log = logging.getLogger(__name__) -USER_AGENT = "signal-cal-bot/0.1 (iCalendar to Signal bridge)" +USER_AGENT = "sigcal-bot/0.1 (iCalendar to Signal bridge)" def normalize_feed_url(url: str) -> str: diff --git a/src/signal_cal_bot/format.py b/src/sigcal_bot/format.py similarity index 100% rename from src/signal_cal_bot/format.py rename to src/sigcal_bot/format.py diff --git a/src/signal_cal_bot/images.py b/src/sigcal_bot/images.py similarity index 99% rename from src/signal_cal_bot/images.py rename to src/sigcal_bot/images.py index 16ee092..baddfdc 100644 --- a/src/signal_cal_bot/images.py +++ b/src/sigcal_bot/images.py @@ -28,7 +28,7 @@ Image.MAX_IMAGE_PIXELS = 50_000_000 MAX_DOWNLOAD_BYTES = 20 * 1024 * 1024 DOWNLOAD_TIMEOUT = 20.0 -USER_AGENT = "signal-cal-bot/0.1 (iCalendar to Signal bridge)" +USER_AGENT = "sigcal-bot/0.1 (iCalendar to Signal bridge)" @dataclass(frozen=True) diff --git a/src/signal_cal_bot/scheduler.py b/src/sigcal_bot/scheduler.py similarity index 99% rename from src/signal_cal_bot/scheduler.py rename to src/sigcal_bot/scheduler.py index 32a50d8..b494c71 100644 --- a/src/signal_cal_bot/scheduler.py +++ b/src/sigcal_bot/scheduler.py @@ -451,7 +451,7 @@ class Bot: "https://tinyurl.com/api-create.php", params={"url": url}, timeout=8, - headers={"User-Agent": "signal-cal-bot/0.1"}, + headers={"User-Agent": "sigcal-bot/0.1"}, ) if response.status_code == 200 and response.text.strip().startswith("http"): short = response.text.strip() @@ -472,7 +472,7 @@ class Bot: return try: self.sender.send( - f"signal-cal-bot alive \u2014 {self.store.count_events()} events in the window", + f"sigcal-bot alive \u2014 {self.store.count_events()} events in the window", [self.watchdog.recipient], text_mode=self.config.signal.text_mode, ) diff --git a/src/signal_cal_bot/signal_client.py b/src/sigcal_bot/signal_client.py similarity index 100% rename from src/signal_cal_bot/signal_client.py rename to src/sigcal_bot/signal_client.py diff --git a/src/signal_cal_bot/store.py b/src/sigcal_bot/store.py similarity index 100% rename from src/signal_cal_bot/store.py rename to src/sigcal_bot/store.py diff --git a/src/signal_cal_bot/watchdog.py b/src/sigcal_bot/watchdog.py similarity index 97% rename from src/signal_cal_bot/watchdog.py rename to src/sigcal_bot/watchdog.py index 1038f4d..7511743 100644 --- a/src/signal_cal_bot/watchdog.py +++ b/src/sigcal_bot/watchdog.py @@ -63,7 +63,7 @@ class Watchdog: self._last_alert[key] = now try: self.sender.send( - f"\u26a0\ufe0f signal-cal-bot\n{text}", + f"\u26a0\ufe0f sigcal-bot\n{text}", [self.recipient], text_mode=self.text_mode, ) diff --git a/tests/test_expand.py b/tests/test_expand.py index a5d855b..5cda72e 100644 --- a/tests/test_expand.py +++ b/tests/test_expand.py @@ -6,7 +6,7 @@ from __future__ import annotations from datetime import datetime, timezone from pathlib import Path -from signal_cal_bot.expand import parse_events +from sigcal_bot.expand import parse_events FIXTURE = Path(__file__).parent / "fixtures" / "tec-like.ics.txt" diff --git a/tests/test_feed.py b/tests/test_feed.py index 3416b53..9f05c5f 100644 --- a/tests/test_feed.py +++ b/tests/test_feed.py @@ -8,8 +8,8 @@ from pathlib import Path import httpx -from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url -from signal_cal_bot.store import Store +from sigcal_bot.feed import Feed, FeedResponse, normalize_feed_url +from sigcal_bot.store import Store NOW = datetime(2026, 11, 18, 12, 0, tzinfo=timezone.utc) EMPTY_FEED = b"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//test//EN\r\nEND:VCALENDAR\r\n" diff --git a/tests/test_format.py b/tests/test_format.py index 4797bfa..739bcf5 100644 --- a/tests/test_format.py +++ b/tests/test_format.py @@ -6,9 +6,9 @@ from __future__ import annotations from datetime import datetime, timezone from zoneinfo import ZoneInfo -from signal_cal_bot.config import FormatConfig -from signal_cal_bot.expand import Event -from signal_cal_bot.format import ( +from sigcal_bot.config import FormatConfig +from sigcal_bot.expand import Event +from sigcal_bot.format import ( find_postcode, format_hashtags, format_time_range, diff --git a/tests/test_images.py b/tests/test_images.py index 6716b69..b0d508e 100644 --- a/tests/test_images.py +++ b/tests/test_images.py @@ -8,8 +8,8 @@ import io import httpx from PIL import Image -from signal_cal_bot.config import ImagesConfig -from signal_cal_bot.images import ImageService +from sigcal_bot.config import ImagesConfig +from sigcal_bot.images import ImageService def make_service(tmp_path, **overrides) -> ImageService: diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py index 7cac535..d6882b2 100644 --- a/tests/test_scheduler.py +++ b/tests/test_scheduler.py @@ -9,7 +9,7 @@ from zoneinfo import ZoneInfo import httpx -from signal_cal_bot.config import ( +from sigcal_bot.config import ( AnnounceConfig, CalendarConfig, Config, @@ -20,17 +20,17 @@ from signal_cal_bot.config import ( SignalConfig, WatchdogConfig, ) -from signal_cal_bot.expand import Event -from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url -from signal_cal_bot.scheduler import ( +from sigcal_bot.expand import Event +from sigcal_bot.feed import Feed, FeedResponse, normalize_feed_url +from sigcal_bot.scheduler import ( Bot, clamp_send_at, in_window, next_window_start, reminder_time, ) -from signal_cal_bot.store import PageInfo, Store -from signal_cal_bot.watchdog import Watchdog +from sigcal_bot.store import PageInfo, Store +from sigcal_bot.watchdog import Watchdog LONDON = ZoneInfo("Europe/London") UTC = timezone.utc