Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

288
Vistas
Can't get /scam to make my telegram bot respond in google apps script

I'm trying to make a bot using google apps script for my telegram group to record scam contracts to google sheets. I can't get the /scam 0xtest00000000 to make the bot respond, or record it to my google sheets. I can do it with /^@/ and it works fine, but I want to use common style tg bot commands. I've tried putting in text = "", I've tried slicing, I've tried all sorts of things. Any help would be appreciated.

    function getMe() {
    var response = UrlFetchApp.fetch(url + "/getMe");
    Logger.log(response.getContentText());
}


function setWebhook() {
  var response = UrlFetchApp.fetch(url + "/setWebhook?url=" + 
  webAppUrl);
  Logger.log(response.getContentText());

}

function sendText(chat_id, text) {
  let data = {
    method: "post",
    payload: {
      method: "sendMessage",
      chat_id: String(chat_id),
      text: text,
      parse_mode: "HTML"
    }    
  };
  UrlFetchApp.fetch(url + "/sendMessage?chat_id=" + chat_id + "$texts" 
 + encodeURIComponent(text));
}

function doGet(e) {
  return HtmlService.createHtmlOutput ("Hello" + JSON.stringify(e));
}


function doPost(e) {
  try {
  let contents = JSON.parse(e.postData.contents);
  GmailApp.sendEmail(Session.getEffectiveUser().getEmail(), "Telegram 
  Bot Update",JSON.stringify(contents,null,4));
  let text = contents.message.text;
  let chat_id = contents.message.chat.id;
  let name = contents.message.from.first_name + " " + 
  contents.message.from.last_name;
  let user_id = contents.message.from.id;
  let username = contents.message.from.username;
  let contract = text.slice(1).split(" ")[0];
 // let item = text.split(" ");
  let scam = "/scam";
  // let com1 = scam.split(' ')[0];

  if(text == scam)) {
  
  SpreadsheetApp.openById(ssid).appendRow([new 
Date(),user_id,username,name,contract]);
  sendText(chat_id, "Contract address " + contract + " has been added 
 to the list." );
  }

} catch(e) {
  sendText(lbsId,"Error" + JSON.stringify(e,null,4));
}
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda