diff --git a/config/telegram-git-notifier.php b/config/telegram-git-notifier.php index c0dfe2b..f778fc6 100644 --- a/config/telegram-git-notifier.php +++ b/config/telegram-git-notifier.php @@ -3,5 +3,31 @@ return [ 'app' => [ 'name' => env('APP_NAME', 'Laravel Telegram Git Notify'), + 'url' => env('APP_URL', 'http://localhost:8000'), + 'timezone' => env('TIMEZONE','Asia/Ho_Chi_Minh'), ], + + 'telegram-bot' => [ + 'token' => env('TELEGRAM_BOT_TOKEN', ''), + 'chat_id' => env('TELEGRAM_BOT_CHAT_ID', ''), + 'notify_chat_ids' => explode( + ',', + env('TELEGRAM_NOTIFY_CHAT_IDS', '') + ), + ], + + 'author' => [ + 'contact' => env('TGN_AUTHOR_CONTACT', 'https://t.me/tannp27'), + 'source_code' => env('TGN_AUTHOR_SOURCE_CODE','https://github.com/lbiltech/telegram-git-notifier'), + ], + + 'view' => [ + 'path' => env('TGN_VIEW_PATH', 'resources/views/telegram-git-notifier'), + 'event' => [ + 'default' => env('TGN_VIEW_EVENT_DEFAULT', 'default'), + ], + 'globals' => [ + 'access_denied' => env('TGN_VIEW_GLOBALS_ACCESS_DENIED', 'globals.access_denied'), + ] + ] ]; diff --git a/routes/bot.php b/routes/bot.php index e69de29..4b71d1c 100644 --- a/routes/bot.php +++ b/routes/bot.php @@ -0,0 +1,21 @@ +group(function () { + Route::get('/set-webhook', [WebhookAction::class, 'set'])->name('set-webhook'); + Route::get('/delete-webhook', [WebhookAction::class, 'delete'])->name('delete-webhook'); +}); + diff --git a/src/Http/Actions/WebhookAction.php b/src/Http/Actions/WebhookAction.php new file mode 100644 index 0000000..6a1682c --- /dev/null +++ b/src/Http/Actions/WebhookAction.php @@ -0,0 +1,44 @@ +webhookService = $webhookService; + $this->webhookService->setToken(config('telegram-git-notifier.telegram-bot.token')); + $this->webhookService->setUrl(config('telegram-git-notifier.app.url')); + } + + /** + * Set webhook for telegram bot + * + * @return false|string + */ + public function set(): false|string + { + return $this->webhookService->setWebhook(); + } + + /** + * Delete webhook for telegram bot + * + * @return false|string + */ + public function delete(): false|string + { + return $this->webhookService->deleteWebHook(); + } +}