Skip to content

Commit deb7843

Browse files
committed
Merge pull request jirwin#36 from purdyk/btcConv
Added btc converter. Why not.
2 parents 8081102 + 9538fe1 commit deb7843

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

plugins/doge.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ var async = require('async');
77
*/
88

99
var DOGE = function () {
10-
this.commands = ['doge', 'btc', 'dc'];
10+
this.commands = ['doge', 'btc', 'dc', 'bc'];
1111
this.usage = {
1212
doge: 'ex : !doge . Gets market prices for DOGE',
1313
btc: 'ex : !btc . Gets market prices for BTC',
14-
dc: 'ex : !dc <amount>. Convert DOGE to USD, default 1000'
14+
dc: 'ex : !dc <amount>. Convert DOGE to USD, default 1000',
15+
bc: 'ex : !bc <amount>. Convert BTC to USD, default 1'
1516
};
1617
};
1718

@@ -145,4 +146,25 @@ DOGE.prototype.dc = function (bot, to, from, msg, callback)
145146
});
146147
};
147148

149+
DOGE.prototype.bc = function (bot, to, from, msg, callback)
150+
{
151+
var msgOut = '',
152+
amount = 1,
153+
raw = msg.replace(',', '');
154+
155+
if ((raw !== '') && !isNaN(raw)) {
156+
amount = parseFloat(raw);
157+
}
158+
159+
eachProvider(['Coinbase'], function(err, results) {
160+
if (isNaN(results[0].value)) {
161+
msgOut = 'Cannot do conversion at this moment.';
162+
} else {
163+
msgOut = 'BTC' + amount + ' is $' + (amount * results[0].value).toFixed(2);
164+
}
165+
bot.say(to, msgOut);
166+
callback();
167+
});
168+
};
169+
148170
exports.Plugin = DOGE;

0 commit comments

Comments
 (0)