代码之家  ›  专栏  ›  技术社区  ›  Ethan

bot帖子中的松弛更改主题

  •  0
  • Ethan  · 技术社区  · 7 年前

    我有一个机器人,代码如下:

    bot.on('message', function (data) {
        // all ingoing events https://api.slack.com/rtm
        console.log(data);
        if (data.content.includes('new')) {
            bot.postMessageToUser(data.subtitle, '#282828 ,#565656 ,#2AFC86 ,#282828 ,#434745 ,#FFFFFF ,#2AFC8e ,#DB6668 ');
        } else {
            bot.postMessageToUser(data.subtitle, 'I don\'t understand :scream_cat:\nPlease type "new" for a new color scheme.');
        }
    });
    

    当我发布配色方案时,它看起来像这样:

    我发布它的方式是期望的结果。有什么办法可以让它工作吗?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Ethan    7 年前

    只需添加 {as_user: true}

    bot.on('message', function (data) {
        // all ingoing events https://api.slack.com/rtm
        console.log(data);
        if (data.content.includes('new')) {
            bot.postMessageToUser(data.subtitle, '#282828 ,#565656 ,#2AFC86 ,#282828 ,#434745 ,#FFFFFF ,#2AFC8e ,#DB6668 ', {as_user: true});
        } else {
            bot.postMessageToUser(data.subtitle, 'I don\'t understand :scream_cat:\nPlease type "new" for a new color scheme.', {as_user: true});
        }
    });