Skip to content

Instantly share code, notes, and snippets.

@precipice
Created February 22, 2016 06:14
Show Gist options
  • Save precipice/330d7884dfae50bb5564 to your computer and use it in GitHub Desktop.
Save precipice/330d7884dfae50bb5564 to your computer and use it in GitHub Desktop.
Announcing a session via the Slack API
def announce
users = @proposal.votes_for.up.by_type(Person).voters.map {|p| "<@#{p.slug}>" }.to_sentence.html_safe
text = "#{users}: #{params[:announcement]}"
client = Slack::Client.new(token: current_person.slack_access_token)
response = client.chat_postMessage channel: "#fiascon", text: text, as_user: true
respond_to do |format|
if response["ok"]
format.json { render json: [], status: :created }
else
format.json { render json: response["error"], status: :bad_request }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment