Skip to content

Commit

Permalink
Updated README with info for colors and join_or_leave in message logg…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
stephenmcd committed Dec 22, 2012
1 parent c10abfa commit 1594f3c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,9 @@ the log record instance:
* ``record.channel`` - The IRC channel the message occurred on.
* ``record.nickname`` - The nickname of the user who sent the
message.
* ``record.msg`` - The message itself.
* ``record.msg`` - The actual message string itself.
* ``record.join_or_leave`` - ``True`` if the record was for a user
joining or leaving the channel, otherwise ``False``.

Here's an example of adding an extra logging handler for IRC messages::

Expand Down Expand Up @@ -501,13 +503,17 @@ events out to the console::
};

// When someone joins or leaves the channel, we're given the
// entire user list.
// entire user list. It'a an array of objects, each with a
// nickname and color property.
client.onNicknames = function(nicknames) {
console.log('The user list changed, here it is: ' + nicknames.join(', '));
nicknames = $.map(nicknames, function(obj) {
return obj.nickname;
}).join(', ');
console.log('The user list changed, here it is: ' + nicknames);
});

// Whenever a message is received from the channel, it's an
// object with nickname and message properties.
// object with nickname, message and color properties.
client.onMessage = function(data) {
console.log(data.nickname + ' wrote: ' + data.message);
});
Expand All @@ -526,6 +532,12 @@ As you may have guessed, the server-side settings configured for
Gnotty are passed directly into the ``gnotty`` JavaScript function,
which then creates its own ``IRCClient`` instance.

You'll also see the data sent to the ``onMessage`` and ``onNickname``
events contain color values that the interface can use for colorizing
nicknames. These are calculated on the server, so that both the chat
interface and message archive produce consistent colors every time
a particular nickname is displayed.


Hosting Private Chat Rooms
==========================
Expand Down

0 comments on commit 1594f3c

Please sign in to comment.