File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed
Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 11/*
22activation_example:!bitcoinprice
3- regex:!bitcoinprice
3+ regex:!bitcoinprice\b
44flags:gmi
55*/
66
77var input = current . text . trim ( ) ;
8- if ( / ! b i t c o i n p r i c e / i. test ( input ) ) {
9- var quote = new sn_ws . RESTMessageV2 ( ) ;
10- quote . setEndpoint ( 'https://api.coindesk.com/v1/bpi/currentprice.json' ) ;
11- quote . setHttpMethod ( 'GET' ) ;
8+ var quote = new sn_ws . RESTMessageV2 ( ) ;
9+ quote . setEndpoint ( 'https://api.coindesk.com/v1/bpi/currentprice.json' ) ;
10+ quote . setHttpMethod ( 'GET' ) ;
1211
13- var chatResponse = quote . execute ( ) ;
14- var chatResponseBody = JSON . parse ( chatResponse . getBody ( ) ) ;
12+ var chatResponse = quote . execute ( ) ;
13+ var chatResponseBody = JSON . parse ( chatResponse . getBody ( ) ) ;
1514
16- if ( chatResponseBody && chatResponseBody . length > 0 ) {
17- var bitcoinpriceFormatted = chatResponseBody . bpi . USD . rate ;
18- new x_snc_slackerbot . Slacker ( ) . send_chat ( current , 'The current price of one bitcoin is: ' + bitcoinpriceFormatted + '$' , false ) ;
19- }
15+ if ( chatResponseBody && chatResponseBody . bpi && chatResponseBody . bpi . USD && chatResponseBody . bpi . USD . rate ) {
16+ var bitcoinpriceFormatted = chatResponseBody . bpi . USD . rate ;
17+ new x_snc_slackerbot . Slacker ( ) . send_chat ( current , 'The current price of one bitcoin is: ' + bitcoinpriceFormatted + '$' , false ) ;
2018}
You can’t perform that action at this time.
0 commit comments