twig->render($template, $templateData); foreach ($accounts as $account) { $this->sendMessage($account, $text, $parseMode, $keyboardMarkup, $disableWebPreview, $disableNotifications); } } public function sendTemplatedMessage( Account $account, string $template, array $templateData = [], ReplyKeyboardMarkup $keyboardMarkup = null, bool $disableWebPreview = true, bool $disableNotifications = false, string $parseMode = self::PARSE_MARKDOWN_V2 ): bool { $text = $this->twig->render($template, $templateData); return $this->sendMessage($account, $text, $parseMode, $keyboardMarkup, $disableWebPreview, $disableNotifications); } public function sendMessage( Account $account, string $text, string $parseMode = self::PARSE_PLAIN, ReplyKeyboardMarkup $keyboardMarkup = null, bool $disableWebPreview = false, bool $disableNotifications = false ): bool { return $this->sendMessageToChat($account->getChatId(), $text, $parseMode, $keyboardMarkup, $disableWebPreview, $disableNotifications); } public function sendMessageToChat( int $chatId, string $text, string $parseMode = self::PARSE_PLAIN, ReplyKeyboardMarkup $keyboardMarkup = null, bool $disableWebPreview = false, bool $disableNotifications = false ): bool { try { $this->client->sendMessage( chatId: (string) $chatId, text: $text, parseMode: $parseMode, disablePreview: $disableWebPreview, replyMarkup: $keyboardMarkup, disableNotification: $disableNotifications, ); return true; } catch (\Exception $e) { $this->log->error('sendMessageToChat', [ 'error' => $e->getMessage(), 'file' => $e->getFile() . ':' . $e->getLine(), ]); return false; } } }