Skip to content

Instantly share code, notes, and snippets.

@hidepin
Last active April 8, 2017 01:11
Show Gist options
  • Select an option

  • Save hidepin/b82091a863bdd8b512df0e175e3c4026 to your computer and use it in GitHub Desktop.

Select an option

Save hidepin/b82091a863bdd8b512df0e175e3c4026 to your computer and use it in GitHub Desktop.

http://doatt.com/2015/02/18/the-hubot-msg-object/

http://qiita.com/bouzuya/items/d65a394cac9e76b56d3d

module.exports = (robot) ->
  robot.hear /PING$/i, (msg) ->
    msg.send "PONG!"

  robot.hear /HELLO$/i, (msg) ->
    msg.send "hello!"

  robot.hear /debug/, (msg) ->
    console.log Object(msg)
module.exports = function(robot) {
    robot.hear(/hi/i, function(msg) {
        msg.send('Hi');
    });
    robot.hear(/hey/i, function(msg) {
        msg.send('HEY');
    });
    robot.hear(/hoi/i, function(msg) {
        msg.send(msg.message.text + msg.name + ' hoi ');
    });
    robot.hear(/debug/i, function(msg) {
        console.log(Object(msg));
    });
};
app_1  |   message:
app_1  |    TextMessage {
app_1  |      user:
app_1  |       User {
app_1  |         id: 'm9sodpzqsf8fpymegu1jhnnhqo',
app_1  |         name: 'admin',
app_1  |         room: 'town-square' },
app_1  |      text: 'subot debugy',
app_1  |      id: undefined,
app_1  |      done: false,
app_1  |      room: 'town-square' },
app_1  |   match: [ 'debug', index: 6, input: 'subot debugy' ],
app_1  |   envelope:
app_1  |    { room: 'town-square',
app_1  |      user:
app_1  |       User {
app_1  |         id: 'm9sodpzqsf8fpymegu1jhnnhqo',
app_1  |         name: 'admin',
app_1  |         room: 'town-square' },
app_1  |      message:
app_1  |       TextMessage {
app_1  |         user: [Object],
app_1  |         text: 'subot debugy',
app_1  |         id: undefined,
app_1  |         done: false,
app_1  |         room: 'town-square' } } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment