mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update telegram
This commit is contained in:
		| @@ -24,16 +24,12 @@ class ConfigController extends Controller | ||||
|     public function setTelegramWebhook(Request $request) | ||||
|     { | ||||
|         $telegramService = new TelegramService($request->input('telegram_bot_token')); | ||||
|         if (!$telegramService->getMe()) { | ||||
|             abort(500, '机器人Token有误'); | ||||
|         } | ||||
|         if (!$telegramService->setWebhook( | ||||
|         $telegramService->getMe(); | ||||
|         $telegramService->setWebhook( | ||||
|             config('v2board.app_url') | ||||
|             . '/api/v1/guest/telegram/webhook?access_token=' | ||||
|             . md5(config('v2board.telegram_bot_token', $request->input('telegram_bot_token'))) | ||||
|         )) { | ||||
|             abort(500, 'Webhook设置失败'); | ||||
|         } | ||||
|         ); | ||||
|         return response([ | ||||
|             'data' => true | ||||
|         ]); | ||||
|   | ||||
							
								
								
									
										20
									
								
								app/Http/Controllers/User/TelegramController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								app/Http/Controllers/User/TelegramController.php
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Http\Controllers\User; | ||||
|  | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Services\TelegramService; | ||||
|  | ||||
| class TelegramController extends Controller | ||||
| { | ||||
|     public function getBotInfo() | ||||
|     { | ||||
|         $telegramService = new TelegramService(); | ||||
|         $response = $telegramService->getMe(); | ||||
|         return response([ | ||||
|             'data' => [ | ||||
|                 'username' => $response->result->username | ||||
|             ] | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| @@ -62,7 +62,8 @@ class UserController extends Controller | ||||
|                 'commission_balance', | ||||
|                 'plan_id', | ||||
|                 'discount', | ||||
|                 'commission_rate' | ||||
|                 'commission_rate', | ||||
|                 'telegram_id' | ||||
|             ]) | ||||
|             ->first(); | ||||
|         $user['avatar_url'] = 'https://cdn.v2ex.com/gravatar/' . md5($user->email) . '?s=64&d=identicon'; | ||||
|   | ||||
| @@ -51,6 +51,8 @@ class UserRoute | ||||
|             $router->get ('/server/log/fetch', 'User\\ServerController@logFetch'); | ||||
|             // Coupon | ||||
|             $router->post('/coupon/check', 'User\\CouponController@check'); | ||||
|             // Telegram | ||||
|             $router->get ('/telegram/getBotInfo', 'User\\TelegramController@getBotInfo'); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user