Ypurek / Telegram-feedback-bot

Telegram feedback bot using webhook and Google apps script
25 stars 14 forks source link

Need Help #2

Open mbino94 opened 2 years ago

mbino94 commented 2 years ago

Hello sir. im facing an issue , hope you can help every time i Create a variable that contains a special character like ( _ or @ )my script stops working for example: var target = contents.massage.reply_to_message.from.id; if add this line to my script the script stops working

my full script is here ' function setWebhook() { var url = telegramUrl + "/setWebhook?url=" + webAppUrl; var response = UrlFetchApp.fetch(url); }

function sendMessage(id, text,) { var url = telegramUrl + "/sendMessage?chat_id=" + id + "&text=" + text; sponse = UrlFetchApp.fetch(url); }

function doPost(e) { var contents = JSON.parse(e.postData.contents); var id = contents.message.from.id; var text = contents.message.text; var target = contents.massage.reply_to_message.from.id;

if (text.includes("/who")) { sendMessage(id, "it is " + target+ " :) " );

Ypurek commented 2 years ago

hi there! as far as I see, your script missing }} in the end (if statement not closed and doPost function not closed)

mbino94 commented 2 years ago

.from.id;

the }} are in the script, bu i just forgot them in the comment,

ive tried to catch the error and got that .from.id is undefined which are in the line var target = contents.massage.reply_to_message.from.id;

but they are defined in the object as you see in the screenshot Screenshot 2022-05-06 174550

Ypurek commented 2 years ago

var target = contents.mAssage.reply_to_message.from.id; there is typo in contents.massage. should be message

mbino94 commented 2 years ago

yea, ive fixed that and catched the error after that