Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require recipient Telegram and validate bot token #324

Merged
merged 9 commits into from
Jan 13, 2023
14 changes: 11 additions & 3 deletions app/Filament/Pages/Settings/NotificationPage.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,27 @@ public function sendTestTelegramNotification()
{
$notificationSettings = new (NotificationSettings::class);

if (count($notificationSettings->telegram_recipients)) {
$bot = config('telegram.bot');

if (blank($bot)) {
Notification::make()
->title('First you need to add \'TELEGRAM_BOT_TOKEN\' on your .env file or add it as environment variable')
->warning()
->send();
}
if (! empty($notificationSettings->telegram_recipients)) {
foreach ($notificationSettings->telegram_recipients as $recipient) {
\Illuminate\Support\Facades\Notification::route('telegram_chat_id', $recipient['telegram_chat_id'])
->notify(new TelegramNotification('Test notification channel *telegram*'));
}

Notification::make()
->title('Test telegram notification sent.')
->title('Test Telegram notification sent.')
->success()
->send();
} else {
Notification::make()
->title('You need to add recipients to receive telegram notifications.')
->title('You need to add recipients to receive Telegram notifications.')
->warning()
->send();
}
Expand Down
5 changes: 5 additions & 0 deletions config/telegram.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php

return [
'bot' => env('TELEGRAM_BOT_TOKEN', null),
];