Skip to content

Post to thread #81

@ky4k0b

Description

@ky4k0b

I needed some stuff to be posted into thread for my logging purposes on production, so I came up with the following:

  1. add a new function for parsing response:
function get_thread_ts() {
    local response=$1
    echo "$(echo "$response" | jq -r .message.ts)"
}
  1. in function send_message() add to json
    "thread_ts": "$thread_ts",
    (var $thread_ts can be empty, slack will ignore it)

  2. in function send_message() execute get_thread_ts in else part:

if [[ $(get_ok_in_response "$post_result") != "true" ]]; then
    write_to_stderr "$post_result"
    exit_code=1
else
    get_thread_ts "$post_result"
fi
  1. in main() add thread_ts for uploading files:
    upload_result="$(curl -F file=@"$filename" -F token="$token" $channels_param -F thread_ts="$thread_ts" https://slack.com/api/files.upload 2> /dev/null)"
  2. add reading $thread_ts with -r key in parse_args()

And now I can do stuff like this:

thread_ts=$(echo anything|slacktee -q)
echo something|slacktee -r $thread_ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions