public function sendNotification(User $user, $text, $subject) { $message = $this->swiftMailer->createMessage(); $message->setBody($text); $message->setCharset('utf-8'); $message->addFrom($this->fromEmail, $this->fromEmailSender); $message->addTo($user->getEmail()); $message->setSubject($subject); $message->setContentType('text/html'); $this->swiftMailer->send($message); $this->logger->info('Отправлено письмо пользователю ' . $user->getEmail(), ['text' => $text, 'subject' => $subject]); }
public function handleUpdate(Update $update) { $message = json_decode(json_encode($update->message), true); $this->findUser($message['chat']['id']); $this->logger->info('Сообщение из telegram', ['user' => $this->user ? $this->user->getEmail() : 'new', 'message' => $message]); $messageText = trim($message['text']); if (is_numeric($messageText)) { $this->confirmRegistration($messageText, $message); } elseif ($this->user === null) { $this->botApi->sendMessage($message['chat']['id'], 'Для использования бота необходимо зарегистрироваться на сайте http://lf.dizzy.name'); } else { $command = trim($message['text']); $matches = []; if ($command === '/sites') { $text = $this->sitesListCommand(); } elseif ($command === '/list') { $text = $this->getShowsList(); } elseif (preg_match('#/site_(.*?)_list#', $command, $matches)) { $text = $this->siteShowsList($matches[1]); } elseif (preg_match('#/subscribe_site_(.*)#', $command, $matches)) { $text = $this->subscribeNewShows($matches[1]); } elseif (preg_match('#/subscribe_(.*)#', $command, $matches)) { $text = $this->subscribeShow($matches[1]); } elseif (preg_match('#/unsubscribe_site_(.*)#', $command, $matches)) { $text = $this->unsubscribeNewShows($matches[1]); } elseif (preg_match('#/unsubscribe_(.*)#', $command, $matches)) { $text = $this->unsubscribeShow($matches[1]); } else { $text = $this->helpCommand(); } if (is_array($text)) { $chunks = array_chunk($text, 25); foreach ($chunks as $chunk) { $this->botApi->sendMessage($message['chat']['id'], implode("\n", $chunk)); } } else { $this->botApi->sendMessage($message['chat']['id'], $text); } } }
public function sendNotification(User $user, $text, $subject) { $this->botApi->sendMessage($user->getTelegramId(), $text); $this->logger->info('Отправлено сообщение telegram пользователю ' . $user->getEmail(), ['text' => $text]); }