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

how to trace user position #14

Closed
moeinrahimi opened this issue May 28, 2016 · 6 comments
Closed

how to trace user position #14

moeinrahimi opened this issue May 28, 2016 · 6 comments

Comments

@moeinrahimi
Copy link

hi
i want to know how can i trace user position in the chat via my bot.
my bot have several keyboard i want to add a back button for each keyboard .
but i don't know how to do that

@Eleirbag89
Copy link
Owner

You need someway ti store the state of a chat, like a database.
Everytime you send a new keyboard, you write it down on the db and when you receive a "back button press" check on the db what the current keyboard is and send the previous one (updating the db accordingly).

@moeinrahimi
Copy link
Author

ok thank you for your guidance , just something else : i don't know what part
of the data need to use in database

On May 28 2016, at 11:52 am, Gabriele Grillo <notifications@github.com>
wrote:

You need someway ti store the state of a chat, like a database.
Everytime you send a new keyboard, you write it down on the db and when you
receive a "back button press" check on the db what the current keyboard is and
send the previous one (updating the db accordingly).


You are receiving this because you authored the thread.
Reply to this email directly, [view it on GitHub](https://github.com/Eleirbag8
9/TelegramBotPHP/issues/14#issuecomment-222294832), or [mute the
thread](https://github.com/notifications/unsubscribe
/ANFGUJhL2yc_xVcPBAnE5582dORjXM2Fks5qF-
06gaJpZM4IpAen).![](https://github.com/notifications/beacon/ANFGUOhdmjU-
Eo2C1GCIx2bamBvwBgh2ks5qF-06gaJpZM4IpAen.gif)

@Eleirbag89
Copy link
Owner

Eleirbag89 commented May 28, 2016

Well, there are many ways.
Let's say you have 2 different keyboards, one shows the options A and B and the other one Back and C.
We call the first keyboard ONE and the second TWO.
So when you send the keyboard ONE you write 1 on the database. You send other stuff to the user and finally send the keyboard TWO. Now you write TWO on the database. When the user click Back, check the db, you'll find TWO and you know that the keyboard to show from TWO is ONE.
Pseudo:

if (user_choosed_button() == "Back") {
      $prev_key = take_previuos_keyboard_from_db();
      if ($prev_key == "TWO") {
               sendKeyboardONE();
      }
      if ($prev_key == "THREE") {
               sendKeyboardTWO();
      }
}

It's simple but a little messy if you have a lot of different keyboards to show, but it's a starting point.

@Amir199
Copy link

Amir199 commented Jun 17, 2016

can you write a source code ? :(
i need it ...

@Eleirbag89
Copy link
Owner

It's not a function of the Telegram's Bot API, so I'll not write a source code :-)

@dade80vr
Copy link

dade80vr commented Jun 19, 2016

Hi @Eleirbag89 .
What do you mean with when you receive a "back button press" ??
Thanks

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

4 participants