Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
yulii committed Dec 16, 2019
1 parent a0d16af commit 6fa82c6
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 17 deletions.
16 changes: 7 additions & 9 deletions lib/alpha_vantage/query/fx_daily.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
HttpQueryString = require '../../http/query_string'

class AlphaVantageQueryFxDaily

constructor: (params) ->
Expand All @@ -12,13 +10,13 @@ class AlphaVantageQueryFxDaily

params: () ->
return {
apikey: @apikey
function: @function
from_symbol: @from_symbol
to_symbol: @to_symbol
outputsize: @outputsize
datatype: @datatype
}
apikey: @apikey
function: @function
from_symbol: @from_symbol
to_symbol: @to_symbol
outputsize: @outputsize
datatype: @datatype
}

_assert = ->
throw new Error('`apikey` is required argument') unless @apikey?
Expand Down
14 changes: 6 additions & 8 deletions lib/alpha_vantage/query/time_series_daily.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
HttpQueryString = require '../../http/query_string'

class AlphaVantageQueryTimeSeriesDaily

constructor: (params) ->
Expand All @@ -12,12 +10,12 @@ class AlphaVantageQueryTimeSeriesDaily

params: () ->
return {
apikey: @apikey
function: @function
symbol: @symbol
outputsize: @outputsize
datatype: @datatype
}
apikey: @apikey
function: @function
symbol: @symbol
outputsize: @outputsize
datatype: @datatype
}

_assert = ->
throw new Error('`apikey` is required argument') unless @apikey?
Expand Down
12 changes: 12 additions & 0 deletions scripts/alpha_vantage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,15 @@ module.exports = (robot) ->
)
catch error
msg.send "#{error.name}: #{error.message}"

robot.respond /fx ([a-z0-9^]+\/[a-z0-9^]+)$/i, (msg) ->
try
new AlphaVantage(
function: 'FX_DAILY',
symbol: msg.match[1]
).execute(robot, (message) ->
robot.logger.debug(message.toString())
msg.send(message.format())
)
catch error
msg.send "#{error.name}: #{error.message}"
10 changes: 10 additions & 0 deletions scripts/webhook.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ module.exports = (robot) ->
catch error
robot.send { room: '#devops' }, "#{error.name}: #{error.message}"

['USD/JPY'].forEach (name) ->
try
new AlphaVantage(
function: 'FX_DAILY', symbol: name
).execute(robot, (message) ->
robot.send { room: '#random' }, message.format()
)
catch error
robot.send { room: '#devops' }, "#{error.name}: #{error.message}"

when /wake up!/i.test(req.body.text)
robot.send { room: '#general' }, "I'm readly for @#{req.body.user_name}"

Expand Down

0 comments on commit 6fa82c6

Please sign in to comment.