Skip to content

@jpr5 /b00m.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Nuke HipChat 1:1 History
require 'rubygems'
require 'mechanize'
account = {
:email => "jpr5@serv.io",
:password => "balls",
}
agent = Mechanize.new
site = agent.post("https://www.hipchat.com/sign_in", account).uri.host
# get numeric UID
member_id = agent.get("https://#{site}/account").
search('img[alt="Your photo"]').first["src"].match(%r{photos/(\d+)})[1]
# determine intervals
registered_around = agent.get("https://#{site}/members/#{member_id}").
search('li:contains("Signed up")').text.sub(/Signed up: /, '')
registered_on = Date.parse(`date -d "#{registered_around}"`.chomp)
intervals = (registered_on..Date.today).map { |d| d.strftime("/%Y/%m/%d") }
# identify 1:1 chats
members = agent.get("https://#{site}/history").search("ul.members").children.search("a").
map { |m| m.attributes["href"].value }.
reject { |m| m =~ /#{member_id}/ }
# walk intervals for each member, capture message_id's
messages = {}
members.each do |member|
intervals.each do |interval|
messages[member] ||= []
messages[member] += agent.get("https://#{site}#{member}#{interval}").
search("input[name=message_id]").map { |m| m["value"] }
end
end
messages.each do |member, msg_ids|
msg_ids.each do |msg_id|
agent.post("https://#{site}#{member}", {:action => "delete", :message_id => msg_id})
end
end
@lucygeneric

jpr5 does this still work? It feels like they have closed a few of these routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.