【发布时间】:2018-12-08 08:02:38
【问题描述】:
我正在使用 botkit,我有一个响应某个单词的机器人。 但我不希望机器人在最近这样做时做出响应。
目前我正在使用channels.history 方法检索 4 条最近的消息然后找到机器人 ID,如果它在那里它不会回复。这不漂亮,我一直在寻找有用的方法来使用,但我找不到任何方法。我只是想知道该机器人是否最近发布并根据它执行操作。
const targetBotID = 'GKALXJCM6'
bot.api.channels.history({
channel: message.channel,
latest: message.ts,
count: 4,
inclusive: 1,
}, function(err, response) {
if(err) { bot.reply(message, 'Something is wrong with me, check log if there is??'); }
if(response){
const recentPostFound = response.messages.filter(function (member) {
return member.user === targetBotID;
});
if(recentPostFound){
return bot.reply();
}
return bot.reply(answer) // Answer if no matching id found
}
});
【问题讨论】: