Skip to content

Replace slacker with a small built-in Slack client - #8

Merged
bboe merged 2 commits into
mainfrom
manual-slack-client
Jun 15, 2026
Merged

bboe merged 2 commits into
mainfrom
manual-slack-client

Conversation

@bboe

@bboe bboe commented Jun 15, 2026 •

Copy link
Copy Markdown
Owner

deslackify only uses three Slack Web API methods — search.messages, chat.delete, chat.update — so depending on the unmaintained slacker library (last released 2020) isn't worth it. This implements them directly over requests (already a dependency).

Changes

  • SlackClient (token + optional d cookie) POSTs to the Slack Web API with the token in an Authorization: Bearer header — verified to authenticate both xoxp- app tokens and xoxc- browser tokens.
  • SlackError replaces slacker.Error; the rate-limit/timeout retry loop is unchanged (handle_rate_limit now takes a plain callable).
  • Drops the slacker dependency and the hand-rolled Protocol type shims it needed — pyright strict now runs against real types, and the # pyright: ignore[reportMissingTypeStubs] is gone.
  • The --cookie/_normalize_d_cookie browser-session support is retained as-is.
  • Strict --after/--before validation — only YYYY-MM-DD is accepted; times, relative phrases (1 hour ago), and unrecognized words are rejected with a clear error instead of silently matching the wrong messages (Slack's date modifiers mishandle them without erroring).
  • Tests updated for the client-based API + the date validation (30 tests).

Verification (live workspace, end-to-end)

  • Read path: --dry-run found the expected messages via search.messages.
  • Write path: ran a real --update delete of 4 throwaway messages → Messages deleted: 4, zero errors, and the search count drained to 0 — so both chat.update and chat.delete are confirmed working through the new client.
  • Validation: --after "1 hour ago" and invalid dates are rejected before any API call.

pyright strict clean; pre-commit clean; CI green.

bboe added 2 commits June 15, 2026 00:02
deslackify only uses three Web API methods (search.messages, chat.delete,
chat.update), so depending on the unmaintained slacker library (last
released 2020) is unnecessary. Implement them directly over requests.

- Add SlackClient (token + optional d cookie) that POSTs to the Slack Web
  API with the token in an Authorization: Bearer header, which
  authenticates both xoxp- app tokens and xoxc- browser tokens.
- Add SlackError, replacing slacker.Error; keep the rate-limit and timeout
  retry loop (handle_rate_limit now takes a plain callable).
- Drop the slacker dependency and the hand-rolled Protocol type shims it
  required; pyright strict now runs against real types.
- Update tests for the client-based API.
Slack's search date modifiers silently mishandle anything that is not a
plain date: times and most relative phrases (e.g. "1 hour ago") are
parsed as free-text terms, and unrecognized single words ("hour",
"day") return arbitrary results. Rather than risk deleting the wrong
messages, reject any --after/--before value that is not a valid
YYYY-MM-DD date with a clear error.
@bboe
bboe merged commit 28e1c3b into main Jun 15, 2026
6 checks passed
@bboe
bboe deleted the manual-slack-client branch June 15, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant