Used NotificationProcessor for interview request notification
This commit is contained in:
parent
111d9094c8
commit
c6797c7738
@ -32,7 +32,7 @@
|
|||||||
"kartik-v/yii2-widget-datetimepicker": "dev-master",
|
"kartik-v/yii2-widget-datetimepicker": "dev-master",
|
||||||
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",
|
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",
|
||||||
"asmoday74/yii2-ckeditor5": "*",
|
"asmoday74/yii2-ckeditor5": "*",
|
||||||
"kavalar/telegram_bot": "^0.1.0"
|
"kavalar/telegram_bot": "0.2"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"yiisoft/yii2-debug": "~2.0.0",
|
"yiisoft/yii2-debug": "~2.0.0",
|
||||||
|
2392
composer.lock
generated
2392
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,7 @@ use common\behaviors\GsCors;
|
|||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
use common\models\InterviewRequest;
|
use common\models\InterviewRequest;
|
||||||
use frontend\modules\api\models\ProfileSearchForm;
|
use frontend\modules\api\models\ProfileSearchForm;
|
||||||
|
use kavalar\BotNotificationTemplateProcessor;
|
||||||
use kavalar\TelegramBotService;
|
use kavalar\TelegramBotService;
|
||||||
use yii\filters\auth\CompositeAuth;
|
use yii\filters\auth\CompositeAuth;
|
||||||
use yii\filters\auth\HttpBearerAuth;
|
use yii\filters\auth\HttpBearerAuth;
|
||||||
@ -71,12 +72,16 @@ class ProfileController extends \yii\rest\Controller
|
|||||||
$token = \Yii::$app->params['telegramBotToken'];
|
$token = \Yii::$app->params['telegramBotToken'];
|
||||||
$chat_id = \Yii::$app->params['telegramBotChatId'];
|
$chat_id = \Yii::$app->params['telegramBotChatId'];
|
||||||
|
|
||||||
$message =
|
$templates = [
|
||||||
"Пришёл запрос на интервью.\n".
|
'interview_request' =>
|
||||||
"Профиль: {$attributes['profile_id']}\n".
|
"Пришёл запрос на интервью.\n".
|
||||||
"Телефон: {$attributes['phone']}\n".
|
"Профиль: ~profile_id~\n".
|
||||||
"Email: {$attributes['email']}\n".
|
"Телефон: ~phone~\n".
|
||||||
"Комментарий: {$attributes['comment']}";
|
"Email: ~email~\n".
|
||||||
|
"Комментарий: ~comment~"
|
||||||
|
];
|
||||||
|
$templateProcessor = new BotNotificationTemplateProcessor($templates);
|
||||||
|
$message = $templateProcessor->renderTemplate('interview_request', $attributes);
|
||||||
|
|
||||||
$bot = new TelegramBotService($token);
|
$bot = new TelegramBotService($token);
|
||||||
$bot->sendMessageTo($chat_id, $message);
|
$bot->sendMessageTo($chat_id, $message);
|
||||||
|
Loading…
Reference in New Issue
Block a user