Closed massadm closed 1 year ago
Call to get incoming updates using long polling looks like this:
$response = Request::getUpdates(..., $offset = $this->last_update_id + 1)
$this->last_update_id
populated from the database like this:
SELECT `id` FROM `telegram_update` ORDER BY `id` DESC LIMIT 1
The problem is that DB::insertRequest($this->update)
does not populate the database with information about unknown updates. At the next iteration, the database will not contain information about the processing of unimplemented update, so $this->last_update_id
will remain the same as in the previous iteration. And so it turns out to be an endless cycle.
You're absolutely right, thanks for reporting. This will be fixed in the next version, which will also have the Bot API 5.1 integrated.
It will also be more future-proof for when new update types get added by Telegram 👌
I suggest to ALTER TABLE telegram_update
by adding COLUMN unknown_update_id
BIGINT UNSIGNED NULL referred to unknown_telegram_update
TABLE by it's primary key. All unimplemented updates must be stored here in unknown_telegram_update
table in serialized form.
An additional overridable system command can be considered to handle such updates (as a workaround for manual handling of the latest Telegram Bot API innovations, without waiting for implementation inside the library).
@massadm Your suggestion sounds like a great idea! Would you like to make a PR for it? 😇
Maybe we could combine this with #1124?
I'll see what I can do.
🐞 Bug Report
Critical
Required Information
Summary
Due to Telegram Bot API updates, the TelegramBot instance may receive updates that have not yet been implemented by the library. With the current implementation of
getUpdates
, processing of such updates will be repeated indefinitely.How to reproduce
Get
my_chat_member
or any other currently unimplemented update from Telegram usinggetUpdates
.Expected behaviour
Need the way to process unknown updates.