Closed ilshatlatyp closed 4 years ago
Same here.
i solved it by using Telegram::sendMessage([ 'chat_id' => 'chat_id', 'text' => $message ]);
inside laravel job https://laravel.com/docs/7.x/queues. I didnt found any other solution
You solved the problem by not using it ?
@foremtehan @Ilhatl I have tested it, and it works just fine. Test it with this code block:
class WebHookController extends Controller
{
public function hook()
{
/** @var Update $update */
$update = Telegram::commandsHandler(true);
if ($update->getChat()->get('id')) {
/** @var Update $response */
Telegram::setAsyncRequest(true)->sendMessage([
'text' => 'Test Async Message Response',
'chat_id' => $update->getChat()->get('id'),
]);
}
}
}
@ilshatlatyp as You are using chat_id
as not the ID of the chat, but a string value.
Hope, this helps.
Its not working in laravel Listener.
@foremtehan Please, share the code You are using.
Put your codes inside the laravel Job or Listener (ShouldQueued)) and you will see its not working, I'm sure its not about my codes because when i remove the setAsyncRequest(true)
it working whenever it inside a Job or anywhere else.
@foremtehan It's not a problem with this package.
If You would like to have it worked out for You, make Your HttpClientHandler
and do the same with implementing methods from the HttpClientInterface
.
This is the problem with Guzzle and how it works with the async requests from the Queue/Job.
Bot the author claims "Supports Laravel out of the box."Queue and Listener" is the part of laravel.
@foremtehan As I have written before, this is not the problem with this package (telegram-bot-sdk). It's all about how Guzzle works. Yes - this package supports Laravel, but Guzzle. If You are not satisfied with the standard HTTP handler then only an option - is to write own.
Async and queues are different.
Hi, I had the same problem. In my case the problem was in Guzzle and it is not solved https://github.com/guzzle/guzzle/issues/2752 (__destruct()
was called before execute()
in CurlMultiHandler
)
So in addition to resolving promises via Telegram\Bot\HttpClients\GuzzleHttpClient::__destruct
, I added resolution via register_shutdown_function
:
register_shutdown_function([$your_bot->getClient()->getHttpClientHandler(), '__destruct']);
I try to use with Laravel:
and got no error, but message is not sends But the code is working without setAsyncRequest(true)