简体   繁体   中英

Make Hubot send a direct message in HipChat

How do I tell Hubot to send a direct message using the HipChat adapter? I've tried many different options without success.

module.exports = function (robot) {
  robot.respond(/hi/i, function (msg) {
    msg.send(msg.message.user.room, 'hi'); // outputs to current room
    msg.send(msg.message.user.id, 'hi'); // outputs to current room
    msg.send(msg.message.user, 'hi'); // outputs to current room
    msg.reply('hi'); // @mentions the user in the current room
    msg.reply_to('hi') // no reply_to method though I thought I saw this somewhere
  });
};

It took me awhile to find it, but it turns out this works:

module.exports = function (robot) {
  robot.respond(/hi/i, function (msg) {
    robot.send({
      user: msg.message.user.jid
    }, 'hi');
  });
};

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM