Home

GradysGhost edited this page Jun 4, 2013 · 7 revisions

What is jIRC?

jIRC is an extensible IRC bot written in Node.JS and liberally using martynsmith's irc module.

What can it do?

jIRC connects to an IRC server as a client and joins channels as configured. Plugins provide functionality to those channels. Some common functionality includes printing out web page titles when URLs are posted to the channel, logging the channel's activity, and browsing or searching those logs from a web browser.

There are several plugins packaged with jIRC, but if they don't do what you want, you can (and should) easily write your own to suit your needs (and then share it). See the Plugins page for an exhaustive list.

How does it work?

The irc Node module acts as an IRC client. The irc client calls functions in jIRC when certain events occur on the IRC server. jIRC forwards those calls up to plugins when they occur. The plugins react to the events. Those events are elaborated on in the Writing Plugins page.

jIRC Configuration

Global configuration is made in the config.json file. Basic configuration options are:

  • clients - An object containing client objects. Details on client configuration can be found below.
  • commandChar - A passive option. Plugins may (should) use this value to determine if they've been issued a command. Defaults to '.'. All documentation in this wiki referring to issuing commands assumes this default value.
  • maxMessageLength - Some IRC servers will reject messages outright if they exceed a certain length to prevent spamming. Client-to-server messages longer than this option's value will be truncated at this value to avoid that problem. Defaults to 512.
  • pluginDir - The directory in which plugins can be found. Defaults to './plugins'.
  • plugins - An array of strings representing the filenames of plugins to load. These plugins must have a file in the pluginDir with these values + '.js'. For example, the 'url' plugin's code is at './plugins/url.js'. Sequence matters; plugins get loaded in the order in which they're listed here. This is sometimes important. Don't load logbrowser before logger, for instance, since the former depends on the latter.

Client Configuration

The global configuration contains a clients object. This contains a series of client objects. A client object looks something like this:

'arbitrary_client_name' : {
  'host' : 'irc.hostname.com',
  'nick' : 'botNick',
  'options' : {
    // Options
  }
}
  • host - The hostname or IP address of the IRC server to connect to.
  • nick - The nick to use when connecting.
  • options - Options defined in here will be passed directly to the constructor of the irc Client object. For a full listing of your options, see this documentation.