This documentation is for the legacy version of Kiwi IRC, kept here only for reference.

See here for the actively developed Kiwi IRC

Scripting Examples

Note: These examples are using an experimental plugin system. Event names or structures may change. Take note of development changes as you update!

Open a query window instead of the user box when clicking a nickname in either a message or the nicklist
var events = kiwi.components.Events();
var network = kiwi.components.Network();

events.on('nick:select', function(event, data) {
    event.preventDefault();
    network.createQuery(data.member.get('nick'));
});
When clicking on a nickname in a message, insert the nickname into the control box (message input box)
var events = kiwi.components.Events();
var control = kiwi.components.ControlInput();

events.on('nick:select', function(event, data) {
    event.preventDefault();

    if (data.source !== 'message') {
        return;
    }

    control.input.val(function(idx, val){
        return val + data.member.get('nick') + ': ';
    }); 
});
Add custom items into the user box
var events = kiwi.components.Events();

events.on('usermenu:created', function(event, data) {
    var $item = $('<a>Click me!</a>');

    $item.on('click', function(event) {
        var nick = data.user.get('nick');
        alert('Your custom item has been clicked on ' + nick);
    });

    data.menu.addItem('my_plugin_name', $item);
});
Reply to any messages starting with !hello
var events = kiwi.components.Events();

events.on('message:new', function(event, data) {
    if (data.message.msg.match(/^!hello/)) {
        data.network.say(data.message.target, 'Hello there, ' + data.message.nick + '!');
    }
});
Add a /mytime command to send your local time
var control = kiwi.components.ControlInput();
var network = kiwi.components.Network();

control.on('command:mytime', function(data) {
    var current_channel = kiwi.panels().active;
    network.say(current_channel.get('name'), 'My time is: ' + (new Date()).toLocaleString());
});
Add a plugin icon in the bottom right
var control = kiwi.components.ControlInput();

var $plugin_icon = $('<a>I</a>');
$plugin_icon.on('click', function(event) {
    alert('Your plugin has been clicked!');
});

control.addPluginIcon($plugin_icon);