@@ -7,11 +7,12 @@ var async = require('async');
7
7
*/
8
8
9
9
var DOGE = function ( ) {
10
- this . commands = [ 'doge' , 'btc' , 'dc' ] ;
10
+ this . commands = [ 'doge' , 'btc' , 'dc' , 'bc' ] ;
11
11
this . usage = {
12
12
doge : 'ex : !doge . Gets market prices for DOGE' ,
13
13
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'
15
16
} ;
16
17
} ;
17
18
@@ -145,4 +146,25 @@ DOGE.prototype.dc = function (bot, to, from, msg, callback)
145
146
} ) ;
146
147
} ;
147
148
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
+
148
170
exports . Plugin = DOGE ;
0 commit comments