lundi 30 avril 2018

Google Scripts to Telegram - if statement issues when comparing strings

function sendText(id,text) {
  if(text == "hiii"){
    var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + "sup?";
  } else{ 
    var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + "yo yo yo";
    var response = UrlFetchApp.fetch(url);
    Logger.log(response.getContentText());
  }
}

My issue is that in Google Scripts (back end to Google Sheets), I have this function that reads in a message from telegram and, if the message reads "hiii" it should respond "sup?". Currently my code does not do this and instead executes only the else statement.

Aucun commentaire:

Enregistrer un commentaire