Closed hamidqp closed 3 years ago
when want to forward a message to many chats and then save the message-id of the sent message
For this particular case there's no need to use synchronous requests, just do:
$chatIds = [869444431235, 869444431235, ....]; // 50 chats
foreach ($chatIds as $chatId) {
$ctx->sendMessage('text', ['chat_id' => $chatId])
->then(function (Message $msg) {
$msgId = $msg->getMessageId();
});
}
Anyway, I can imagine in some case is useful to perform operations sequentially. You might use reactphp-block to perform synchronous requests.
Thanks a lot, reactphp-block completely solved that.
Hi, Thanks for the full Asynchronous PHP Telegram Bot Framework it makes telegram bots so fast.
but actually, sometimes I really need several methods that work Continuous and cant use ->then for all of them.
example when want to forward a message to many chats and then save the message-id of the sent message. or when want to send 50 messages to count 1 - 50, and many other things like that.