Skip to content

Instantly share code, notes, and snippets.

@m0pfin
Created January 11, 2021 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save m0pfin/5df851a7e528a1cf32fbf44c5ebfdbcf to your computer and use it in GitHub Desktop.
Save m0pfin/5df851a7e528a1cf32fbf44c5ebfdbcf to your computer and use it in GitHub Desktop.
Уведомление в телеграм от Google ADS
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