fix: validate timezone at setup; cap critical() ping content (dpylogger-10/11)
a string timezone passed setup silently and TypeError'd on every send, blackholing the sink; now validated as a real tzinfo in initialize(). a long pings list could push critical() content past Discord's 2000-char limit, silently dropping the send; content is now capped to fit. also compresses docstrings/comments with no behavior change. Signed-off-by: disqualifier <dev@disqualifier.me>
This commit is contained in:
@@ -10,18 +10,18 @@ live from `bot.settings` so it can change at runtime via a command.
|
||||
`requirements.txt`:
|
||||
|
||||
```
|
||||
dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.5
|
||||
dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.6
|
||||
```
|
||||
|
||||
Direct:
|
||||
|
||||
```bash
|
||||
pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.5"
|
||||
pip install "dpy_logger @ git+ssh://git@git.rethinkstudios.io/rethink-public/dpy_logger.git@v0.1.6"
|
||||
```
|
||||
|
||||
Requires `discord.py` (pulled transitively).
|
||||
|
||||
Drop the `@v0.1.4` suffix from the line above to install the latest unpinned.
|
||||
Drop the `@v0.1.6` suffix from the line above to install the latest unpinned.
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -73,8 +73,9 @@ await bot.log.debug("noisy", log_to_file=False) # -> Discord only
|
||||
## Errors
|
||||
|
||||
Resolution failures (unresolvable guild/channel, bad config, a non-text channel — whether
|
||||
passed as an id or as an already-resolved object) raise `ValueError` from `initialize()` —
|
||||
a misconfigured logger should fail loudly at setup. Underlying `discord` exceptions
|
||||
passed as an id or as an already-resolved object — or a `timezone` that isn't a `tzinfo`
|
||||
instance) raise `ValueError` from `initialize()` — a misconfigured logger should fail
|
||||
loudly at setup. Underlying `discord` exceptions
|
||||
(`NotFound` / `Forbidden` / `HTTPException` / `InvalidData` and other `ClientException`
|
||||
subclasses) from `fetch_guild`/`fetch_channel` are normalized to that `ValueError` on every
|
||||
resolution path (construction channel, per-guild settings lookup) so callers see one error
|
||||
@@ -87,8 +88,11 @@ doesn't resolve) never breaks the caller's command.
|
||||
The host injects everything; the lib never imports `config`:
|
||||
|
||||
- `colors` (dict, optional) — per-level colors, merged over defaults
|
||||
- `pings` (list of user ids) — mentioned on `critical()`
|
||||
- `timezone`, `footer`, `avatar` — embed identity
|
||||
- `pings` (list of user ids) — mentioned on `critical()`; the ping content is capped at
|
||||
Discord's 2000-char message limit so a long list still sends
|
||||
- `timezone` (`tzinfo`, optional) — must be a real `tzinfo` instance (e.g. `datetime.timezone.utc`);
|
||||
validated at `initialize()`, not a string
|
||||
- `footer`, `avatar` — embed identity
|
||||
- `alert_here` (bool) — if no `pings` are set, `critical()` falls back to
|
||||
`@here` only when this is `True`; otherwise it sends no mention
|
||||
- `embed_builder` (callable, optional) — restyle embeds without subclassing
|
||||
|
||||
Reference in New Issue
Block a user