Rename to sigcal-bot

- package src/sigcal_bot, distribution and CLI sigcal-bot
- environment variables SIGCAL_BOT_*
- database file, container names, user agents, logs and QR device name
- docs and changelog updated
This commit is contained in:
2026-11-18 17:06:40 +00:00
parent f6d0db664e
commit add77f6cb8
23 changed files with 56 additions and 56 deletions
+5 -5
View File
@@ -13,7 +13,7 @@ Read `README.md` for the user-facing behaviour and setup.
## Layout ## Layout
``` ```
src/signal_cal_bot/ src/sigcal_bot/
config.py TOML loading, defaults, duration/time parsers config.py TOML loading, defaults, duration/time parsers
feed.py conditional GET; validators committed only after parse feed.py conditional GET; validators committed only after parse
expand.py iCalendar -> Event; series-ID heuristics; recurrence expansion expand.py iCalendar -> Event; series-ID heuristics; recurrence expansion
@@ -34,9 +34,9 @@ python -m venv .venv && . .venv/bin/activate
pip install -e '.[dev]' pip install -e '.[dev]'
pytest # must pass, no network pytest # must pass, no network
signal-cal-bot --config config.toml --dump # render the feed without sending sigcal-bot --config config.toml --dump # render the feed without sending
signal-cal-bot --config config.toml --check # config + Signal account check sigcal-bot --config config.toml --check # config + Signal account check
signal-cal-bot --config config.toml --once # one tick sigcal-bot --config config.toml --once # one tick
``` ```
`--dump` uses a throwaway database and never sends; keep it that way. `--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 default, parse it in `load_config`, document it in `config.example.toml` and
the README table. the README table.
- **Schema change**: append to `SCHEMA` in `store.py`. There is no migration - **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 ## Changelog
+3 -3
View File
@@ -36,9 +36,9 @@ Unreleased. To make the first release, rename that section to
### Changed ### Changed
- Renamed from `calbot` to `signal-cal-bot`: Python package - Renamed from `calbot` to `sigcal-bot`: Python package
`signal_cal_bot`, CLI `signal-cal-bot`, environment variables `sigcal_bot`, CLI `sigcal-bot`, environment variables
`SIGNAL_CAL_BOT_*`, database `data/signal-cal-bot.sqlite3`. `SIGCAL_BOT_*`, database `data/sigcal-bot.sqlite3`.
### Fixed ### Fixed
+1 -1
View File
@@ -13,4 +13,4 @@ RUN pip install .
# The compose file runs the bot as uid/gid 1000; these must be writable. # 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 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"]
+9 -9
View File
@@ -111,14 +111,14 @@ the phone must scan, and the server has no browser. Either:
ssh -L 8080:localhost:8080 you@server ssh -L 8080:localhost:8080 you@server
``` ```
Then open <http://localhost:8080/v1/qrcodelink?device_name=signal-cal-bot> Then open <http://localhost:8080/v1/qrcodelink?device_name=sigcal-bot>
in your local browser and scan it from in your local browser and scan it from
**Signal → Settings → Linked devices → +**. **Signal → Settings → Linked devices → +**.
- **Fetch the QR as a file.** On the server: - **Fetch the QR as a file.** On the server:
```bash ```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 -o /tmp/link-qr.png
``` ```
@@ -199,8 +199,8 @@ https.
### 3. Verify, preview, run ### 3. Verify, preview, run
```bash ```bash
docker compose run --rm bot python -m signal_cal_bot --check # config + account docker compose run --rm bot python -m sigcal_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 --dump # rendered posts, no sending
docker compose up -d bot docker compose up -d bot
docker compose logs -f bot docker compose logs -f bot
``` ```
@@ -209,10 +209,10 @@ docker compose logs -f bot
| Command | Purpose | | Command | Purpose |
|---|---| |---|---|
| `signal-cal-bot --config config.toml` | Run the loop | | `sigcal-bot --config config.toml` | Run the loop |
| `signal-cal-bot --once` | Run a single tick and exit | | `sigcal-bot --once` | Run a single tick and exit |
| `signal-cal-bot --dump` | Print rendered posts for the feed; uses a temporary DB, sends nothing | | `sigcal-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 --check` | Validate config and confirm the Signal account is linked |
All commands accept `--log-level` (or `LOG_LEVEL`). 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` | | Follow logs | `docker compose logs -f bot` |
| Apply config changes | edit `config.toml`, then `docker compose restart bot` | | Apply config changes | edit `config.toml`, then `docker compose restart bot` |
| Update code | `git pull && docker compose up -d --build` | | 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` | | Clear image cache | `rm -rf cache/images` |
| Back up | `signal-data/` (linked-device keys) and `config.toml` | | Back up | `signal-data/` (linked-device keys) and `config.toml` |
+1 -1
View File
@@ -59,5 +59,5 @@ alert_cooldown_hours = 6
daily_heartbeat = false daily_heartbeat = false
[storage] [storage]
db = "data/signal-cal-bot.sqlite3" db = "data/sigcal-bot.sqlite3"
cache = "cache" cache = "cache"
+3 -3
View File
@@ -2,7 +2,7 @@
services: services:
signal-api: signal-api:
image: bbernhard/signal-cli-rest-api:latest image: bbernhard/signal-cli-rest-api:latest
container_name: signal-cal-bot-signal container_name: sigcal-bot-signal
restart: unless-stopped restart: unless-stopped
environment: environment:
- MODE=json-rpc-native - MODE=json-rpc-native
@@ -17,13 +17,13 @@ services:
bot: bot:
build: . build: .
container_name: signal-cal-bot container_name: sigcal-bot
restart: unless-stopped restart: unless-stopped
depends_on: depends_on:
- signal-api - signal-api
user: "1000:1000" user: "1000:1000"
environment: environment:
- SIGNAL_CAL_BOT_CONFIG=/app/config.toml - SIGCAL_BOT_CONFIG=/app/config.toml
- LOG_LEVEL=info - LOG_LEVEL=info
- TZ=Europe/London - TZ=Europe/London
volumes: volumes:
+2 -2
View File
@@ -1,5 +1,5 @@
[project] [project]
name = "signal-cal-bot" name = "sigcal-bot"
version = "0.1.0" version = "0.1.0"
description = "Announce iCalendar events to a Signal group" description = "Announce iCalendar events to a Signal group"
requires-python = ">=3.11" requires-python = ">=3.11"
@@ -18,7 +18,7 @@ dependencies = [
dev = ["pytest>=8.0", "ruff>=0.6"] dev = ["pytest>=8.0", "ruff>=0.6"]
[project.scripts] [project.scripts]
signal-cal-bot = "signal_cal_bot.__main__:main" sigcal-bot = "sigcal_bot.__main__:main"
[build-system] [build-system]
requires = ["setuptools>=77"] requires = ["setuptools>=77"]
@@ -1,6 +1,6 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (C) 2026 kawaiipunk # 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" __version__ = "0.1.0"
@@ -28,7 +28,7 @@ from .signal_client import SignalClient
from .store import Store from .store import Store
from .watchdog import Watchdog from .watchdog import Watchdog
log = logging.getLogger("signal_cal_bot") log = logging.getLogger("sigcal_bot")
TICK_SECONDS = 30 TICK_SECONDS = 30
@@ -43,7 +43,7 @@ def _logging(level: str) -> None:
def _http_client() -> httpx.Client: def _http_client() -> httpx.Client:
return httpx.Client( return httpx.Client(
follow_redirects=True, 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), 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: 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( parser.add_argument(
"--config", "--config",
default=os.environ.get("SIGNAL_CAL_BOT_CONFIG", "config.toml"), default=os.environ.get("SIGCAL_BOT_CONFIG", "config.toml"),
help="path to config.toml (default: $SIGNAL_CAL_BOT_CONFIG or ./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("--once", action="store_true", help="run a single tick and exit")
parser.add_argument("--dump", action="store_true", help="print posts for upcoming events") 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: else:
log.error( log.error(
"Signal account %s not found at %s. Link it first: " "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.number,
config.signal.api_url, config.signal.api_url,
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.SIGTERM, stop)
signal.signal(signal.SIGINT, 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(): if not sender.account_exists():
log.warning( 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, config.signal.api_url,
) )
@@ -191,7 +191,7 @@ def main(argv: list[str] | None = None) -> int:
while not stopping and time.monotonic() < deadline: while not stopping and time.monotonic() < deadline:
time.sleep(0.5) time.sleep(0.5)
log.info("signal-cal-bot stopped") log.info("sigcal-bot stopped")
store.close() store.close()
http.close() http.close()
sender.close() sender.close()
@@ -142,7 +142,7 @@ class Config:
images: ImagesConfig = field(default_factory=ImagesConfig) images: ImagesConfig = field(default_factory=ImagesConfig)
format: FormatConfig = field(default_factory=FormatConfig) format: FormatConfig = field(default_factory=FormatConfig)
watchdog: WatchdogConfig = field(default_factory=WatchdogConfig) 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") cache_dir: Path = Path("cache")
config_path: Path | None = None config_path: Path | None = None
base_dir: Path = Path(".") base_dir: Path = Path(".")
@@ -194,8 +194,8 @@ def load_config(path: str | Path) -> Config:
for lead in lead_times: for lead in lead_times:
parse_duration(lead) parse_duration(lead)
db_path = Path(os.environ.get("SIGNAL_CAL_BOT_DB", storage.get("db", "data/signal-cal-bot.sqlite3"))) db_path = Path(os.environ.get("SIGCAL_BOT_DB", storage.get("db", "data/sigcal-bot.sqlite3")))
cache_dir = Path(os.environ.get("SIGNAL_CAL_BOT_CACHE", storage.get("cache", "cache"))) cache_dir = Path(os.environ.get("SIGCAL_BOT_CACHE", storage.get("cache", "cache")))
if not db_path.is_absolute(): if not db_path.is_absolute():
db_path = base_dir / db_path db_path = base_dir / db_path
if not cache_dir.is_absolute(): if not cache_dir.is_absolute():
@@ -15,7 +15,7 @@ from .store import Store, from_iso, iso
log = logging.getLogger(__name__) 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: def normalize_feed_url(url: str) -> str:
@@ -28,7 +28,7 @@ Image.MAX_IMAGE_PIXELS = 50_000_000
MAX_DOWNLOAD_BYTES = 20 * 1024 * 1024 MAX_DOWNLOAD_BYTES = 20 * 1024 * 1024
DOWNLOAD_TIMEOUT = 20.0 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) @dataclass(frozen=True)
@@ -451,7 +451,7 @@ class Bot:
"https://tinyurl.com/api-create.php", "https://tinyurl.com/api-create.php",
params={"url": url}, params={"url": url},
timeout=8, 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"): if response.status_code == 200 and response.text.strip().startswith("http"):
short = response.text.strip() short = response.text.strip()
@@ -472,7 +472,7 @@ class Bot:
return return
try: try:
self.sender.send( 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], [self.watchdog.recipient],
text_mode=self.config.signal.text_mode, text_mode=self.config.signal.text_mode,
) )
@@ -63,7 +63,7 @@ class Watchdog:
self._last_alert[key] = now self._last_alert[key] = now
try: try:
self.sender.send( self.sender.send(
f"\u26a0\ufe0f signal-cal-bot\n{text}", f"\u26a0\ufe0f sigcal-bot\n{text}",
[self.recipient], [self.recipient],
text_mode=self.text_mode, text_mode=self.text_mode,
) )
+1 -1
View File
@@ -6,7 +6,7 @@ from __future__ import annotations
from datetime import datetime, timezone from datetime import datetime, timezone
from pathlib import Path 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" FIXTURE = Path(__file__).parent / "fixtures" / "tec-like.ics.txt"
+2 -2
View File
@@ -8,8 +8,8 @@ from pathlib import Path
import httpx import httpx
from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url from sigcal_bot.feed import Feed, FeedResponse, normalize_feed_url
from signal_cal_bot.store import Store from sigcal_bot.store import Store
NOW = datetime(2026, 11, 18, 12, 0, tzinfo=timezone.utc) 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" EMPTY_FEED = b"BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//test//EN\r\nEND:VCALENDAR\r\n"
+3 -3
View File
@@ -6,9 +6,9 @@ from __future__ import annotations
from datetime import datetime, timezone from datetime import datetime, timezone
from zoneinfo import ZoneInfo from zoneinfo import ZoneInfo
from signal_cal_bot.config import FormatConfig from sigcal_bot.config import FormatConfig
from signal_cal_bot.expand import Event from sigcal_bot.expand import Event
from signal_cal_bot.format import ( from sigcal_bot.format import (
find_postcode, find_postcode,
format_hashtags, format_hashtags,
format_time_range, format_time_range,
+2 -2
View File
@@ -8,8 +8,8 @@ import io
import httpx import httpx
from PIL import Image from PIL import Image
from signal_cal_bot.config import ImagesConfig from sigcal_bot.config import ImagesConfig
from signal_cal_bot.images import ImageService from sigcal_bot.images import ImageService
def make_service(tmp_path, **overrides) -> ImageService: def make_service(tmp_path, **overrides) -> ImageService:
+6 -6
View File
@@ -9,7 +9,7 @@ from zoneinfo import ZoneInfo
import httpx import httpx
from signal_cal_bot.config import ( from sigcal_bot.config import (
AnnounceConfig, AnnounceConfig,
CalendarConfig, CalendarConfig,
Config, Config,
@@ -20,17 +20,17 @@ from signal_cal_bot.config import (
SignalConfig, SignalConfig,
WatchdogConfig, WatchdogConfig,
) )
from signal_cal_bot.expand import Event from sigcal_bot.expand import Event
from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url from sigcal_bot.feed import Feed, FeedResponse, normalize_feed_url
from signal_cal_bot.scheduler import ( from sigcal_bot.scheduler import (
Bot, Bot,
clamp_send_at, clamp_send_at,
in_window, in_window,
next_window_start, next_window_start,
reminder_time, reminder_time,
) )
from signal_cal_bot.store import PageInfo, Store from sigcal_bot.store import PageInfo, Store
from signal_cal_bot.watchdog import Watchdog from sigcal_bot.watchdog import Watchdog
LONDON = ZoneInfo("Europe/London") LONDON = ZoneInfo("Europe/London")
UTC = timezone.utc UTC = timezone.utc