3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-27 22:39:26 +01:00
dbot/modules/units/units.js
2014-02-20 20:25:50 +01:00

35 lines
814 B
JavaScript

/**
* Module Name: Unit Conversion
* Description: Converts units.
* Requires: node-units [https://github.com/brettlangdon/node-units]
* TODO: currency converting
*/
var _ = require('underscore')._,
unit = require('node-units');
var units = function(dbot) {
this.commands = {
'~convert': function(event) {
var query = event.input[1];
try {
var result = unit.convert(query);
event.reply(dbot.t('result', {
'input': query,
'output': result
}));
}
catch (e) {
event.reply(dbot.t('error'));
}
}
}
};
};
exports.fetch = function(dbot) {
return new units(dbot);
};