Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 994 Bytes

.verb.md

File metadata and controls

52 lines (38 loc) · 994 Bytes

Usage

var Gitter = require('{%= name %}');

API

{%= apidocs('index.js') %}

Events

The following events will be emitted after .listen has been called and are available to be listened for:

chatMessages

The chatMessages event will be emitted when anything happens to a chat message. Check the .operation property to see what is happening to the message:

gitter.on('chatMessages', function(msg, room) {
  console.log(msg);
  switch (msg.operation) {
    case 'create':
      // new message being created
      break;
    case 'patch':
      // message was updated (e.g. someone marked it as "read")
      break;
  }
});

events

The events event will be emitted when an event in the room occurs.

gitter.on('events', function(event, room) {
  console.log(event);
});

users

The users event will be emitted when a user joins or leaves a room:

gitter.on('users', function(user, room) {
  console.log(user);
});