| @@ 104-127 (lines=24) @@ | ||
| 101 | $this->initCommands(); |
|
| 102 | ||
| 103 | // Process all updates |
|
| 104 | while (true) { |
|
| 105 | $updates = $this->execRequest("getUpdates?offset=$offset&limit=$limit&timeout=$timeout"); |
|
| 106 | ||
| 107 | // Parse all update to receive |
|
| 108 | foreach ($updates as $key => $update) { |
|
| 109 | try { |
|
| 110 | // Process one at a time |
|
| 111 | $this->processUpdate($update); |
|
| 112 | } catch (BotException $e) { |
|
| 113 | echo $e->getMessage(); |
|
| 114 | } |
|
| 115 | } |
|
| 116 | ||
| 117 | // Update the offset |
|
| 118 | $offset += sizeof($updates); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | /** @} */ |
|
| 123 | ||
| 124 | /** |
|
| 125 | * \addtogroup Core Core(Internal) |
|
| 126 | * @{ |
|
| 127 | */ |
|
| 128 | ||
| 129 | /** |
|
| 130 | * \brief Dispatch each update to the right method (processMessage, processCallbackQuery, etc). |
|
| @@ 96-118 (lines=23) @@ | ||
| 93 | $this->initCommands(); |
|
| 94 | ||
| 95 | // Process all updates received |
|
| 96 | while (true) { |
|
| 97 | $updates = $this->getUpdates($offset, $limit, $timeout); |
|
| 98 | ||
| 99 | // Parse all updates received |
|
| 100 | foreach ($updates as $key => $update) { |
|
| 101 | try { |
|
| 102 | $this->processUpdate($update); |
|
| 103 | } catch (BotException $e) { |
|
| 104 | echo $e->getMessage(); |
|
| 105 | } |
|
| 106 | } |
|
| 107 | ||
| 108 | // Update the offset in redis |
|
| 109 | $this->redis->set($offset_key, $offset + count($updates)); |
|
| 110 | } |
|
| 111 | } |
|
| 112 | ||
| 113 | /** |
|
| 114 | * \brief (<i>Internal</i>) Get first update offset in database. |
|
| 115 | * \details Called by getUpdatesDatabase to get the offset saved in database or to get it from telegram and save it in database. |
|
| 116 | * @param $table_name Name of the table where offset is saved in the database |
|
| 117 | * @param $column_name Name of the column where the offset is saved in the database |
|
| 118 | * @return Id of the first update to process. |
|
| 119 | */ |
|
| 120 | protected function getUpdateOffsetDatabase(string $table_name, string $column_name) : int |
|
| 121 | { |
|