Skip to content
zombified edited this page Apr 3, 2011 · 6 revisions

Objects

Line Object

This object is passed into the 'raw' events emitted from the IRC Client object. 'Raw' events are typically a numeric value, human readable forms of the numeric value (based on RFC 1459), or just raw textual commands.

Properties

  • raw
    the raw line received from the server
  • prefix
    the line prefix as defined in the RFC
  • server_or_nick
    the servername or nickname the message came from
  • user
    the user name the message came from, note: if server_or_nick is a servername, then this value will be undefined
  • host
    the host name the message came from, note: if server_or_nick is a servername, then this vlaue will be undefined
  • command
    the numeric or human readable command identified by the received line
  • targets
    an array of nicks or channel names that the received command targets, may be undefined or empty
  • params
    an array of parameters that the received command has, may be undefined or empty
  • message
    the trailing message found in the received line

IRC Client

This is the object exported from the module.

Properties

  • host
    IRC host, ex: irc.freenode.net
  • port
    Typically 6667.
  • nick
    The nick name to register the client with.
  • user
    The clients user name. Defaults to 'guest'.
  • real
    The clients real name. Defaults to 'Guest'.
  • pass
    Password, if any. Defaults to an empty string.
  • connected
    [true] if the client is connected to the host.
  • tryReconnect
    [true] by default. If [true], then the client will try to re-connect to the server if it is disconnected for any reason (including timeout, error, or manual disconnection).

Constructor

Parameters

  • host: sets host property
  • port: sets port property
  • nick: sets nick property

Methods

  • connect
    Creates a connection to the IRC host on the specified port.

  • disconnect
    If the client is connected to the IRC host, this method disconnects the client. NOTE: if the property tryReconnect is set to [true], the client will attempt to reconnect.

  • send
    Creates a line to send to the server. Every argument will be joined together, separated by spaces with the command terminator, '\r\n' appended to the end.

    For example, if you wanted to send the PRIVMSG command manually, you could use code similar to:

    ircc.send('PRIVMSG', '#channel', ':this is a message');
    

    Note the ':' beginning the message portion of the PRIVMSG command.

  • join
    Parameters:

    • channel
      The channel to join

    Sends the JOIN command to the host

  • setNick
    Parameters:

    • nick
      The nick name to change to

    Allows the bot's nick to change.

  • quit
    Parameters:

    • message
      A message to send along with the quit command

    Sends the QUIT command to the server and disconnects the client. NOTE: if the tryReconnect property is set, the client will attempt to reconnect.

  • part
    Parameters:

    • channels
      A list of channels to send the PART command to

    Causes the client to send the PART command to the given channels.

  • topic
    Parameters:

    • channel
      The channel to get/set the topic for.
    • topic
      Optional. The channels topic is attempted to be set to this value. If not present, then the current topic will be requested.

    Gets or sets the specified channel's topic, depending on whether or not the topic parameter is present and has a value.

  • names
    Parameters:

    • channels
      Optional. A list of channels to retrieve name lists for. If not present, or if empty, then all names from all visible channels on the host are requested.

    Request a list of names from the server.

  • privmsg
    Parameters:

    • to
      A list of all channels and/or nicks to send the message to
    • message
      The message to send

    Send a PRIVMSG message to one or more channels or nicks.

  • notice
    Parameters:

    • to
      A list of all channels and/or nicks to send the message to
    • message
      The message to send

    Send a NOTICE message to one or more channels or nicks.

  • me
    Parameters:

    • to
      A list of all channels and/or nicks to send the action to
    • message
      The action to send

    Send out an action message

Clone this wiki locally