UNPKG

transit-im

Version:

express-like framework for AIM bots creation (ICQ as well)

70 lines (54 loc) 1.57 kB
// Generated by CoffeeScript 1.6.3 (function() { var app, echo, transit; transit = require('../../transit'); app = transit(); app.use(transit.commandLine()); app.use(transit.alias((function(name, cb) { return cb([ { pattern: "hi", replacement: "hello", autohelp: "same as 'hello'" }, { pattern: "jecho {param}", replacement: "echo {param} desu", autohelp: "japaneese version of echo" } ]); }), (function(name, data) { return console.log("Aliases saved, now there is " + data.length + " of them"); }))); app.use(transit.commandParser()); app.use(transit.doNotWaitForResponse()); app.formatOutput("braces", function(data, options, cb) { return cb(null, "(" + data + ")"); }); app.receive('hello', { autohelp: "just greeting" }, function(req, res) { return res.sendBack("Hello " + req.user); }); echo = function(params, cb) { if (params.indexOf("error") > -1) { return cb("Error example"); } else { return cb(null, params.join(" ")); } }; app.receive('echo {{params}}', { autohelp: "echoes provided params back" }, function(req, res) { return echo(req.attrs.params, res.braces.asCallback); }); app.receive(function(req, res) { return res.sendBack("I do not know what is <" + req.data + "> :("); }); app.use(transit.autohelp({ showOnUnknown: false })); app.on('exit', function(req, res) { return console.log("User " + req.user + " left"); }); app.start(); }).call(this);