@@ -57,16 +57,16 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - #[\Override] |
|
| 61 | - public function send(string $identifier, string $message, array $extra = []): void { |
|
| 60 | + #[\Override ] |
|
| 61 | + public function send(string $identifier, string $message, array $extra = [ ]): void { |
|
| 62 | 62 | if (empty($message)) { |
| 63 | - $message = $this->l10n->t('`%s` is your Nextcloud verification code.', [$extra['code']]); |
|
| 63 | + $message = $this->l10n->t('`%s` is your Nextcloud verification code.', [ $extra[ 'code' ] ]); |
|
| 64 | 64 | } |
| 65 | 65 | $this->logger->debug("sending telegram message to $identifier, message: $message"); |
| 66 | 66 | $token = $this->getToken(); |
| 67 | 67 | $this->logger->debug("telegram bot token: $token"); |
| 68 | 68 | |
| 69 | - $url = self::TELEGRAM_API_URL . $token . '/sendMessage'; |
|
| 69 | + $url = self::TELEGRAM_API_URL.$token.'/sendMessage'; |
|
| 70 | 70 | $params = [ |
| 71 | 71 | 'chat_id' => $identifier, |
| 72 | 72 | 'text' => $message, |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | $body = $response->getBody(); |
| 85 | 85 | $data = json_decode($body, true); |
| 86 | 86 | |
| 87 | - if (!isset($data['ok']) || $data['ok'] !== true) { |
|
| 88 | - $errorDescription = $data['description'] ?? 'Unknown error'; |
|
| 89 | - $this->logger->error('Telegram API error: ' . $errorDescription); |
|
| 90 | - throw new MessageTransmissionException('Telegram API error: ' . $errorDescription); |
|
| 87 | + if (!isset($data[ 'ok' ]) || $data[ 'ok' ] !== true) { |
|
| 88 | + $errorDescription = $data[ 'description' ] ?? 'Unknown error'; |
|
| 89 | + $this->logger->error('Telegram API error: '.$errorDescription); |
|
| 90 | + throw new MessageTransmissionException('Telegram API error: '.$errorDescription); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $this->logger->debug("telegram message to chat $identifier sent"); |
@@ -96,15 +96,15 @@ discard block |
||
| 96 | 96 | 'exception' => $e, |
| 97 | 97 | 'chat_id' => $identifier, |
| 98 | 98 | ]); |
| 99 | - throw new MessageTransmissionException('Failed to send Telegram message: ' . $e->getMessage(), 0, $e); |
|
| 99 | + throw new MessageTransmissionException('Failed to send Telegram message: '.$e->getMessage(), 0, $e); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - #[\Override] |
|
| 103 | + #[\Override ] |
|
| 104 | 104 | public function cliConfigure(InputInterface $input, OutputInterface $output): int { |
| 105 | 105 | $helper = new QuestionHelper(); |
| 106 | 106 | $settings = $this->getSettings(); |
| 107 | - $tokenQuestion = new Question($settings->fields[0]->prompt . ' '); |
|
| 107 | + $tokenQuestion = new Question($settings->fields[ 0 ]->prompt.' '); |
|
| 108 | 108 | $token = $helper->ask($input, $output, $tokenQuestion); |
| 109 | 109 | $this->setToken($token); |
| 110 | 110 | $output->writeln("Using $token."); |