Estoy tratando de hacer un bot usando el script de aplicaciones de Google para mi grupo de Telegram para registrar contratos de estafa en las hojas de Google. No puedo obtener /scam 0xtest00000000 para hacer que el bot responda o registrarlo en mis hojas de Google. Puedo hacerlo con /^@/ y funciona bien, pero quiero usar comandos tg bot de estilo común. He intentado poner text = "", he intentado cortar, he intentado todo tipo de cosas. Cualquier ayuda sería apreciada.
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)); } }