Merge branch 'promise' of https://github.com/M2Ys4U/KiwiIRC into M2Ys4U-promise
[KiwiIRC.git] / server_modules / example.js
index df1136091cfd29db422fbb0e1f02900ad48392af..a12f8ddb62b119de689b45502e2282d789e413a5 100644 (file)
@@ -3,12 +3,38 @@ var kiwiModules = require('../server/modules');
 var module = new kiwiModules.Module('Example Module');
 
 
-module.subscribe('client:connected', function(data) {
-    console.log('Client connection:', data);
+// A web client is connected
+module.on('client created', function(event, data) {
+    console.log('[client connection]', data);
+    event.callback();
 });
 
 
-module.subscribe('client:commands:msg', function(data) {
-    console.log('Client msg:', data.args.target, ': ', data.args.msg);
-    data.args.msg += ' - modified!';
-});
\ No newline at end of file
+// The Client recieves a IRC PRIVMSG command
+module.on('irc message', function(event, data) {
+       console.log('[MESSAGE]', data.irc_event);
+    event.callback();
+});
+
+// The Client recieves a IRC USER NOTICE command
+module.on('irc user notice', function(event, data) {
+       console.log('[NOTICE]', data.irc_event);
+    event.callback();
+});
+
+// The client recieves an IRC JOIN command
+module.on('irc channel join', function(event, data) {
+       console.log('[JOIN]', data.irc_event);
+    event.callback();
+});
+
+
+// A command has been sent from the client
+module.on('client command', function(event, data) {
+       var client_method = data.command.method;
+       var client_args = data.command.args;
+
+       console.log('[CLIENT COMMAND]', client_method);
+       console.log('    ', client_args);
+    event.callback();
+});