Skip to content

scripting server_modules

Darren edited this page Feb 4, 2016 · 1 revision

Server Modules

Server modules are installed by the kiwi server admin and are loaded into the server at server start up.

Loading a server module

By default, server modules are placed within the server_modules folder. You can then enable them by modifying your config.js as follows:

conf.modules = [
    'control',
    'your_module_name'
];

Much more information on server modules is needed. Bug prawnsalad to do this :)

For the time being.. a very brief look at a server module:

var kiwiModules = require('../server/modules'),

var module = new kiwiModules.Module('Kiwi');


module.on('dispose', function() {
    // Any module cleanup here
});


// Before making a socket connection
module.on('irc connecting', function (event, event_data) {
    event.wait = true;

    // Some useful objects available to you here
    var irc_connection = event_data.connection;
    var client = event_data.connection.state.client;
    var http_request = client.websocket.request;

    // You can override connection details
    // irc_connection.username = 'some_username';
    // irc_connection.nick = 'overridden_nick';

    // Get access to the origin HTTP request details
    // Access the cookie via:
    // http_request.headers.cookie

    // Maybe retrieve user info from a third party session store and update the
    // connection details..

    // Once you're done, just call the following:
    event.callback();
});