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

Making requests when getting updates #28

Closed
9px opened this issue Sep 5, 2015 · 5 comments
Closed

Making requests when getting updates #28

9px opened this issue Sep 5, 2015 · 5 comments

Comments

@9px
Copy link

9px commented Sep 5, 2015

hi. telegram recently add an ability to perform a request to the telegram Bot API while sending an answer to the webhook.
can you do a simple implement of this feature in your bot?

@irazasyed
Copy link
Owner

Hi,

Can you tell me a real world use case for this?

Also, Are you aware that, you won't get any results when you make such a request?

You could simply use the sendMessage() or replyWithMessage() (If you're responding from a command). Let me know.

@9px
Copy link
Author

9px commented Sep 6, 2015

Can you tell me a real world use case for this?

yes. for example for reply a command that received from user.

when a user send a command to robot, server received it in 1 connection.
When we send an answer to the user (for example with sendMessage method), this is another connection.
This new telegram bot feature is great. because it save 1 connection :)
so server can process double request simultaneously.

@irazasyed
Copy link
Owner

Here's how that would work (If you're on Laravel):

Route::post('/webhook', function () {
    $update = Telegram::getWebhookUpdates();
    $chat_id = $update->getMessage()->getChat()->getId();

    Telegram::sendChatAction($chat_id, 'typing');

    $method = 'sendMessage';
    $text = 'This is a demo...!';

    return response()->json(compact('method', 'chat_id', 'text'));
});

I'll think of a way to implement this in the project itself. But in the mean time, You can use the above.

@jonnywilliamson
Copy link
Contributor

@9px - Hi! Could you tell why you think the send on reply is so useful? Apart from reducing a connection, it provides no information on wither your message was sent correctly etc.

That seems like a much bigger disadvantage than the benefit you get back!?

I'd love to know what you plan to use this for as I can't think of anything and I'm interested to make sure I'm not missing out!

@jonnywilliamson
Copy link
Contributor

@9px Any more info?

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

3 participants