Skip to content

Add time-based removal of users from welcome channels - #2

Merged
DragonSenseiGuy merged 3 commits into
mainfrom
feature/time-based-user-removal
Jul 7, 2026
Merged

Add time-based removal of users from welcome channels#2
DragonSenseiGuy merged 3 commits into
mainfrom
feature/time-based-user-removal

Conversation

@DragonSenseiGuy

Copy link
Copy Markdown
Collaborator

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)

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)
@DragonSenseiGuy
DragonSenseiGuy merged commit 28a53f3 into main Jul 7, 2026
5 checks passed
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