【问题标题】:Slack Botkit - How to get a message's content from a 'reaction_added' eventSlack Botkit - 如何从“reaction_add”事件中获取消息内容
【发布时间】:2016-08-27 13:13:51
【问题描述】:

我正在使用 botkit 框架在向消息添加反应时做出响应,但我不确定在触发事件时如何提取消息的内容。以下是我目前拥有的:

controller.on('reaction_added',function(bot, event) {

   if (event.reaction == 'x') {
      // bot reply with the message's text
   }
});

根据Slack API,我只能得到像event.item这样的数据,它有消息的类型、通道和ts。有谁知道如何做到这一点?

【问题讨论】:

    标签: javascript node.js slack-api


    【解决方案1】:

    想通了。给定时间戳和频道,我可以在频道历史记录中手动搜索消息并提取我需要的数据。

    function getTaskID(channel_id, timestamp, callback) {
      slack.api("channels.history", {
          channel: channel_id,
          latest: timestamp,
          count: 1,
          inclusive: 1
        }, function(err, response) {
          // do something with the response
      });
    }
    

    【讨论】:

    • 答案不是很清楚,等待更好的解决方案。
    • 你在这个例子中使用了哪个 slack 包?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    • 2020-09-05
    • 2021-12-13
    • 2013-04-02
    相关资源
    最近更新 更多