Created
February 22, 2016 06:14
-
-
Save precipice/330d7884dfae50bb5564 to your computer and use it in GitHub Desktop.
Announcing a session via the Slack API
This file contains 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
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