Rename project to signal-cal-bot
- package src/signal-cal-bot -> src/signal_cal_bot - distribution and CLI entry point: signal-cal-bot - env vars CALBOT_* -> SIGNAL_CAL_BOT_* - database file, container names, user agents and logs renamed - docs and compose updated
This commit is contained in:
@@ -13,7 +13,7 @@ Read `README.md` for the user-facing behaviour and setup.
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/calbot/
|
||||
src/signal_cal_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
|
||||
calbot --config config.toml --dump # render the feed without sending
|
||||
calbot --config config.toml --check # config + Signal account check
|
||||
calbot --config config.toml --once # one tick
|
||||
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
|
||||
```
|
||||
|
||||
`--dump` uses a throwaway database and never sends; keep it that way.
|
||||
@@ -97,7 +97,7 @@ calbot --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/calbot.sqlite3` re-seeds silently.
|
||||
framework; deleting `data/signal-cal-bot.sqlite3` re-seeds silently.
|
||||
|
||||
## Before you finish
|
||||
|
||||
|
||||
+1
-1
@@ -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", "calbot", "--config", "/app/config.toml"]
|
||||
CMD ["python", "-m", "signal_cal_bot", "--config", "/app/config.toml"]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# calbot — iCalendar → Signal
|
||||
# signal-cal-bot — iCalendar → Signal
|
||||
|
||||
Polls an iCalendar feed and posts events to a Signal group, with the event's
|
||||
poster image attached. Built for [MCR Commons](https://commonscalendar.uk) (The
|
||||
@@ -76,7 +76,7 @@ mkdir -p signal-data data cache
|
||||
docker compose up -d signal-api
|
||||
```
|
||||
|
||||
Open <http://localhost:8080/v1/qrcodelink?device_name=calbot> and scan it from
|
||||
Open <http://localhost:8080/v1/qrcodelink?device_name=signal-cal-bot> and scan it from
|
||||
**Signal → Settings → Linked devices**.
|
||||
|
||||
> Linking as a secondary device means the bot posts **as your own number**.
|
||||
@@ -104,8 +104,8 @@ https.
|
||||
### 3. Verify, preview, run
|
||||
|
||||
```bash
|
||||
docker compose run --rm bot python -m calbot --check # config + account
|
||||
docker compose run --rm bot python -m calbot --dump # rendered posts, no sending
|
||||
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 up -d bot
|
||||
docker compose logs -f bot
|
||||
```
|
||||
@@ -114,10 +114,10 @@ docker compose logs -f bot
|
||||
|
||||
| Command | Purpose |
|
||||
|---|---|
|
||||
| `calbot --config config.toml` | Run the loop |
|
||||
| `calbot --once` | Run a single tick and exit |
|
||||
| `calbot --dump` | Print rendered posts for the feed; uses a temporary DB, sends nothing |
|
||||
| `calbot --check` | Validate config and confirm the Signal account is linked |
|
||||
| `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 |
|
||||
|
||||
All commands accept `--log-level` (or `LOG_LEVEL`).
|
||||
|
||||
@@ -163,7 +163,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/calbot.sqlite3`, start (re-seeds silently) |
|
||||
| Reset duplicate/seen state | stop bot, delete `data/signal-cal-bot.sqlite3`, start (re-seeds silently) |
|
||||
| Clear image cache | `rm -rf cache/images` |
|
||||
| Back up | `signal-data/` (linked-device keys) and `config.toml` |
|
||||
|
||||
|
||||
+1
-1
@@ -59,5 +59,5 @@ alert_cooldown_hours = 6
|
||||
daily_heartbeat = false
|
||||
|
||||
[storage]
|
||||
db = "data/calbot.sqlite3"
|
||||
db = "data/signal-cal-bot.sqlite3"
|
||||
cache = "cache"
|
||||
|
||||
+3
-3
@@ -2,7 +2,7 @@
|
||||
services:
|
||||
signal-api:
|
||||
image: bbernhard/signal-cli-rest-api:latest
|
||||
container_name: calbot-signal
|
||||
container_name: signal-cal-bot-signal
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- MODE=json-rpc-native
|
||||
@@ -17,13 +17,13 @@ services:
|
||||
|
||||
bot:
|
||||
build: .
|
||||
container_name: calbot
|
||||
container_name: signal-cal-bot
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- signal-api
|
||||
user: "1000:1000"
|
||||
environment:
|
||||
- CALBOT_CONFIG=/app/config.toml
|
||||
- SIGNAL_CAL_BOT_CONFIG=/app/config.toml
|
||||
- LOG_LEVEL=info
|
||||
- TZ=Europe/London
|
||||
volumes:
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
[project]
|
||||
name = "calbot"
|
||||
name = "signal-cal-bot"
|
||||
version = "0.1.0"
|
||||
description = "Announce iCalendar events to a Signal group"
|
||||
requires-python = ">=3.11"
|
||||
@@ -15,7 +15,7 @@ dependencies = [
|
||||
dev = ["pytest>=8.0", "ruff>=0.6"]
|
||||
|
||||
[project.scripts]
|
||||
calbot = "calbot.__main__:main"
|
||||
signal-cal-bot = "signal_cal_bot.__main__:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["setuptools>=68"]
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
"""calbot: announce iCalendar events to a Signal group."""
|
||||
|
||||
__version__ = "0.1.0"
|
||||
@@ -0,0 +1,3 @@
|
||||
"""signal-cal-bot: announce iCalendar events to a Signal group."""
|
||||
|
||||
__version__ = "0.1.0"
|
||||
@@ -25,7 +25,7 @@ from .signal_client import SignalClient
|
||||
from .store import Store
|
||||
from .watchdog import Watchdog
|
||||
|
||||
log = logging.getLogger("calbot")
|
||||
log = logging.getLogger("signal_cal_bot")
|
||||
|
||||
TICK_SECONDS = 30
|
||||
|
||||
@@ -40,7 +40,7 @@ def _logging(level: str) -> None:
|
||||
def _http_client() -> httpx.Client:
|
||||
return httpx.Client(
|
||||
follow_redirects=True,
|
||||
headers={"User-Agent": "calbot/0.1 (iCalendar to Signal bridge)"},
|
||||
headers={"User-Agent": "signal-cal-bot/0.1 (iCalendar to Signal bridge)"},
|
||||
limits=httpx.Limits(max_connections=8, max_keepalive_connections=4),
|
||||
)
|
||||
|
||||
@@ -99,11 +99,11 @@ def dump(config: Config) -> int:
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
parser = argparse.ArgumentParser(prog="calbot", description=__doc__)
|
||||
parser = argparse.ArgumentParser(prog="signal-cal-bot", description=__doc__)
|
||||
parser.add_argument(
|
||||
"--config",
|
||||
default=os.environ.get("CALBOT_CONFIG", "config.toml"),
|
||||
help="path to config.toml (default: $CALBOT_CONFIG or ./config.toml)",
|
||||
default=os.environ.get("SIGNAL_CAL_BOT_CONFIG", "config.toml"),
|
||||
help="path to config.toml (default: $SIGNAL_CAL_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")
|
||||
@@ -139,7 +139,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=calbot and scan the QR code.",
|
||||
"open %s/v1/qrcodelink?device_name=signal-cal-bot and scan the QR code.",
|
||||
config.signal.number,
|
||||
config.signal.api_url,
|
||||
config.signal.api_url,
|
||||
@@ -172,10 +172,10 @@ def main(argv: list[str] | None = None) -> int:
|
||||
signal.signal(signal.SIGTERM, stop)
|
||||
signal.signal(signal.SIGINT, stop)
|
||||
|
||||
log.info("calbot started (feed=%s, group=%s)", config.calendar.url, config.signal.group_id)
|
||||
log.info("signal-cal-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=calbot",
|
||||
"Signal account not linked yet. Open %s/v1/qrcodelink?device_name=signal-cal-bot",
|
||||
config.signal.api_url,
|
||||
)
|
||||
|
||||
@@ -188,7 +188,7 @@ def main(argv: list[str] | None = None) -> int:
|
||||
while not stopping and time.monotonic() < deadline:
|
||||
time.sleep(0.5)
|
||||
|
||||
log.info("calbot stopped")
|
||||
log.info("signal-cal-bot stopped")
|
||||
store.close()
|
||||
http.close()
|
||||
sender.close()
|
||||
@@ -139,7 +139,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/calbot.sqlite3")
|
||||
db_path: Path = Path("data/signal-cal-bot.sqlite3")
|
||||
cache_dir: Path = Path("cache")
|
||||
config_path: Path | None = None
|
||||
base_dir: Path = Path(".")
|
||||
@@ -191,8 +191,8 @@ def load_config(path: str | Path) -> Config:
|
||||
for lead in lead_times:
|
||||
parse_duration(lead)
|
||||
|
||||
db_path = Path(os.environ.get("CALBOT_DB", storage.get("db", "data/calbot.sqlite3")))
|
||||
cache_dir = Path(os.environ.get("CALBOT_CACHE", storage.get("cache", "cache")))
|
||||
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")))
|
||||
if not db_path.is_absolute():
|
||||
db_path = base_dir / db_path
|
||||
if not cache_dir.is_absolute():
|
||||
@@ -12,7 +12,7 @@ from .store import Store, from_iso, iso
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
USER_AGENT = "calbot/0.1 (iCalendar to Signal bridge)"
|
||||
USER_AGENT = "signal-cal-bot/0.1 (iCalendar to Signal bridge)"
|
||||
|
||||
|
||||
def normalize_feed_url(url: str) -> str:
|
||||
@@ -25,7 +25,7 @@ Image.MAX_IMAGE_PIXELS = 50_000_000
|
||||
|
||||
MAX_DOWNLOAD_BYTES = 20 * 1024 * 1024
|
||||
DOWNLOAD_TIMEOUT = 20.0
|
||||
USER_AGENT = "calbot/0.1 (iCalendar to Signal bridge)"
|
||||
USER_AGENT = "signal-cal-bot/0.1 (iCalendar to Signal bridge)"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -448,7 +448,7 @@ class Bot:
|
||||
"https://tinyurl.com/api-create.php",
|
||||
params={"url": url},
|
||||
timeout=8,
|
||||
headers={"User-Agent": "calbot/0.1"},
|
||||
headers={"User-Agent": "signal-cal-bot/0.1"},
|
||||
)
|
||||
if response.status_code == 200 and response.text.strip().startswith("http"):
|
||||
short = response.text.strip()
|
||||
@@ -469,7 +469,7 @@ class Bot:
|
||||
return
|
||||
try:
|
||||
self.sender.send(
|
||||
f"calbot alive \u2014 {self.store.count_events()} events in the window",
|
||||
f"signal-cal-bot alive \u2014 {self.store.count_events()} events in the window",
|
||||
[self.watchdog.recipient],
|
||||
text_mode=self.config.signal.text_mode,
|
||||
)
|
||||
@@ -60,7 +60,7 @@ class Watchdog:
|
||||
self._last_alert[key] = now
|
||||
try:
|
||||
self.sender.send(
|
||||
f"\u26a0\ufe0f calbot\n{text}",
|
||||
f"\u26a0\ufe0f signal-cal-bot\n{text}",
|
||||
[self.recipient],
|
||||
text_mode=self.text_mode,
|
||||
)
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from calbot.expand import parse_events
|
||||
from signal_cal_bot.expand import parse_events
|
||||
|
||||
FIXTURE = Path(__file__).parent / "fixtures" / "tec-like.ics.txt"
|
||||
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@ from pathlib import Path
|
||||
|
||||
import httpx
|
||||
|
||||
from calbot.feed import Feed, FeedResponse, normalize_feed_url
|
||||
from calbot.store import Store
|
||||
from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url
|
||||
from signal_cal_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"
|
||||
|
||||
@@ -3,9 +3,9 @@ from __future__ import annotations
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
from calbot.config import FormatConfig
|
||||
from calbot.expand import Event
|
||||
from calbot.format import (
|
||||
from signal_cal_bot.config import FormatConfig
|
||||
from signal_cal_bot.expand import Event
|
||||
from signal_cal_bot.format import (
|
||||
find_postcode,
|
||||
format_hashtags,
|
||||
format_time_range,
|
||||
|
||||
@@ -5,8 +5,8 @@ import io
|
||||
import httpx
|
||||
from PIL import Image
|
||||
|
||||
from calbot.config import ImagesConfig
|
||||
from calbot.images import ImageService
|
||||
from signal_cal_bot.config import ImagesConfig
|
||||
from signal_cal_bot.images import ImageService
|
||||
|
||||
|
||||
def make_service(tmp_path, **overrides) -> ImageService:
|
||||
|
||||
@@ -6,7 +6,7 @@ from zoneinfo import ZoneInfo
|
||||
|
||||
import httpx
|
||||
|
||||
from calbot.config import (
|
||||
from signal_cal_bot.config import (
|
||||
AnnounceConfig,
|
||||
CalendarConfig,
|
||||
Config,
|
||||
@@ -17,17 +17,17 @@ from calbot.config import (
|
||||
SignalConfig,
|
||||
WatchdogConfig,
|
||||
)
|
||||
from calbot.expand import Event
|
||||
from calbot.feed import Feed, FeedResponse, normalize_feed_url
|
||||
from calbot.scheduler import (
|
||||
from signal_cal_bot.expand import Event
|
||||
from signal_cal_bot.feed import Feed, FeedResponse, normalize_feed_url
|
||||
from signal_cal_bot.scheduler import (
|
||||
Bot,
|
||||
clamp_send_at,
|
||||
in_window,
|
||||
next_window_start,
|
||||
reminder_time,
|
||||
)
|
||||
from calbot.store import PageInfo, Store
|
||||
from calbot.watchdog import Watchdog
|
||||
from signal_cal_bot.store import PageInfo, Store
|
||||
from signal_cal_bot.watchdog import Watchdog
|
||||
|
||||
LONDON = ZoneInfo("Europe/London")
|
||||
UTC = timezone.utc
|
||||
|
||||
Reference in New Issue
Block a user