xn / ext-notification
laravel-admin notification helper
v1.0.6
2024-11-08 17:48 UTC
Requires
- php: >=8.1.0
- irazasyed/telegram-bot-sdk: ^3.14
- linecorp/line-bot-sdk: ^9.11
- xn/laravel-admin: >=1.0.60
Requires (Dev)
- phpunit/phpunit: ~6.0
This package is auto-updated.
Last update: 2025-01-08 10:09:44 UTC
README
Install & ENV
# composer
composer require xn/ext-notification
#publish config
php artisan vendor:publish --tag="ext-notification-config"
php artisan migrate
EXT_NOTIFY_PHRASE=
EXT_NOTIFY_SEED=
admin page
{APP_URL}/admin/notify-bots
{APP_URL}/admin/notify-chats
Notify Class
# line
\Xn\ExtNotification\Services\Notify::LineBot($chatToken)->send($message);
#$bot = new \Xn\ExtNotification\Services\LineBot($chatToken);
#$bot->send("測試看看\n測試Class");
# telegram
\Xn\ExtNotification\Services\Notify::TelegramBot($chatToken)->send($message);
#$bot = new \Xn\ExtNotification\Services\TelegramBot($chatToken);
#$res = $bot->send("測試看看\n測試Class");
# discord
\Xn\ExtNotification\Services\Notify::DiscordBot($chatToken)->send($message);
#$bot = new \Xn\ExtNotification\Services\DiscordBot($chatToken);
#$res = $bot->send("測試看看\n測試Class");
發送訊息
{APP_URL}/notify/line/send
{APP_URL}/notify/telegram/send
# 參數
{
"token": "", // Chat token
"message": "測試\n換行"
}
Notify Helper (Using AccessToken)
$notifier = new Xn\ExtNotification\Helpers\Notifier\Notifier();
$notifier
->telegram($botToken, $chatId)
->line($accessToken, $chatId)
->discord($botToken, $channelId)
->send("測試\n可以了");
CSRF
# bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
$middleware->validateCsrfTokens(except: [
'notify/*',
]);
})
webhook
{APP_URL}/notify/{type}/{botId}/webhook