<?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 = "1287759048:AAEDiTPrgKYzNKguK6y6hXwV3-tWO2cpK6I";

        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();
        }
    }


}
