File tree Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Expand file tree Collapse file tree 3 files changed +21
-5
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,6 @@ private function notificationToTelegram($exception)
3939 // Send notification to Telegram
4040 try {
4141 TelegramMessage::create ()
42- ->toNotGiven ()
4342 ->to (config ('services.telegram-bot-api.chat_id ' ))
4443 ->line ('*⚠️ Ой-ой-ой!* Возникла неприятность в нашем коде. Пользователь столкнулся с неожиданной ошибкой на сайте. ' )
4544 ->line ('` ' )
Original file line number Diff line number Diff line change 1111use Illuminate \Database \Eloquent \Model ;
1212use Illuminate \Support \Str ;
1313use Laravel \Scout \Searchable ;
14+ use NotificationChannels \Telegram \TelegramMessage ;
1415use Orchid \Filters \Filterable ;
1516use Orchid \Filters \Types \Like ;
1617use Orchid \Metrics \Chartable ;
@@ -85,6 +86,22 @@ public static function boot()
8586
8687 $ post ->slug = $ slug ;
8788 });
89+
90+ static ::created (function (Post $ post ){
91+ try {
92+ if (config ('app.env ' ) == 'local ' ) {
93+ return ;
94+ }
95+
96+ TelegramMessage::create ()
97+ ->to (config ('services.telegram-bot-api.channel_id ' ))
98+ ->escapedLine ($ post ->title )
99+ ->content (route ('post.show ' , $ post ))
100+ ->send ();
101+ } catch (\Throwable $ e ) {
102+ report ($ e );
103+ }
104+ });
88105 }
89106
90107 /**
Original file line number Diff line number Diff line change 4444 ],
4545
4646 'telegram-bot-api ' => [
47- 'bot_name ' => env ('TELEGRAM_BOT_NAME ' ),
48- 'token ' => env ('TELEGRAM_BOT_TOKEN ' ),
49- 'chat_id ' => env ('TELEGRAM_CHAT_ID ' ),
50- 'report_chat_id ' => env ('TELEGRAM_REPORT_CHAT_ID ' ),
47+ 'bot_name ' => env ('TELEGRAM_BOT_NAME ' ),
48+ 'token ' => env ('TELEGRAM_BOT_TOKEN ' ),
49+ 'chat_id ' => env ('TELEGRAM_CHAT_ID ' ),
50+ 'channel_id ' => env ('TELEGRAM_CHANNEL_ID ' ),
5151 ],
5252];
You can’t perform that action at this time.
0 commit comments