function sendMessage(from_chat_id, text, keyboard, id_msg) { // Отправляет сообщение используя sendMessage
var data = {
method: "sendMessage",
chat_id: String(from_chat_id),
text: text,
parse_mode: "HTML",
reply_markup: JSON.stringify(keyboard),
reply_to_message_id: String(id_msg)
};
var options = {
method: 'POST',
payload: data,
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch('https://api.telegram.org/bot' + token + '/sendMessage', options);
console.log(JSON.parse(response.getContentText(), null, 7))
}
let keyboard_contact = {
keyboard: [
[{
text: "Авторизоваться",
request_contact: true
}]
],
resize_keyboard: true,
one_time_keyboard: true
};
let keyboard_menu_inline = {
inline_keyboard: [
[{
text: "Услуги ",
callback_data: "services"
}, {
text: "Оплата ",
url: "https://google.com",
callback_data: "pay"
}],
[{
text: "Статус ✅ ",
url: "https://google.com"
}, {
text: "Обратная связь ",
callback_data: "support"
}]
]
};
sendMessage(from_chat_id, text, keyboard)
const getYear = (value) => {
const timeStmp = Date.parse(value);
return new Date(timeStmp).getUTCFullYear();
}
const monthDiff = (dateFrom) => {
const baseYear = new Date(dateFrom).getUTCFullYear();
const baseDate = new Date(baseYear, 11);
const bday = new Date(dateFrom);
return new Date(baseDate).getMonth() - bday.getMonth() +
(12 * (new Date(baseDate).getFullYear() - bday.getFullYear()));
}
const cowsFemale = cows
.filter(res => res.gender === 'Ұрғашы')
.reduce((accum, curVal) => {
const currentYearBorn = getYear(curVal.bdate);
const monthsAgo = monthDiff(curVal.bdate);
const younger = monthsAgo <= 20;
if (younger) {
if (!accum[currentYearBorn]) {
accum[currentYearBorn] = {
count: 1
}
} else {
accum[currentYearBorn] = {
count: accum[currentYearBorn].count + 1
}
}
}
return accum
}, {})
{
2019: {count: 11}
2020: {count: 9}
}
[
{
vid: 221,
age: 4,
bdate: "2020-05-27T15:00:00-04:00",
type: "Ұрғашы бұзау",
statusChangeTime: "2020-10-19T04:27:05.000Z",
},
{
vid: 225,
age: 6,
bdate: "2020-07-09T15:00:00-04:00",
type: "Ұрғашы бұзау",
statusChangeTime: "",
},
{
vid: -34,
age: 7,
bdate: "2020-02-21T14:00:00-05:00",
type: "Ұрғашы бұзау",
statusChangeTime: "2020-10-17T05:17:55.000Z",
},
{
vid: -30,
age: 4,
bdate: "2019-01-03T14:00:00-05:00",
type: "Еркек бұзау",
statusChangeTime: "2019-05-06T07:24:00.000Z",
},
]
.map((item) => +("" || item.bdate).split("-")[0])
.filter((y, i, a) => a.indexOf(y) === i);
> [2020, 2019]
if(result === repl)