| @@ 1155-1181 (lines=27) @@ | ||
| 1152 | * |
|
| 1153 | * @return Update|Update[] |
|
| 1154 | */ |
|
| 1155 | public function commandsHandler($webhook = false) |
|
| 1156 | { |
|
| 1157 | if ($webhook) { |
|
| 1158 | $update = $this->getWebhookUpdates(); |
|
| 1159 | $this->processCommand($update); |
|
| 1160 | ||
| 1161 | return $update; |
|
| 1162 | } |
|
| 1163 | ||
| 1164 | $updates = $this->getUpdates(); |
|
| 1165 | $highestId = -1; |
|
| 1166 | ||
| 1167 | foreach ($updates as $update) { |
|
| 1168 | $highestId = $update->getUpdateId(); |
|
| 1169 | $this->processCommand($update); |
|
| 1170 | } |
|
| 1171 | ||
| 1172 | //An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. |
|
| 1173 | if ($highestId != -1) { |
|
| 1174 | $params = []; |
|
| 1175 | $params['offset'] = $highestId + 1; |
|
| 1176 | $params['limit'] = 1; |
|
| 1177 | $this->getUpdates($params); |
|
| 1178 | } |
|
| 1179 | ||
| 1180 | return $updates; |
|
| 1181 | } |
|
| 1182 | ||
| 1183 | ||
| 1184 | /** |
|
| @@ 1191-1217 (lines=27) @@ | ||
| 1188 | * |
|
| 1189 | * @return Update|Update[] |
|
| 1190 | */ |
|
| 1191 | public function conversationsHandler($webhook = false) |
|
| 1192 | { |
|
| 1193 | if ($webhook) { |
|
| 1194 | $update = $this->getWebhookUpdates(); |
|
| 1195 | $this->processConversation($update); |
|
| 1196 | ||
| 1197 | return $update; |
|
| 1198 | } |
|
| 1199 | ||
| 1200 | $updates = $this->getUpdates(); |
|
| 1201 | $highestId = -1; |
|
| 1202 | ||
| 1203 | foreach ($updates as $update) { |
|
| 1204 | $highestId = $update->getUpdateId(); |
|
| 1205 | $this->processConversation($update); |
|
| 1206 | } |
|
| 1207 | ||
| 1208 | //An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. |
|
| 1209 | if ($highestId != -1) { |
|
| 1210 | $params = []; |
|
| 1211 | $params['offset'] = $highestId + 1; |
|
| 1212 | $params['limit'] = 1; |
|
| 1213 | $this->getUpdates($params); |
|
| 1214 | } |
|
| 1215 | ||
| 1216 | return $updates; |
|
| 1217 | } |
|
| 1218 | ||
| 1219 | ||
| 1220 | ||