Created
February 2, 2017 19:16
-
-
Save thehar/4adcbd909d57ca9b424539f6ada24f13 to your computer and use it in GitHub Desktop.
Remove yourself from Slack channels en-masse
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
# | |
# Slack hack:: slack_leave_channels_mass | |
# Description:: Remove yourself from IM-channels in mass | |
require "slack" | |
require "progress_bar" | |
class Array | |
include ProgressBar::WithProgress | |
end | |
Slack.configure do |config| | |
config.token = ENV['SLACK_API_TOKEN'] | |
fail 'Missing ENV[SLACK_API_TOKEN]!' unless config.token | |
end | |
# Slack.configure do |config| | |
# config.token = "YOUR TOKEN HERE" | |
# end | |
channels = Slack.channels_list["channels"] | |
channels.each_with_progress do |channel| | |
if channel["name"].start_with?("im-") && channel["is_member"] == true | |
Slack.channels_leave(:channel => channel["id"]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment