My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 18, 2007 by soubok
Labels: Featured
QuickStart  

!! NEW VERSION IN PROGRESS !!

!! NEW VERSION IN PROGRESS !!

!! NEW VERSION IN PROGRESS !!

Introduction

The aim of this page is to explain you how jsircbot works, an how to customize it.

The first obvious thing you have to know is how does IRC works.

Internet Relay Chat Client Protocol and Server Protocol.

jsircbot is nothing else that a non-interactive IRC client ( on the other hand mIRC is an interactive IRC client ).

Overview

jsircbot is split in two parts :

jsircbot core

The core manages :

A module is a simple object that implements some functions ( Core -> Module )

Note: It is NOT mandatory for a module to implement these functions. Note2: All modules are notified by these events.

A module can call some functions to the Core

Note: All theses functions are stored in the current object of the module ( this )

Module public API

It is possible for a module to create and export its own API. For example, the CTCP module export AddCtcpListener(), RemoveCtcpListener(), CtcpQuery() and CtcpResponse() function and are available for other modules.

The module use the this.api object ( that is provided by the core at the module initialization) to store its public API. this.api object is common to all modules.

Core data API

The core implements a listener-based tree structure that is available for modules to store any kind of information. this structure is shared between all modules and the core. In a module, the root object of this storage space is this.data. eg. the ChannelModule use this structure to store general informations about the channel it manages.

...      
TOPIC: function( from, command, channel, topic ) {

  if ( channel != _channel )
    return;
  setData( this.data.channel[channel].topic, topic );
},
...

In the previous example, the ChannelModule listen for any TOPIC messages from the IRC server, and store the topic string in a right place. next, anyone that are listening this node of the tree will receive a notification.

eg: the following example, send a message to the channel when the topic has changed

addDataListener( _module.data.channel['#jslibs'].topic, function(info) {
       
  _module.Send( 'PRIVMSG #jslibs :the topic has changed: ' + info );
});

Default modules

The current jsircbot distribution cames with some default modules



Sign in to add a comment
Hosted by Google Code