ChannelManager

(c) 2013-2014 http://ircanywhere.com

Author: Ricki Hastings

IRCAnywhere server/channels.js

class ChannelManager.ChannelManager()

This object is responsible for managing everything related to channel records, such as the handling of joins/parts/mode changes/topic changes and such. As always these functions are extendable and can be prevented or extended by using hooks.

Returns:void
ChannelManager.queueJoin(id, channel, key)

Queues a channel for join

Arguments:
  • id (objectid) – A valid Mongo ObjectID for the networks collection
  • channel (string) – A valid channel name
  • key (string) – A key to join the channel if necessary
Returns:

void

ChannelManager.getChannel(network, channel)

Gets a tab record from the parameters passed in, strictly speaking this doesn’t have to be a channel, a normal query window will also be returned. However this class doesn’t need to work with anything other than channels.

A new object is created but not inserted into the database if the channel doesn’t exist.

Arguments:
  • network (string) – A network string such as ‘freenode’
  • channel (string) – The name of a channel with the hash key ‘#ircanywhere’
Returns:

A promise with a channel object straight out of the database.

ChannelManager.insertUsers(key, channel, users[, force])

Inserts a user or an array of users into a channel record matching the network key network name and channel name, with the option to force an overwrite

Arguments:
  • key (objectid) – A valid Mongo ObjectID for the networks collection
  • channel (string) – The channel name ‘#ircanywhere’
  • users ([object]) – An array of valid user objects usually from a who/join output
  • [force] (boolean) – Optional boolean whether to overwrite the contents of the channelUsers
Returns:

A promise containing final array of the users inserted

ChannelManager.removeUsers(key[, channel, users])

Removes a specific user from a channel, if users is omitted, channel should be equal to a nickname and that nickname will be removed from all channels records on that network.

Arguments:
  • key (objectid) – A valid Mongo ObjectID for the networks collection
  • [channel] (string) – A valid channel name
  • users (array) – An array of users to remove from the network or channel
Returns:

void

ChannelManager.updateUsers(key, users, values)

Updates a user or an array of users from the specific channel with the values passed in.

Arguments:
  • key (objectid) – A valid Mongo ObjectID for the networks collection
  • users (array) – A valid users array
  • values (object) – A hash of keys and values to be replaced in the users array
Returns:

void

ChannelManager.updateModes(key, capab, channel, mode)

Takes a mode string, parses it and handles any updates to any records relating to the specific channel. This handles user updates and such, it shouldn’t really be called externally, however can be pre and post hooked like all other functions in this object.

Arguments:
  • key (objectid) – A valid Mongo ObjectID for the networks collection
  • capab (object) – A valid capabilities object from the ‘registered’ event
  • channel (string) – Channel name
  • mode (string) – Mode string
Returns:

void

ChannelManager.updateTopic(key, channel, topic, setby)

Updates the specific channel’s topic and setby in the internal records.

Arguments:
  • key (objectid) – A valid Mongo ObjectID for the networks collection
  • channel (string) – A valid channel name
  • topic (string) – The new topic
  • setby (string) – A setter string, usually in the format of 'nickname!username@hostname
Returns:

void