Skip to content

Instantly share code, notes, and snippets.

@thehar
Created February 2, 2017 19:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thehar/4adcbd909d57ca9b424539f6ada24f13 to your computer and use it in GitHub Desktop.
Save thehar/4adcbd909d57ca9b424539f6ada24f13 to your computer and use it in GitHub Desktop.
Remove yourself from Slack channels en-masse
#
# 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