mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	update telegram
This commit is contained in:
		| @@ -3,6 +3,7 @@ | ||||
| namespace App\Http\Controllers\Admin; | ||||
|  | ||||
| use App\Http\Requests\Admin\ConfigSave; | ||||
| use App\Services\TelegramService; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Utils\Dict; | ||||
| use App\Http\Controllers\Controller; | ||||
| @@ -20,6 +21,20 @@ class ConfigController extends Controller | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|     public function setTelegramWebhook() | ||||
|     { | ||||
|         $telegramService = new TelegramService(); | ||||
|         if (!$telegramService->getMe()) { | ||||
|             abort(500, '机器人Token有误'); | ||||
|         } | ||||
|         if (!$telegramService->setWebhook(config('v2board.app_url') . '/api/v1/guest/telegram/webhook?access_token=' . md5(config('v2board.telegram_bot_token')))) { | ||||
|             abort(500, 'Webhook设置失败'); | ||||
|         } | ||||
|         return response([ | ||||
|             'data' => true | ||||
|         ]); | ||||
|     } | ||||
|  | ||||
|     public function fetch() | ||||
|     { | ||||
|         // TODO: default should be in Dict | ||||
|   | ||||
							
								
								
									
										21
									
								
								app/Http/Controllers/Guest/TelegramController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								app/Http/Controllers/Guest/TelegramController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Http\Controllers\Guest; | ||||
|  | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
|  | ||||
| class TelegramController extends Controller | ||||
| { | ||||
|     public function __construct(Request $request) | ||||
|     { | ||||
|         if ($request->input('access_token') !== md5(config('v2board.telegram_bot_token'))) { | ||||
|             abort(500, 'authentication failed'); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public function webhook(Request $request) | ||||
|     { | ||||
|         info($request->input()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user