したいこと
Ruby経由でSlackにシングルクォートを含んだwebhookテキストを飛ばす。
飛ばしたいテキスト例: Hello! I'm Takutope. You're so cool. I lovin' you.
現在のコード
ruby
1 2# Slack 3module Slack 4 def self.send_message(name) 5 txt = "Hello! I'm #{name}. You're so cool. I lovin' you" 6 `curl -X POST --data-urlencode 'payload={"channel": "#hello", "username": "mr_hello", "text": "#{txt}" }' https://hooks.slack.com/services/xxxxx/xxxxxxxxxxxxxx` 7 end 8end 9 10Slack.send_message("Takutope") 11
実行結果
mr_hello
Hello! Im Takutope. Youre so cool. I lovin you
クォーテーションを残す方法はありますか?
なぜslack-notifier などのgem を使わずにcurl なのですか? ( https://github.com/stevenosloan/slack-notifier )
私がそういうクールなgemを知らなかったからですね。
回答2件
あなたの回答
tips
プレビュー