3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-26 20:52:39 +01:00
dbot/modules/units/units.js
thoso b43be1f900 Adding a unit converter
Due to issue #596 I coded a basic unit converter to convert time,
distance, mass, volume and digital values. It depends on node-units.

Also, fixed a typo.
2014-02-19 22:19:36 +01:00

34 lines
798 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 {
event.reply(dbot.t('result', {
'input': query,
'output': result
}));
var result = unit.convert(query);
}
} catch (e) {
event.reply(dbot.t('error'));
}
}
};
};
exports.fetch = function(dbot) {
return new units(dbot);
};