Skip to content

Commit

Permalink
Merge pull request #78 from coursehero/fix-icon-url-issue-in-streaming
Browse files Browse the repository at this point in the history
Fix the icon_url issue reported by PR 77 in the streaming mode
  • Loading branch information
Chikashi-Kato committed May 11, 2021
2 parents 9b570f8 + 685d159 commit bc1ab44
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions slacktee.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,19 @@ function send_message()
fi

if [[ -z "$streaming_ts" ]]; then
json="{\
\"channel\": \"$chan\", \
\"username\": \"$username\", \
$message_attr \"icon_emoji\": \"$icon_emoji\", \
\"icon_url\": \"$icon_url\" $parseMode}"
if [[ ! -z "$icon_url" ]];then
json="{\
\"channel\": \"$chan\", \
\"username\": \"$username\", \
$message_attr \"icon_url\": \"$icon_url\", \
$parseMode}"
else
json="{\
\"channel\": \"$chan\", \
\"username\": \"$username\", \
$message_attr \"icon_emoji\": \"$icon_emoji\", \
$parseMode}"
fi

post_result=$(curl -H "Authorization: Bearer $token" -H 'Content-type: application/json; charset=utf-8' -X POST -d "$json" https://slack.com/api/chat.postMessage 2> /dev/null)
if [ $(get_ok_in_response $post_result) != "true" ]; then
Expand Down

0 comments on commit bc1ab44

Please sign in to comment.