Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const token = "Токен вашего бота";
- function timer() {
- let ss = SpreadsheetApp.getActiveSpreadsheet();
- let ws = ss.getSheetByName("Клиенты");
- let data = ws.getRange(2, 2, ws.getLastRow()-1, 6).getValues();
- let curentTime = new Date().getDate() + "." + (new Date().getMonth() + 1) + "." + new Date().getFullYear();
- for (i = 0; i < data.length; i++) {
- let dataInfo = data[i];
- let clientName = dataInfo[1];
- let clientBirthday = dataInfo[4].toString();
- let clientIdChat = dataInfo[5];
- if (dataInfo[4] !== ""){
- clientBirthday = dataInfo[4].getDate() + "." + (dataInfo[4].getMonth() + 1) + "." + dataInfo[4].getFullYear();
- console.log(clientIdChat)
- }
- if (clientBirthday === curentTime){
- if (clientIdChat !== ""){
- sendText(clientIdChat, "Уважаемый, " + clientName + ". Поздравляем вас с Днем Рождения!!!🎂");
- }
- }
- }
- //console.log(curentTime)
- }
- function sendText(chatId, text, keyBoard) {
- let data = {
- method: 'post',
- payload: {
- method: 'sendMessage',
- chat_id: String(chatId),
- text: text,
- parse_mode: 'HTML',
- reply_markup: JSON.stringify(keyBoard)
- }
- }
- UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/', data);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement