mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	update telegram
This commit is contained in:
		| @@ -2,6 +2,7 @@ | ||||
|  | ||||
| namespace App\Http\Controllers\Guest; | ||||
|  | ||||
| use App\Services\UserService; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
|  | ||||
| @@ -16,6 +17,32 @@ class TelegramController extends Controller | ||||
|  | ||||
|     public function webhook(Request $request) | ||||
|     { | ||||
|         info($request->input()); | ||||
|         $msg = $this->getMessage($request->input()); | ||||
|         if (!$msg) return; | ||||
|         switch($msg->command) { | ||||
|             case '/bind': $this->bind($msg); | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function getMessage(array $data) | ||||
|     { | ||||
|         if (!$data['message']) return false; | ||||
|         $obj = new \StdClass(); | ||||
|         $obj->is_private = $data['message']['chat']['type'] === 'private' ? true : false; | ||||
|         $text = explode(' ', $data['message']['text']); | ||||
|         $obj->command = $text[0] || ''; | ||||
|         $obj->args = array_slice($text, 1) || []; | ||||
|         $obj->chat_id = $data['message']['chat']['id'] || ''; | ||||
|         return $obj; | ||||
|     } | ||||
|  | ||||
|     private function bind(object $msg) | ||||
|     { | ||||
|         if (!$msg->is_private) return; | ||||
|         $userService = new UserService(); | ||||
|         $subscribeUrl = $msg->args[0]; | ||||
|         $subscribeUrl = parse_url($subscribeUrl); | ||||
|         info($subscribeUrl); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user