<?php

// init pandabot
checkPandabotPID();
loadPandabotConfig();

require_once 'vendor/autoload.php';

use danog\MadelineProto\Settings;
use danog\MadelineProto\Settings\AppInfo;
use danog\MadelineProto\Settings\Connection;
use danog\MadelineProto\Settings\RPC;
use danog\MadelineProto\Settings\Database\Postgres;

$settings = new Settings;
$globalsettings["bot"]["version"].=" (MP: ".explode(" ",$settings->getAppInfo(new AppInfo)->getAppVersion())[0].")";

$settings->setAppInfo((new AppInfo)->setApiId($globalsettings["tgapp"]["APIID"])->setApiHash($globalsettings["tgapp"]["APIHASH"])->setAppVersion($globalsettings["bot"]["version"]));

$settings->setConnection((new Connection)->setTimeout($globalsettings["tgapp"]["setTimeout"]));
$settings->setRPC((new RPC)->setRpcResendTimeout($globalsettings["tgapp"]["setRpcResendTimeout"]));

$MadelineProto = new \danog\MadelineProto\API('session.madeline', $settings);
$MadelineProto->start();

$getSelf=$MadelineProto->getSelf();
$globalsettings["bot"]["pandaownerid"]=$getSelf['id'];
$globalsettings["bot"]["pandaownername"]="@".$getSelf['username'];
$pandaOwnerName="@".$getSelf['username'];


