【问题标题】:Slack bot - using Botkit to clear old messagesSlack bot - 使用 Botkit 清除旧消息
【发布时间】:2016-08-10 02:05:13
【问题描述】:

我正在使用 botkit 开发一个自定义机器人,它将删除旧消息(例如,所有超过一周的消息)。例如,我会在使用 slack 时说“@custombot delete”。我添加到 custombot.js 的新代码是

controller.hears('delete','direct_mention',function(bot,message) {
   // customized code for removing old messages 
});

我一直在研究 Slack 的 API 并试图弄清楚如何构建这个自定义代码。有人能指出我如何做到这一点的方向吗?

我理解代码是这样的

bot.api.chat.delete({},function(err,response) {
   //Do something...
})

但是,我想针对每个频道中早于特定日期的所有消息。

谢谢。

【问题讨论】:

    标签: bots slack-api botkit


    【解决方案1】:

    不幸的是,没有简单的方法可以做到这一点。您必须使用channels.historyim.historygroups.historympim.history 来检索消息,然后在您希望删除的每条消息上单独使用chat.delete

    您可能想查看this Python script 以了解它是如何完成的。

    【讨论】:

      猜你喜欢
      • 2017-11-05
      • 1970-01-01
      • 2018-06-30
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多