Eleirbag89 / TelegramBotPHP

A very simple PHP Telegram Bot API for sending messages.
http://eleirbag89.github.io/TelegramBotPHP
MIT License
814 stars 343 forks source link

how can i get first message text during the chat? #120

Closed ghost closed 6 years ago

ghost commented 6 years ago

Hello, at first thanks for this library ...

i want to get first message text during conversation while when i use Webhook it send me last message array, in addition last message i want to get first message.

in fact i want to detect every username as https://telegram.me/myBot?start=username during conversation between all of users and response them according their username

Thanks

Eleirbag89 commented 6 years ago

It's not clear what you want to achieve. Using the webhook you receive a call for each message every user send. The username is in the message object. If you need some complex interation, you have to save the conversation state somewhere (db, file etc.)

ghost commented 6 years ago

how can i access to first $telegram->Text() always (every time) from strat conversation untill end of conversation ?

That is it.

Eleirbag89 commented 6 years ago

You can't. You need to save on a database the first message a user sends by yourself and implement the conversation logic.

ghost commented 6 years ago

yes I knew that way, but i like to fetch first $telegram->Text() without using database, because of database will be busy during chat, I wanted to use query string with start chat till end of chatting if possible.

of course I must tell you that I used Session for saving username when the chat start first with this url: https://telegram.me/myBot?start=username but I couldn`t keep it after second message up to the end.

Eleirbag89 commented 6 years ago

I don't think it's possible, the query parameter exist only in the first message

ghost commented 6 years ago

Thanks dear Gabriele if I can solve it, i will share it.