Repository navigation
Replace slacker with a small built-in Slack client - #8
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
deslackifyonly uses three Slack Web API methods —search.messages,chat.delete,chat.update— so depending on the unmaintainedslackerlibrary (last released 2020) isn't worth it. This implements them directly overrequests(already a dependency).Changes
SlackClient(token + optionaldcookie) POSTs to the Slack Web API with the token in anAuthorization: Bearerheader — verified to authenticate bothxoxp-app tokens andxoxc-browser tokens.SlackErrorreplacesslacker.Error; the rate-limit/timeout retry loop is unchanged (handle_rate_limitnow takes a plain callable).slackerdependency and the hand-rolledProtocoltype shims it needed — pyright strict now runs against real types, and the# pyright: ignore[reportMissingTypeStubs]is gone.--cookie/_normalize_d_cookiebrowser-session support is retained as-is.--after/--beforevalidation — onlyYYYY-MM-DDis 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).Verification (live workspace, end-to-end)
--dry-runfound the expected messages viasearch.messages.--updatedelete of 4 throwaway messages →Messages deleted: 4, zero errors, and the search count drained to0— so bothchat.updateandchat.deleteare confirmed working through the new client.--after "1 hour ago"and invalid dates are rejected before any API call.pyright strict clean; pre-commit clean; CI green.