Skip to content

Instantly share code, notes, and snippets.

@therod
Created June 30, 2015 19:59
Show Gist options
  • Save therod/93b1839dbf59c01974ed to your computer and use it in GitHub Desktop.
Save therod/93b1839dbf59c01974ed to your computer and use it in GitHub Desktop.
ruby script that deletes all messages from a defined channel
require 'slack'
require 'json'
Slack.configure do |config|
config.token = ENV['SLACK_TOKEN']
end
Slack.auth_test
general = "C06S8GRSL"
channel_history = Slack.channels_history(channel: general, count: 1000)["messages"]
channel_history.each do |message|
response = Slack.chat_delete(ts: message["ts"], channel: general)
puts "Deleted Message : #{response["ts"]}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment