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

telegram bot url with parameters #406

Open
milad145 opened this Issue Aug 16, 2017 · 8 comments

Comments

Projects
None yet
3 participants
@milad145

milad145 commented Aug 16, 2017

i saw a bot with this link

http://telegram.me/example_bot?id=456856

so i want to create link like this

http://telegram.me/myExample_bot?command=sendMessage

and i want when a user click on this link bot get the command and send him message
is it possible?

@GingerPlusPlus

This comment has been minimized.

Show comment
Hide comment
@GingerPlusPlus

GingerPlusPlus Aug 16, 2017

Contributor

@milad145 yes, it is possible. It's called deep linking, read about it in docs.

Contributor

GingerPlusPlus commented Aug 16, 2017

@milad145 yes, it is possible. It's called deep linking, read about it in docs.

@milad145

This comment has been minimized.

Show comment
Hide comment
@milad145

milad145 Aug 16, 2017

@GingerPlusPlus
thank you,
but
this is my code

bot.onText(/\/getCommand (\w+)/, function(msg, match) {
   callFuction(msg.chat.id , match[1]);
});

var callFunction = function(chatid,text){
   bot.sendMessage(chatid,text)
}

and my link is

http://telegram.me/myExample_bot?getCommand=123456

i want when a user click on bot link then callFunction run automaticly
how can i do that?

milad145 commented Aug 16, 2017

@GingerPlusPlus
thank you,
but
this is my code

bot.onText(/\/getCommand (\w+)/, function(msg, match) {
   callFuction(msg.chat.id , match[1]);
});

var callFunction = function(chatid,text){
   bot.sendMessage(chatid,text)
}

and my link is

http://telegram.me/myExample_bot?getCommand=123456

i want when a user click on bot link then callFunction run automaticly
how can i do that?

@GingerPlusPlus

This comment has been minimized.

Show comment
Hide comment
@GingerPlusPlus

GingerPlusPlus Aug 16, 2017

Contributor

@milad145 read about deep linking again.
I'd use a link like http://telegram.me/myExample_bot?start=getCommand-123456
and a regex like /start getCommand-(\d+)
or add a general route like (untested):

bot.onText(/^\/start ([\w-]+)$/, (msg, [, command]) =>
  const message = Object.create(msg)
  message.text =  '/' + command.replace(/\-/g, ' ')
  bot.processUpdate({ message })
)
Contributor

GingerPlusPlus commented Aug 16, 2017

@milad145 read about deep linking again.
I'd use a link like http://telegram.me/myExample_bot?start=getCommand-123456
and a regex like /start getCommand-(\d+)
or add a general route like (untested):

bot.onText(/^\/start ([\w-]+)$/, (msg, [, command]) =>
  const message = Object.create(msg)
  message.text =  '/' + command.replace(/\-/g, ' ')
  bot.processUpdate({ message })
)
@milad145

This comment has been minimized.

Show comment
Hide comment
@milad145

milad145 Aug 16, 2017

@GingerPlusPlus
thanks,
i do that, in this case if user click on link ,the start button do correctly
but if user clear bot cash and then press on start button the start button doesn't work

milad145 commented Aug 16, 2017

@GingerPlusPlus
thanks,
i do that, in this case if user click on link ,the start button do correctly
but if user clear bot cash and then press on start button the start button doesn't work

@GingerPlusPlus

This comment has been minimized.

Show comment
Hide comment
@GingerPlusPlus

GingerPlusPlus Aug 16, 2017

Contributor

@milad145

if user clear bot cash

What's "bot cash"?

What do you mean by "doesn't work"?

Contributor

GingerPlusPlus commented Aug 16, 2017

@milad145

if user clear bot cash

What's "bot cash"?

What do you mean by "doesn't work"?

@milad145

This comment has been minimized.

Show comment
Hide comment
@milad145

milad145 Aug 16, 2017

bot.onText(/\/start (\w+)/, function (msg, match) {
	console.log(msg)
	console.log(match)
})

if you click on link and then press start you can see the console.log
but if you press on start without clicking on link you can't see console.log

milad145 commented Aug 16, 2017

bot.onText(/\/start (\w+)/, function (msg, match) {
	console.log(msg)
	console.log(match)
})

if you click on link and then press start you can see the console.log
but if you press on start without clicking on link you can't see console.log

@GingerPlusPlus

This comment has been minimized.

Show comment
Hide comment
@GingerPlusPlus

GingerPlusPlus Aug 16, 2017

Contributor

That's the expected behavior.

The handler is called only when bot it started from a link.

Contributor

GingerPlusPlus commented Aug 16, 2017

That's the expected behavior.

The handler is called only when bot it started from a link.

@milad145

This comment has been minimized.

Show comment
Hide comment
@milad145

milad145 Aug 16, 2017

but what happend if some one start bot without clicking on link
or what happend if some one clear bot history and then press start button again?

milad145 commented Aug 16, 2017

but what happend if some one start bot without clicking on link
or what happend if some one clear bot history and then press start button again?

@GochoMugo GochoMugo added the question label Nov 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment