irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
2.98k stars 660 forks source link

Bot not waiting for an update and it checks hook continually! #367

Closed behnamazimi closed 7 years ago

behnamazimi commented 7 years ago

I used SDK Laravel Starter and set the hook for my bot. I just wanna get an update and send a 'Hi' message to user. but in action bot send me the 'Hi' message continuously and not waiting for an update!

That's my webhookHandler() method's content:

$update = $this->telegram->getWebhookUpdate();

$message = $update->getMessage();

$this->telegram->sendMessage()
                ->chatId($message->chat->id)
                ->text('Hi')
                ->getResult();

Is it normal?!

irazasyed commented 7 years ago

Are you returning something in your method?

Like Ok? Because Telegram servers should get a confirmation from you about acceptance of the update. The only way to do that is by returning something (Status 200).

irazasyed commented 7 years ago

Also, Keep in mind. Any incoming update will then send "Hi". So /start or any command / normal text / photo, etc. as per your code.

behnamazimi commented 7 years ago

@irazasyed I just put return 'Ok'; at the end of my webhookHandler() method.

Be honest, I have many problems with V3 and I ashamed to make new issue for each. Especially in handle callback_query. for example when I attach an inline button I do not get any update! I'm so desperate and I really really rummaged all of issues and forums and communities, But...! 😢

irazasyed commented 7 years ago

@behnamazimi Your send message code is design to respond to every incoming update. That's one problem. Besides, there could be network issues because of which Telegram couldn't reach your server, and it retries until it gets confirmation or fails fully.

As far as V3 is concerned, it's not released nor tagged as Stable for a reason as we haven't finished it or tested heavily to consider it as stable.

If you're looking for a stable version, then you're better of with v2.x.

That said, there is no issue in creating multiple issue tickets as the more issue tickets you create, the better it is for us to debug and resolve, in a way you're contributing to the project as well. But obviously, please make sure your network connection, setup and other basic things are properly setup and tested before creating the issue.

behnamazimi commented 7 years ago

@irazasyed I know that response to every update by one message is not correct but that was just a test to explain my method structure.

About using v2, there is no possibility to use inline button and handle the callback_query on it while I need inline buttons and I must use v3 I think.

You could be sure that creating an issue is last thing that I do, before that I check all ways that I know and anybody says! However, Thank you and Thanks everyone who spending time on this awesome SDK. Bests.

irazasyed commented 7 years ago

@behnamazimi Yep!

You're very welcome :)

Perhaps, post your project's link using laravel-starter repo? Maybe then I'll be able to debug that easily and get back to you with a solution. Right now I can only test with limited access to your code and with mine, it works fine. So it's a problem that'll never get resolved until we test your version of the code.

behnamazimi commented 7 years ago

@irazasyed I solved that by putting return 'Ok'; in my method (as I did before 🤔). Now my main issue is this one. I close this as solved by adding correct return on webhookHandler body.