<?php
namespace App\Http\Controllers;


use App\Http\Controllers\Controller;
use App\Models\parser_films;
use App\TelegramBot\CallbackHandler;
use App\TelegramBot\InlineHandler;
use App\TelegramBot\MessagesHandler;


class BotController extends Controller
{

    public function __construct()
    {

    }

    public function callback($update){
        $update = json_decode($update);

        $token = "1634226596:AAGS5cBHczuhOdJEkPpq7WgKKwhGl4aUK_8";
 
        try {
            if (isset($update->message)) {
                $handler = new MessagesHandler();
                $handler->handle($update->message, $token);
            } else if (isset($update->callback_query)) {
                $handler = new CallbackHandler();
                $handler->handle($update->callback_query, $token);
            } else if (isset($update->inline_query)) {
                $handler = new InlineHandler();
                $handler->handle($update->inline_query, $token);
            }
        }catch (\Exception $e){
            echo 'ok';
            exit();
        }
    }


}
