@@ 96-119 (lines=24) @@ | ||
93 | $this->initCommands(); |
|
94 | ||
95 | // Process all updates |
|
96 | while (true) { |
|
97 | $updates = $this->execRequest("getUpdates?offset=$offset&limit=$limit&timeout=$timeout"); |
|
98 | ||
99 | foreach ($updates as $key => $update) { |
|
100 | try { |
|
101 | $this->processUpdate($update); |
|
102 | } catch (BotException $e) { |
|
103 | echo $e->getMessage(); |
|
104 | } |
|
105 | } |
|
106 | ||
107 | $offset += sizeof($updates); |
|
108 | } |
|
109 | } |
|
110 | ||
111 | /** @} */ |
|
112 | ||
113 | /** |
|
114 | * @internal |
|
115 | * \brief Dispatch each update to the right method (processMessage, processCallbackQuery, etc). |
|
116 | * \details Set $chat_id for each update, $text, $data and $query are set for each update that contains them. |
|
117 | * @param array $update Reference to the update received. |
|
118 | * @return int The id of the update processed. |
|
119 | */ |
|
120 | protected function processUpdate(array $update) : int |
|
121 | { |
|
122 | static $updates_type = ['message' => 'Message', |
@@ 81-95 (lines=15) @@ | ||
78 | $this->initCommands(); |
|
79 | ||
80 | // Process all updates received |
|
81 | while (true) { |
|
82 | $updates = $this->getUpdates($offset, $limit, $timeout); |
|
83 | ||
84 | foreach ($updates as $key => $update) { |
|
85 | try { |
|
86 | $this->processUpdate($update); |
|
87 | } catch (BotException $e) { |
|
88 | echo $e->getMessage(); |
|
89 | } |
|
90 | } |
|
91 | ||
92 | // Update the offset in redis |
|
93 | $this->redis->set($offset_key, $offset + count($updates)); |
|
94 | } |
|
95 | } |
|
96 | ||
97 | /** |
|
98 | * @internal |