-
-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Telegram notification channel (#265)
- Loading branch information
Showing
13 changed files
with
322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace App\Forms\Components; | ||
|
||
use Filament\Forms\Components\Field; | ||
|
||
class TestTelegramNotification extends Field | ||
{ | ||
protected string $view = 'forms.components.test-telegram-notification'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace App\Telegram; | ||
|
||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Notifications\Notification; | ||
use NotificationChannels\Telegram\TelegramMessage; | ||
|
||
class TelegramNotification extends Notification | ||
{ | ||
use Queueable; | ||
|
||
protected $message; | ||
|
||
/** | ||
* Create a new notification instance. | ||
* | ||
* @return void | ||
*/ | ||
public function __construct($message) | ||
{ | ||
$this->message = $message; | ||
} | ||
|
||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @param mixed $notifiable | ||
* @return array | ||
*/ | ||
public function via($notifiable) | ||
{ | ||
return ['telegram']; | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
* | ||
* @param mixed $notifiable | ||
* @return \Illuminate\Notifications\Messages\MailMessage | ||
*/ | ||
public function toTelegram($notifiable) | ||
{ | ||
return TelegramMessage::create() | ||
->to($notifiable->routes['telegram_chat_id']) | ||
->content($this->message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
database/settings/2022_12_22_125055_create_telegram_notification_settings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
use Spatie\LaravelSettings\Migrations\SettingsMigration; | ||
|
||
class CreateTelegramNotificationSettings extends SettingsMigration | ||
{ | ||
public function up(): void | ||
{ | ||
$this->migrator->add('notification.telegram_enabled', false); | ||
$this->migrator->add('notification.telegram_on_speedtest_run', false); | ||
$this->migrator->add('notification.telegram_on_threshold_failure', false); | ||
$this->migrator->add('notification.telegram_recipients', null); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
resources/views/forms/components/test-telegram-notification.blade.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div> | ||
<x-filament::button wire:click="sendTestTelegramNotification()"> | ||
Test telegram channel | ||
</x-filament::button> | ||
</div> |
Oops, something went wrong.