Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

283
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!