Add time-based removal of users from welcome channels - #2
Merged
Conversation
Remove users from the welcome channel a configurable number of days after they were added, tracked per-user so each has their own clock. - REMOVAL_AFTER_DAYS (0 = disabled, default) and REMOVAL_CHECK_INTERVAL_MINUTES configure the behavior - State backends track add-time: Redis sorted set scored by timestamp plus a channel hash; in-memory dict for the no-Redis case - ChannelManager records the timestamp on add and gains remove_expired_users()/_kick_user() (handles rate limits and already-gone users gracefully) - A daemon sweeper thread runs only when removal is enabled and warns when enabled without REDIS_URL (in-memory add-times don't survive restarts)
- Skip auto-removal for any user in WELCOME_CHANNEL_MEMBERS or WELCOME_CHANNEL_GROUPS; if a group can't be resolved, abort the sweep rather than risk removing a protected member - Only record add-times when REMOVAL_AFTER_DAYS > 0, so nothing is stored when the feature is disabled
…rites
- REMOVAL_CHECK_INTERVAL_MINUTES now falls back to 60 on an empty
string, matching REMOVAL_AFTER_DAYS; avoids an int("") crash at import
that validate() couldn't catch
- record_user_added / remove_tracked_user write their two Redis keys via
a pipeline so a user can't end up in the add-time set without a
matching channel entry (which the sweep would silently drop)
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.
Remove users from the welcome channel a configurable number of days after they were added, tracked per-user so each has their own clock.