Telegram-bot-sdk: Get user id (chat id) in command class

Created on 13 Sep 2017  路  1Comment  路  Source: irazasyed/telegram-bot-sdk

Hi,
how can I access to the user id within a command class?
Suppose I need to make a query to my database in the _HelpCommand.php_ class using the user id. How can I achieve this? I've already tried using _$GLOBALS [user_id]_ (which I set in index.php) but it's not working:

PHP Notice: Undefined index: user_id
That's very strange. What am I missing?

Most helpful comment

Hi,

Just use $this->getUpdate(); to retrieve the original update object and you can then fetch the user id or any other data.

>All comments

Hi,

Just use $this->getUpdate(); to retrieve the original update object and you can then fetch the user id or any other data.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

behnamazimi picture behnamazimi  路  4Comments

Enelar picture Enelar  路  3Comments

corneyl picture corneyl  路  3Comments

khalilst picture khalilst  路  3Comments

nanangkoesharwanto picture nanangkoesharwanto  路  3Comments