conversations.repilesを使います。最低限必要なのは
トークン
token($tに置いてます)チャンネルID
channel($cに置いてます)タイムスタンプ
ts
です。
例
# bash
export u="https://slack.com/api/conversations.replies?token=$t&channel=$c&ts=1555390101.000300"
# fish
# set -l u "https://slack.com/api/conversations.replies?token=$t&channel=$c&ts=1555390101.000300"
curl -Ss $u | jq .messagesmessagesというプロパティに配列でメッセージが入っています。以下はただのメッセージのtsを設定した時のレスポンス例です。
[
{
"type": "message",
"subtype": "bot_message",
"text": "aa",
"ts": "1555390101.000300",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555389874.000100"
}
]次にスレッドです。同じようにスレッド化しているtsを使います。
# bash
export u="https://slack.com/api/conversations.replies?token=$t&channel=$c&ts=1555394677.001400"
# fish
# set -l u "https://slack.com/api/conversations.replies?token=$t&channel=$c&ts=1555394677.001400"
curl -Ss $u | jq .messagesスレッドの場合は、messagesにスレッドのメッセージが含まれ、配列1つ目のメッセージに、
replay_countreplay_user_countlatest_replyreply_usersrepilessubscribed
というプロパティが増えます。
[
{
"type": "message",
"subtype": "bot_message",
"text": "a",
"ts": "1555394677.001400",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555394677.001400",
"reply_count": 4,
"reply_users_count": 1,
"latest_reply": "1555398693.000400",
"reply_users": [
"BD0LHGB2S"
],
"replies": [
{
"user": "BD0LHGB2S",
"ts": "1555395278.001500"
},
{
"user": "BD0LHGB2S",
"ts": "1555395460.002100"
},
{
"user": "BD0LHGB2S",
"ts": "1555398692.000200"
},
{
"user": "BD0LHGB2S",
"ts": "1555398693.000400"
}
],
"subscribed": false
},
{
"type": "message",
"subtype": "bot_message",
"text": "aa",
"ts": "1555395278.001500",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555394677.001400"
},
{
"type": "message",
"subtype": "bot_message",
"text": "aaa",
"ts": "1555395460.002100",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555394677.001400"
},
{
"type": "message",
"subtype": "bot_message",
"text": "aaa",
"ts": "1555398692.000200",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555394677.001400"
},
{
"type": "message",
"subtype": "bot_message",
"text": "aaa",
"ts": "1555398693.000400",
"username": "Slack API Tester",
"bot_id": "BD0LHGB2S",
"thread_ts": "1555394677.001400"
}
]