Skip to content

Commit 6486520

Browse files
committed
Return array of ServerResponse objects when calling Telegram::runCommands
1 parent 5e99f4a commit 6486520

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Exclamation symbols (:exclamation:) note something of importance e.g. breaking c
99
### Added
1010
- Bot API 5.2 (Payments 2.0).
1111
### Changed
12+
- `Telegram::runCommands` returns array of `ServerResponse` objects of executed commands.
1213
### Deprecated
1314
### Removed
1415
### Fixed

src/Telegram.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,9 +1117,11 @@ public function enableLimiter(array $options = []): Telegram
11171117
*
11181118
* @param array $commands
11191119
*
1120+
* @return ServerResponse[]
1121+
*
11201122
* @throws TelegramException
11211123
*/
1122-
public function runCommands(array $commands): void
1124+
public function runCommands(array $commands): array
11231125
{
11241126
if (empty($commands)) {
11251127
throw new TelegramException('No command(s) provided!');
@@ -1175,17 +1177,21 @@ public function runCommands(array $commands): void
11751177
]);
11761178
};
11771179

1180+
$responses = [];
1181+
11781182
foreach ($commands as $command) {
11791183
$this->update = $newUpdate($command);
11801184

11811185
// Refresh commands list for new Update object.
11821186
$this->commands_objects = $this->getCommandsList();
11831187

1184-
$this->executeCommand($this->update->getMessage()->getCommand());
1188+
$responses[] = $this->executeCommand($this->update->getMessage()->getCommand());
11851189
}
11861190

11871191
// Reset Update to initial context.
11881192
$this->update = $userUpdate;
1193+
1194+
return $responses;
11891195
}
11901196

11911197
/**

0 commit comments

Comments
 (0)