Merge pull request #50 from apuc/telegram-bot-notification
Interview telegram bot notification
This commit is contained in:
commit
111d9094c8
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,7 +22,7 @@ Thumbs.db
|
||||
|
||||
# composer itself is not needed
|
||||
composer.phar
|
||||
|
||||
composer.lock
|
||||
# Mac DS_Store Files
|
||||
.DS_Store
|
||||
|
||||
|
@ -31,7 +31,8 @@
|
||||
"kartik-v/yii2-grid": "dev-master",
|
||||
"kartik-v/yii2-widget-datetimepicker": "dev-master",
|
||||
"edofre/yii2-fullcalendar-scheduler": "V1.1.12",
|
||||
"asmoday74/yii2-ckeditor5": "*"
|
||||
"asmoday74/yii2-ckeditor5": "*",
|
||||
"kavalar/telegram_bot": "^0.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"yiisoft/yii2-debug": "~2.0.0",
|
||||
|
@ -6,6 +6,7 @@ use common\behaviors\GsCors;
|
||||
use common\classes\Debug;
|
||||
use common\models\InterviewRequest;
|
||||
use frontend\modules\api\models\ProfileSearchForm;
|
||||
use kavalar\TelegramBotService;
|
||||
use yii\filters\auth\CompositeAuth;
|
||||
use yii\filters\auth\HttpBearerAuth;
|
||||
use yii\filters\auth\QueryParamAuth;
|
||||
@ -59,11 +60,26 @@ class ProfileController extends \yii\rest\Controller
|
||||
public function actionAddToInterview()
|
||||
{
|
||||
if (\Yii::$app->request->isPost) {
|
||||
$attributes = \Yii::$app->request->post();
|
||||
|
||||
$model = new InterviewRequest();
|
||||
$model->attributes = \Yii::$app->request->post();
|
||||
$model->attributes = $attributes;
|
||||
$model->created_at = time();
|
||||
$model->user_id = \Yii::$app->user->id;
|
||||
|
||||
if ($model->save()) {
|
||||
$token = \Yii::$app->params['telegramBotToken'];
|
||||
$chat_id = \Yii::$app->params['telegramBotChatId'];
|
||||
|
||||
$message =
|
||||
"Пришёл запрос на интервью.\n".
|
||||
"Профиль: {$attributes['profile_id']}\n".
|
||||
"Телефон: {$attributes['phone']}\n".
|
||||
"Email: {$attributes['email']}\n".
|
||||
"Комментарий: {$attributes['comment']}";
|
||||
|
||||
$bot = new TelegramBotService($token);
|
||||
$bot->sendMessageTo($chat_id, $message);
|
||||
return ['status' => 'success'];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user