Last active
December 18, 2017 19:55
-
-
Save robertocommit/31a8dddcc02b2ab98b318ab58d18e9d2 to your computer and use it in GitHub Desktop.
Get USDT-BTC on Slack using Google Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function main() { | |
// Insert here your WebHook URL obtained from Slack and the name of the channel | |
var slack_webhook_url = 'https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXXX/XXXXXXXXXXXXXXX'; | |
var slack_channel_name = 'XXXXXXX'; | |
var bittrex_url = 'https://bittrex.com/api/v1.1/public/getticker?market=USDT-BTC'; | |
var url_response = UrlFetchApp.fetch(bittrex_url).getContentText(); | |
var response_parsed = JSON.parse(url_response); | |
var last_usdt_btc = parseInt(response_parsed.result.Last); | |
send('*USDT-BTC* --> ' + last_usdt_btc, slack_channel_name); | |
} | |
function send(message, slack_channel) { | |
var payload = { | |
"channel" : slack_channel, | |
"username" : "robot", | |
"text" : message, | |
"icon_emoji": ":robot_face:" | |
} | |
var options = { | |
"method" : "post", | |
"contentType" : "application/json", | |
"payload" : JSON.stringify(payload) | |
}; | |
// Insert here your WebHook URL obtained from Slack | |
return UrlFetchApp.fetch(slack_webhook_url, options) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment