Used NotificationProcessor for interview request notification

This commit is contained in:
Korzinkayablok 2021-08-25 17:22:20 +03:00
parent 111d9094c8
commit c6797c7738
3 changed files with 1846 additions and 565 deletions

View File

@ -32,7 +32,7 @@
"kartik-v/yii2-widget-datetimepicker": "dev-master",
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",
"asmoday74/yii2-ckeditor5": "*",
"kavalar/telegram_bot": "^0.1.0"
"kavalar/telegram_bot": "0.2"
},
"require-dev": {
"yiisoft/yii2-debug": "~2.0.0",

2392
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,7 @@ use common\behaviors\GsCors;
use common\classes\Debug;
use common\models\InterviewRequest;
use frontend\modules\api\models\ProfileSearchForm;
use kavalar\BotNotificationTemplateProcessor;
use kavalar\TelegramBotService;
use yii\filters\auth\CompositeAuth;
use yii\filters\auth\HttpBearerAuth;
@ -71,12 +72,16 @@ class ProfileController extends \yii\rest\Controller
$token = \Yii::$app->params['telegramBotToken'];
$chat_id = \Yii::$app->params['telegramBotChatId'];
$message =
$templates = [
'interview_request' =>
"Пришёл запрос на интервью.\n".
"Профиль: {$attributes['profile_id']}\n".
"Телефон: {$attributes['phone']}\n".
"Email: {$attributes['email']}\n".
"Комментарий: {$attributes['comment']}";
"Профиль: ~profile_id~\n".
"Телефон: ~phone~\n".
"Email: ~email~\n".
"Комментарий: ~comment~"
];
$templateProcessor = new BotNotificationTemplateProcessor($templates);
$message = $templateProcessor->renderTemplate('interview_request', $attributes);
$bot = new TelegramBotService($token);
$bot->sendMessageTo($chat_id, $message);