-
Notifications
You must be signed in to change notification settings - Fork 277
scripting examples
Darren edited this page Feb 4, 2016
·
1 revision
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') + ': ';
});
});
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);
});
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 + '!');
}
});
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());
});
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);
Officially mirrored at https://kiwiirc.com/docs/