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 get messages that is not command #45

Closed
derakoola opened this issue Oct 7, 2015 · 4 comments
Closed

how to get messages that is not command #45

derakoola opened this issue Oct 7, 2015 · 4 comments

Comments

@derakoola
Copy link

How to get messages that is not command in command mode?!
@irazasyed

@irazasyed
Copy link
Owner

You mean to say, You want to handle normal messages that don't start with a slash?

Like a simple text message hello world?

You can normally do that and don't need to create a command class.

@derakoola
Copy link
Author

@irazasyed
Yes, that is my issue.

I have a route like this:

Route::post('/<token>/webhook', function () {
    Telegram::commandsHandler(true);

    return 'ok';
});

Now I want to get user feedback directly, I don't want to add another route and...

Is it possible?

@irazasyed
Copy link
Owner

Yes, That's possible!

The command handler function returns update object, So if it's not a command and simply a message. It'll return the update object which you can then use it and process accordingly.

Example:

Route::post('/<token>/webhook', function () {
    $update = Telegram::commandsHandler(true);

    $message = $update->getMessage();
    $chatId = $message->getChat()->getId();
    Telegram::sendMessage($chatId, 'Hello World');

    return 'ok';
});

@derakoola
Copy link
Author

Good.

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