Chat Messages

Maintainer:Sebastian Kippe seba.nosp@m.stian@kip.nosp@m..pe
Version:0.6.0

This module stores chat messages in daily archive files.

Summary
Chat Messages
Schemas
chat-messages/dailyRepresents one day of chat messages
DailyArchiveA daily archive stores IRC messages by day.
Properties
serverContains information about the chat server/network
channelNameName of the IRC channel (e.g.
dateDate of the archive’s content
isPublic`true` for public archives, `false` for private ones
parsedDateObject containing padded year, month and day of date
dateIdDate string in the form of YYYY/MM/DD
pathDocument path of the archive file
clientPublic or private BaseClient, depending on isPublic
previousDate of previous log file as YYYY/MM/DD
nextDate of next log file as YYYY/MM/DD
Functions
addMessage
addMessagesLike addMessage, but for multiple messages at once.
removeDeletes the entire archive document from storage
_updateDocumentUpdates and writes an existing archive document
_createDocumentCreates and writes a new archive document
_buildArchiveObjectBuilds the object to be stored in remote storage
_updatePreviousArchiveFinds the previous archive document and updates its today.next value
_findPreviousArchiveReturns the previous archive document
_syncWrite archive document

Schemas

chat-messages/daily

Represents one day of chat messages

Example

{
  "@context": "https://kosmos.org/ns/v1",
  "@id": "chat-messages/freenode/channels/kosmos/",
  "@type": "ChatChannel",
  "name": "#kosmos",
  "ircURI": "irc://irc.freenode.net/kosmos",
  "today":  {
    "@id": "2015/01/01",
    "@type": "ChatLog",
    "messageType": "InstantMessage",
    "previous": "2014/12/31",
    "next": "2015/01/02",
    "messages": [
      { "date": "2015-06-05T17:35:28.454Z", "user": "hal8000", "text": "knock knock" },
      { "date": "2015-06-05T17:37:42.123Z", "user": "raucao", "text": "who's there?" },
      { "date": "2015-06-05T17:55:01.235Z", "user": "hal8000", "text": "HAL" }
    ]
  }
}

DailyArchive

A daily archive stores IRC messages by day.

Parameters (object)

serverChat server info (see DailyArchive.server)
channelNameName of room/channel
dateDate of archive day
isPublicStore logs in public folder (defaults to false)
previousDate of previous log file as YYYY/MM/DD; looked up automatically when not given
nextDate of next log file as YYYY/MM/DD; looked up automatically when not given

Example for IRC

var archive = new chatMessages.DailyArchive({
  server: {
    type: 'irc',
    name: 'freenode',
    ircURI: 'irc://irc.freenode.net'
  },
  channelName: '#kosmos',
  date: new Date(),
  isPublic: true
});

Example for XMPP

var archive = new chatMessages.DailyArchive({
  server: {
    type: 'xmpp',
    name: '5apps',
    xmppMUC: 'muc.5apps.com'
  },
  channelName: 'watercooler',
  date: new Date(),
  isPublic: false
});
Summary
Properties
serverContains information about the chat server/network
channelNameName of the IRC channel (e.g.
dateDate of the archive’s content
isPublic`true` for public archives, `false` for private ones
parsedDateObject containing padded year, month and day of date
dateIdDate string in the form of YYYY/MM/DD
pathDocument path of the archive file
clientPublic or private BaseClient, depending on isPublic
previousDate of previous log file as YYYY/MM/DD
nextDate of next log file as YYYY/MM/DD
Functions
addMessage
addMessagesLike addMessage, but for multiple messages at once.
removeDeletes the entire archive document from storage
_updateDocumentUpdates and writes an existing archive document
_createDocumentCreates and writes a new archive document
_buildArchiveObjectBuilds the object to be stored in remote storage
_updatePreviousArchiveFinds the previous archive document and updates its today.next value
_findPreviousArchiveReturns the previous archive document
_syncWrite archive document

Properties

server

Contains information about the chat server/network

Properties

typeType of server/protocol (e.g.  “irc”, “xmpp”, “campfire”, “slack”)
nameShortname/id/alias of network/server (e.g.  “freenode”, “mycompanyname”)
ircURI(optional) IRC URI of network (e.g.  “irc://irc.freenode.net/”)
xmppMUC(optional) XMPP MUC service host (e.g.  “conference.jabber.org”)

channelName

Name of the IRC channel (e.g.  “#kosmos”)

date

Date of the archive’s content

isPublic

`true` for public archives, `false` for private ones

parsedDate

Object containing padded year, month and day of date

dateId

Date string in the form of YYYY/MM/DD

path

Document path of the archive file

client

Public or private BaseClient, depending on isPublic

previous

Date of previous log file as YYYY/MM/DD

next

Date of next log file as YYYY/MM/DD

Functions

addMessage

addMessage: function addMessage(message)

Parameters (object)

timestampTimestamp of the message
fromThe sender of the message
textThe message itself
typeType of message (one of text, join, leave, action)

addMessages

addMessages: function addMessage(messages,
overwrite)

Like addMessage, but for multiple messages at once.  Useful for bulk imports of messages.

Parameters

messagesArray of message objects (see params for addMessage)
overwriteIf true, creates a new archive file and overwrites the old one.  Defaults to false.

remove

remove: function()

Deletes the entire archive document from storage

_updateDocument

_updateDocument: function(archive,
messages)

Updates and writes an existing archive document

_createDocument

_createDocument: function(messages)

Creates and writes a new archive document

_buildArchiveObject

_buildArchiveObject: function()

Builds the object to be stored in remote storage

_updatePreviousArchive

_updatePreviousArchive: function()

Finds the previous archive document and updates its today.next value

_findPreviousArchive

_findPreviousArchive: function()

Returns the previous archive document

_sync

_sync: function(obj)

Write archive document

addMessage: function addMessage(message)
addMessages: function addMessage(messages,
overwrite)
Like addMessage, but for multiple messages at once.
remove: function()
Deletes the entire archive document from storage
_updateDocument: function(archive,
messages)
Updates and writes an existing archive document
_createDocument: function(messages)
Creates and writes a new archive document
_buildArchiveObject: function()
Builds the object to be stored in remote storage
_updatePreviousArchive: function()
Finds the previous archive document and updates its today.next value
_findPreviousArchive: function()
Returns the previous archive document
_sync: function(obj)
Write archive document
Contains information about the chat server/network
Close