Closed Sogl closed 7 years ago
Does this happen every time a new user registers? Or just sometimes? Also, enable and check your update log, to see if the exact same request comes through twice from Telegram, or if it's the library itself calling it twice.
Also, I'd recommend to refactor your command a bit to make it easier to understand, which also helps to find bugs (if any) 😊
Does this happen every time a new user registers? Or just sometimes?
Every time when user registers
Also, enable and check your update log, to see if the exact same request comes through twice from Telegram, or if it's the library itself calling it twice.
Do you mean debug log enabling?
Do you mean debug log enabling?
No, I mean the update log, which saves all the incoming requests from Telegram:
TelegramLog::initUpdateLog(__DIR__ . '/update.log');
Each message sent to your bot should be logged in that file, so that you know exactly what is coming from Telegram.
Solved. Actually it was two requests from Telegram because first request failed (logging user actions in my ERP didn't work if the user isn't logged in). I don't know why Telegram sends request again after fail.
Also, I'd recommend to refactor your command a bit to make it easier to understand, which also helps to find bugs (if any)
What exactly do you mean by that? Use return
instead of nested if
conditions?
Actually it was two requests from Telegram because first request failed
I had a feeling this was the case.
Regarding the refactor, yes, less nesting and more returning 👍
It's just much easier to understand the flow of the code, instead of having to scroll all the way down to the various else
statements to see what's happening.
Hello!
I have token command for user registration:
All worked fine for a long time, but some time ago for every new user registration this message was sent:
I added some
TelegramLog::error
commands and what I saw in logs:As you can see, first time (16:31:35) system said that user isn't registered, but somehow this command worked second time after 3 seconds (16:31:38) and re-checked that user just registered! But user see error message and doesn't understand what he did wrong.
Why is this happening?
Env: PHP 5.6 Php-telegram-bot v. 0.33