//When the alert is sent by the Webhook, the data will go to the cell D1 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse1 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse1 = wbalxuse1.getSheetByName("Name sheet");
const cellalxuse1 = sheetalxuse1.getRange("D1");
function doPost(e) {
const actionalxuse1 = e.parameter.actionalxuse1;
if(actionalxuse1 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse1 = JSON.parse(e.postData.contents);
cellalxuse1.setValue([useralxuse1.alxuse]);
}
//{ "alxuse":"Message1" }
//?actionalxuse1=addUser
//When the alert is sent by the Webhook, the data will go to the cell D2 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse2 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse2 = wbalxuse2.getSheetByName("Name sheet");
const cellalxuse2 = sheetalxuse2.getRange("D2");
function doPost(e) {
const actionalxuse2 = e.parameter.actionalxuse2;
if(actionalxuse2 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse2 = JSON.parse(e.postData.contents);
cellalxuse2.setValue([useralxuse2.alxuse]);
}
//{ "alxuse":"Message2" }
//?actionalxuse2=addUser
//When the alert is sent by the Webhook, the data will go to the cell D3 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse3 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse3 = wbalxuse3.getSheetByName("Name sheet");
const cellalxuse3 = sheetalxuse3.getRange("D3");
function doPost(e) {
const actionalxuse3 = e.parameter.actionalxuse3;
if(actionalxuse3 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse3 = JSON.parse(e.postData.contents);
cellalxuse3.setValue([useralxuse3.alxuse]);
}
//?actionalxuse3=addUser
//{ "alxuse":"Message3" }
//When the alert is sent by the Webhook, the data will go to the cell D4 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse4 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse4 = wbalxuse4.getSheetByName("Name sheet");
const cellalxuse4 = sheetalxuse4.getRange("D4");
function doPost(e) {
const actionalxuse4 = e.parameter.actionalxuse4;
if(actionalxuse4 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse4 = JSON.parse(e.postData.contents);
cellalxuse4.setValue([useralxuse4.alxuse]);
}
//?actionalxuse4=addUser
//{ "alxuse":"Message4" }
//When the alert is sent by the Webhook, the data will go to the cell D5 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse5 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse5 = wbalxuse5.getSheetByName("Name sheet");
const cellalxuse5 = sheetalxuse5.getRange("D5");
function doPost(e) {
const actionalxuse5 = e.parameter.actionalxuse5;
if(actionalxuse5 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse5 = JSON.parse(e.postData.contents);
cellalxuse5.setValue([useralxuse5.alxuse]);
}
//?actionalxuse5=addUser
//{ "alxuse":"Message5" }
//When the alert is sent by the Webhook, the data will go to the cell D6 in Google sheet.
// For using the code we should change ID sheet and Name sheet.
const wbalxuse6 = SpreadsheetApp.openById("ID sheet")
const sheetalxuse6 = wbalxuse6.getSheetByName("Name sheet");
const cellalxuse6 = sheetalxuse6.getRange("D6");
function doPost(e) {
const actionalxuse6 = e.parameter.actionalxuse6;
if(actionalxuse6 == 'addUser') {
return addUser(e);
}
}
function addUser(e) {
const useralxuse6 = JSON.parse(e.postData.contents);
cellalxuse6.setValue([useralxuse6.alxuse]);
}
//?actionalxuse6=addUser
//{ "alxuse":"Message6" }
//When we receive email from cell C1 in Google sheet.
// For using the code we should change Name sheet and Email address.
// The value of C1 should be Buy.
function sendEmai1() {
const spemail1 = PropertiesService.getScriptProperties();
const ssemail1 = SpreadsheetApp.getActive();
const wsemail1 = ssemail1.getSheetByName("Name sheet");
const cellemail1 = wsemail1.getRange("C1");
const masemail1 = cellemail1.getValue();
const valueToCheckemail1 = wsemail1.getRange("C1").getValue();
const spoldValueemail1 = spemail1.getProperty("C1") || 0;
if (valueToCheckemail1 != spoldValueemail1) {
spemail1.setProperty("C1", valueToCheckemail1);
if (valueToCheckemail1 === "Buy" )
MailApp.sendEmail("Email address", masemail1, "BuySignal: " + valueToCheckemail1+ ".");
}
}
//To send the email, the value of C1 must be changed after each run of the script.
//When we receive email from cell E1 in Google sheet.
// For using the code we should change Name sheet and Email address.
// The value of E1 should be Sell.
function sendEmai2() {
const spemail2 = PropertiesService.getScriptProperties();
const ssemail2 = SpreadsheetApp.getActive();
const wsemail2 = ssemail2.getSheetByName("Name sheet");
const cellemail2 = wsemail2.getRange("E1");
const masemail2 = cellemail2.getValue();
const valueToCheckemail2 = wsemail2.getRange("E1").getValue();
const spoldValueemail2 = spemail2.getProperty("E1") || 0;
if (valueToCheckemail2 != spoldValueemail2) {
spemail2.setProperty("E1", valueToCheckemail2);
if (valueToCheckemail2 === "Sell" )
MailApp.sendEmail("Email address", masemail2, "BuySignal: " + valueToCheckemail2+ ".");
}
}
//To send the email, the value of E1 must be changed after each run of the script.
//When we receive Telegram messages from cell C1 in Google sheet.
// For using the code we should change Name sheet , Token Bot Telegram and Telegram channel name.
// The value of C1 should be Buy.
function postTotelegram1() {
const urltel1 = "https://api.telegram.org/botToken Bot Telegram/sendMessage?chat_id=@Telegram channel name&text="
const optionstel1 = {
'method' : 'post',
}
const sptel1 = PropertiesService.getScriptProperties();
const sstel1 = SpreadsheetApp.getActive();
const wstel1 = sstel1.getSheetByName("Name sheet");
const celltel1 = wstel1.getRange("C1");
const mastel1 = celltel1.getValue();
const valueToChecktel1 = wstel1.getRange("C1").getValue();
const oldValuetel1 = sptel1.getProperty("C1") || 0;
if (valueToChecktel1 != oldValuetel1) {
sptel1.setProperty("C1", valueToChecktel1);
if (valueToChecktel1 === "Buy" )
UrlFetchApp.fetch(urltel1 + (mastel1) ,optionstel1)
}
}
//To send the email, the value of C1 must be changed after each run of the script.
//When we receive Telegram messages from cell E1 in Google sheet.
// For using the code we should change Name sheet , Token Bot Telegram and Telegram channel name.
// The value of E1 should be Sell.
function postTotelegram2() {
const urltel2 = "https://api.telegram.org/botToken Bot Telegram/sendMessage?chat_id=@Telegram channel name&text="
const optionstel2 = {
'method' : 'post',
}
const sptel2 = PropertiesService.getScriptProperties();
const sstel2 = SpreadsheetApp.getActive();
const wstel2 = sstel2.getSheetByName("Name sheet");
const celltel2 = wstel2.getRange("E1");
const mastel2 = celltel2.getValue();
const valueToChecktel2 = wstel2.getRange("E1").getValue();
const oldValuetel2 = sptel2.getProperty("E1") || 0;
if (valueToChecktel2 != oldValuetel2) {
sptel2.setProperty("E1", valueToChecktel2);
if (valueToChecktel2 === "Sell" )
UrlFetchApp.fetch(urltel2 + (mastel2) ,optionstel2)
}
}
//To send the email, the value of E1 must be changed after each run of the script.
//When we receive Discord messages from cell C1 in Google sheet.
// For using the code we should change Name sheet and Discord channel webhook.
// The value of C1 should be Buy.
function postToDiscord1(currentMessagedis1) {
const urldis1 = "Discord channel webhook"
const messagedis1 = {
content: currentMessagedis1
}
const optionsdis1 = {
'method' : 'post',
'payload' : messagedis1
}
UrlFetchApp.fetch(urldis1,optionsdis1)
}
function posFormSpreadsheet1(){
const spdis1 = PropertiesService.getScriptProperties();
const ssdis1 = SpreadsheetApp.getActive();
const wsdis1 = ssdis1.getSheetByName("Name sheet");
const celldis1 = wsdis1.getRange("C1");
const masdis1 = celldis1.getValue();
const spvalueToCheckdis1 = wsdis1.getRange("C1").getValue();
const spoldValuedis1 = spdis1.getProperty("C1") || 0;
if (spvalueToCheckdis1 != spoldValuedis1) {
spdis1.setProperty("C1", spvalueToCheckdis1);
if (spvalueToCheckdis1 === "Buy" )
postToDiscord1(masdis1)
}
}
//To send the email, the value of C1 must be changed after each run of the script.
//When we receive Discord messages from cell E1 in Google sheet.
// For using the code we should change Name sheet and Discord channel webhook.
// The value of E1 should be Sell.
function postToDiscord2(currentMessagedis2) {
const urldis2 = "Discord channel webhook"
const messagedis2 = {
content: currentMessagedis2
}
const optionsdis2 = {
'method' : 'post',
'payload' : messagedis2
}
UrlFetchApp.fetch(urldis2,optionsdis2)
}
function posFormSpreadsheet2(){
const spdis2 = PropertiesService.getScriptProperties();
const ssdis2 = SpreadsheetApp.getActive();
const wsdis2 = ssdis2.getSheetByName("Name sheet");
const celldis2 = wsdis2.getRange("E1");
const masdis2 = celldis2.getValue();
const spvalueToCheckdis2 = wsdis2.getRange("E1").getValue();
const spoldValuedis2 = spdis2.getProperty("E1") || 0;
if (spvalueToCheckdis2 != spoldValuedis2) {
spdis2.setProperty("E1", spvalueToCheckdis2);
if (spvalueToCheckdis2 === "Sell" )
postToDiscord2(masdis2)
}
}
//To send the email, the value of E1 must be changed after each run of the script.
IF command with AND command
We should change the values according to the number of the Webhooks that are used to Google sheet. ( Value D1-Value D2-Value D3-Value D4-Value D5-Value D6)
=IF(AND(D1="Value D1",D2="Value D2"), "Buy", "")
=IF(AND(D1="Value D1",D2="Value D2"), "Sell", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3"), "Buy", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3"), "Sell", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3",D4="Value D4"), "Buy", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3",D4="Value D4"), "Sell", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3",D4="Value D4",D5="Value D5"), "Buy", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3",D4="Value D4",D5="Value D5"), "Sell", "")
=IF(AND(D1="Value D11",D2="Value D2",D3="Value D3",D4="Value D4",D5="Value D5",D6="Value D6"), "Buy", "")
=IF(AND(D1="Value D1",D2="Value D2",D3="Value D3",D4="Value D4",D5="Value D5",D6="Value D6"), "Sell", "")
IMPORTRANGE command
For using IMPORTRANGE command we should change Sheet address and Sheet name and Row or Cell.
Use the IMPORTRANGE command only once per sheet and on rows of sheets that do not have a value or formula.
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/abcd123abcd123", "sheet1!A1:A")
=IMPORTRANGE("https://docs.google.com/spreadsheets/d/abcd123abcd123", "sheet2!B1:B")
=IMPORTRANGE("Sheet address", "Sheet name and Row or Cell")