Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need Help #2

Open
mbino94 opened this issue Apr 30, 2022 · 4 comments
Open

Need Help #2

mbino94 opened this issue Apr 30, 2022 · 4 comments

Comments

@mbino94
Copy link

mbino94 commented Apr 30, 2022

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
Copy link
Owner

Ypurek commented May 1, 2022

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

@mbino94
Copy link
Author

mbino94 commented May 6, 2022

.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
Copy link
Owner

Ypurek commented May 6, 2022

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

@mbino94
Copy link
Author

mbino94 commented May 6, 2022

yea, ive fixed that and catched the error after that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants