从事件 api 响应中查看消息的文本
Look a message's text from events api response
我穿的是休闲裤events API and have setup a subscription to the reactions_added event. Now when a reaction is added to a message, slack will send me a post body with all the details of the dispatched event as described here。
我遇到的问题是我想获取详细信息,特别是我的用户已做出反应的消息的 text
,以便我可以 parse/store 等该特定消息。我假设该消息会 return 带有某种类型的 UUID,然后我可以响应回调并获取文本,但是我发现很难获取特定消息。
我看到唯一可用的端点是 channels.history
,它似乎没有提供我正在寻找的粒度。
所以 tl;dr 是:如何通过休闲裤 API 查找从事件 API 发送的消息文本?给个信息我有event_ts,channel和message ts我觉得就够了。我正在使用 ruby slack-api gem FWIW。
您确实可以使用方法 channels.history
(https://api.slack.com/methods/channels.history) 从 public 频道检索消息。 reaction_added
派发的事件包括原始消息的通道 ID 和时间戳(在 item
中)并且 channelId + 时间戳的组合应该是唯一的。
不过请注意使用正确的时间戳。您需要使用 item.ts
而不是 event_ts
来自文档的完整示例调度事件:
{
"token": "z26uFbvR1xHJEdHE1OQiO6t8",
"team_id": "T061EG9RZ",
"api_app_id": "A0FFV41KK",
"event": {
"type": "reaction_added",
"user": "U061F1EUR",
"item": {
"type": "message",
"channel": "C061EG9SL",
"ts": "1464196127.000002"
},
"reaction": "slightly_smiling_face"
},
"event_ts": "1465244570.336841",
"type": "event_callback",
"authed_users": [
"U061F7AUR"
]}
因此调用 channels.history
设置这些值应该有效:
- 最新 = item.ts 值
- 最老 = item.ts 值
- 包含 = 1
- 频道=item.channel价值
如果您想从私人频道获取消息,您需要使用 groups.history
。
我穿的是休闲裤events API and have setup a subscription to the reactions_added event. Now when a reaction is added to a message, slack will send me a post body with all the details of the dispatched event as described here。
我遇到的问题是我想获取详细信息,特别是我的用户已做出反应的消息的 text
,以便我可以 parse/store 等该特定消息。我假设该消息会 return 带有某种类型的 UUID,然后我可以响应回调并获取文本,但是我发现很难获取特定消息。
我看到唯一可用的端点是 channels.history
,它似乎没有提供我正在寻找的粒度。
所以 tl;dr 是:如何通过休闲裤 API 查找从事件 API 发送的消息文本?给个信息我有event_ts,channel和message ts我觉得就够了。我正在使用 ruby slack-api gem FWIW。
您确实可以使用方法 channels.history
(https://api.slack.com/methods/channels.history) 从 public 频道检索消息。 reaction_added
派发的事件包括原始消息的通道 ID 和时间戳(在 item
中)并且 channelId + 时间戳的组合应该是唯一的。
不过请注意使用正确的时间戳。您需要使用 item.ts
而不是 event_ts
来自文档的完整示例调度事件:
{
"token": "z26uFbvR1xHJEdHE1OQiO6t8",
"team_id": "T061EG9RZ",
"api_app_id": "A0FFV41KK",
"event": {
"type": "reaction_added",
"user": "U061F1EUR",
"item": {
"type": "message",
"channel": "C061EG9SL",
"ts": "1464196127.000002"
},
"reaction": "slightly_smiling_face"
},
"event_ts": "1465244570.336841",
"type": "event_callback",
"authed_users": [
"U061F7AUR"
]}
因此调用 channels.history
设置这些值应该有效:
- 最新 = item.ts 值
- 最老 = item.ts 值
- 包含 = 1
- 频道=item.channel价值
如果您想从私人频道获取消息,您需要使用 groups.history
。