Created
April 19, 2018 22:52
-
-
Save luchaninov/d0795cd223ffae3cb7474fdadb2a2fce to your computer and use it in GitHub Desktop.
TelegramBot: Bitcoin price from Google Sheets
This file contains hidden or 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 spamTelegram() { | |
var telegramToken = 'bot111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA-v4'; // change to your token | |
var telegramChat = '-1111111111111'; // change to your chat id or to public "@channelname" | |
var url,response,data,msg; | |
url = 'https://api.coindesk.com/v1/bpi/currentprice/usd.json?showex=1&calc=1'; | |
response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true}); | |
data = JSON.parse(response.getContentText()); | |
msg = 'BTC = $' + data.bpi.USD.rate.replace(/\.\d+/, ''); | |
url = 'https://api.telegram.org/' + | |
telegramToken + '/sendMessage?chat_id=' + telegramChat + '&text=' + encodeURIComponent(msg); | |
response = UrlFetchApp.fetch(url, {'muteHttpExceptions': true}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment