Sending chat action automatically by calling any send... command. for example the following command send typing... chat action:
$result = Request::sendMessage([
'chat_id' => $chat_id,
'sendChatAction' => true,
'text' => 'test',
]);
@smoqadam I like this idea!
We'd have to establish a safe way of passing the value though, as the $data array is what gets sent to the Telegram API. So we'd either have to make sure that it is a key that will never be used by Telegram, or (and maybe better), have an extra parameter for $extras like this.
@php-telegram-bot/developers
What do you guys think about this?
Do you use the chat actions often enough to make this a necessary / 'makes sense' addition?
As API says it should only be used if bot is about to do something that is gonna take some time, it should definitely not be default behaviour.
@jacklul It isn't done by default! (look here)
That's why it would be passed as an extra parameter :+1:
@jacklul @noplanman
you mean like this?
Request::sendMessage([
'chat_id' => $chat->getId(),
'text' => 'test'
], ['sendChatAction'=>true]);
Sorry guys, but I see no reason to add it at all.
Request::sendChatAction() should be sent before some long operation, not before sending the message, since message received right after chat action will remove that action...
I mean that workflow is:
@chuv1 I like things that make it easier for the user, but I agree with you that it's a question of adding a single line to send the chat action separately.
I do see the advantage of the parameter though, to easily define a long operation with a boolean and have the chat action be managed automatically, without any extra if or anything.
@smoqadam Yes, something like that was in my head. Haven't checked to see if that makes complete sense, but it should do the trick i think.
Before coding more, let's first establish that it's something that would be merged in the first place :blush:
(Also, in future, first open an issue to discuss it, before coding, just to make sure there is no "wasted" coding effort. Nobody likes that :wink: )
Actually, @chuv1 is right.
Makes no sense to send chat action right before sending the result.
Aah... Of course... I read his comment wrongly.
Of course it should be sent as the request comes in, not out.
So all ok to close this then?
@smoqadam Thanks a lot for the idea though! Keep them coming :+1:
@noplanman no problem.
I'm glad I to be helpful if I can
Most helpful comment
Sorry guys, but I see no reason to add it at all.
Request::sendChatAction() should be sent before some long operation, not before sending the message, since message received right after chat action will remove that action...
I mean that workflow is: