Slack Botkit-如何获得消息's来自'reaction_aded'事件
Slack Botkit - How to get a message's content from a 'reaction_added' event
当向消息添加反应时,我使用botkit框架进行响应,但我不确定在触发事件时如何提取消息的内容。以下是我目前拥有的:
controller.on('reaction_added',function(bot, event) {
if (event.reaction == 'x') {
// bot reply with the message's text
}
});
根据Slack API,我只能获得像event.item这样的数据,该数据具有消息的类型、通道和ts。有人知道如何做到这一点吗?
想明白了。给定时间戳和通道,我可以手动在通道历史记录中搜索消息并提取我需要的数据。
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
});
}