Created
January 11, 2021 23:38
-
-
Save m0pfin/5df851a7e528a1cf32fbf44c5ebfdbcf to your computer and use it in GitHub Desktop.
Уведомление в телеграм от Google ADS
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 main(){ | |
var currentAccount = AdsApp.currentAccount(); | |
var todayCost = AdsApp.currentAccount().getStatsFor("TODAY").getCost(); // Затраты сегодня | |
var todayClicks = currentAccount.getStatsFor("TODAY").getClicks(); // Клики сегодня | |
var tagAccounts = 'Samara53'; // Тэг аккаунта для личной статистики | |
sendTelegramMessage( | |
'\nАккаунт ID: ' + currentAccount.getCustomerId() + | |
'\nКликов сегодня: ' + todayClicks + | |
'\nПотрачено сегодня: ' + todayCost + ' ' + currentAccount.getCurrencyCode() + | |
'\n#' + tagAccounts); | |
} | |
function sendTelegramMessage(text) { | |
var CONFIG2 = { | |
TOKEN: 'YOUR_TOKEN', | |
CHAT_ID: 'CHAT_ID' | |
}; | |
var telegramUrl = 'https://api.telegram.org/bot' + CONFIG2.TOKEN + '/sendMessage?chat_id=' + CONFIG2.CHAT_ID + '&text='; | |
var message = encodeURIComponent(text); | |
var sendMessageUrl = telegramUrl + message; | |
var options = { | |
method: 'POST', | |
contentType: 'application/json' | |
}; | |
UrlFetchApp.fetch(sendMessageUrl, options); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment